SpringWebFlow+;Primefaces应用程序没有';它不能正常工作
我叫托马斯兹,这是我的第一个问题。这是我的问题 我是一名初级JavaEE开发人员,在JavaEE、Spring、SpringWebflow、JSF2和Primefaces方面有4个月的经验。我想通过自己的web应用程序了解更多信息。 我没有使用我提到的技术启动一个新项目的经验,所以基本上我复制了一个模板应用程序,并对其进行了一些修改(大部分删除了我现在不需要的不必要的功能)。因此,我的应用程序包含:SpringWebFlow+;Primefaces应用程序没有';它不能正常工作,spring,jsf,primefaces,spring-webflow,Spring,Jsf,Primefaces,Spring Webflow,我叫托马斯兹,这是我的第一个问题。这是我的问题 我是一名初级JavaEE开发人员,在JavaEE、Spring、SpringWebflow、JSF2和Primefaces方面有4个月的经验。我想通过自己的web应用程序了解更多信息。 我没有使用我提到的技术启动一个新项目的经验,所以基本上我复制了一个模板应用程序,并对其进行了一些修改(大部分删除了我现在不需要的不必要的功能)。因此,我的应用程序包含: -弹簧3.2.2 -SpringWebFlow 2.3.2 -JSF 2.1.22 -Prime
-弹簧3.2.2
-SpringWebFlow 2.3.2
-JSF 2.1.22
-Primefaces 3.5
-和HibernateJPA(这没关系,这部分工作得很好) 作为服务器,我使用Tomcat7.0.40 我使用许多配置教程配置了我的应用程序。应用程序可以工作,它没有警告,但它不能正常工作。让我向您展示屏幕截图: 首先,当我启动应用程序时,它看起来是这样的:
但在按F5刷新浏览器后,它看起来应该从一开始就刷新:
这对我来说真是一种奇怪的行为,我不知道为什么会发生。浏览器不重要。我曾在Chrome、FireFox和IE上试用过,效果相同 p:commandLink似乎忽视了我。我点击它,什么也没发生。当我有选择的时候
ajax="false"
启用后,看起来页面已刷新,但仍然没有发生任何事情。我在工作中经常和primefaces和swf打交道,这对我来说从来没有发生过
以下是我申请的一些细节,我可以根据要求发布所有内容:
模板(main.xhtml):
如果需要更多详细信息,请告诉我。我遇到了完全相同的问题,我在这个问题上做了一些研究,并做了一些变通来修复这个错误(因为我的项目已经很晚了)。稍后我会提供一个健壮的解决方案,但我得到的是: 您正在使用
springwebflow
的起始页是index.jsp,带有
,以强制重定向到主web流
您将在浏览器控制台中发现2个JavaScript错误:
ReferenceError:$未定义
ReferenceError:未定义PrimeFaces
标记显然没有在重定向上获取一些Primefaces JavaScript文件和CSS。我发现重定向资源获取失败存在问题。建议的解决方案是在
中添加
。因此,我在
中添加了缺少的脚本和CSS文件,效果非常好
<h:outputStylesheet library="primefaces" name="primefaces.css" />
<h:outputStylesheet library="primefaces" name="layout/layout.css" />
<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />
<h:outputScript library="primefaces" name="jquery/jquery-plugins.js" target="head" />
<h:outputScript library="primefaces" name="primefaces.js" target="head" />
<h:outputScript library="primefaces" name="layout/layout.js" target="head" />
我遇到了完全相同的问题,我在这个问题上钻研了一些东西,并做了一些变通来修复这个bug(因为我的项目已经很晚了)。稍后我会提供一个健壮的解决方案,但我得到的是: 您正在使用
springwebflow
的起始页是index.jsp,带有
,以强制重定向到主web流
您将在浏览器控制台中发现2个JavaScript错误:
ReferenceError:$未定义
ReferenceError:未定义PrimeFaces
标记显然没有在重定向上获取一些Primefaces JavaScript文件和CSS。我发现重定向资源获取失败存在问题。建议的解决方案是在
中添加
。因此,我在
中添加了缺少的脚本和CSS文件,效果非常好
<h:outputStylesheet library="primefaces" name="primefaces.css" />
<h:outputStylesheet library="primefaces" name="layout/layout.css" />
<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />
<h:outputScript library="primefaces" name="jquery/jquery-plugins.js" target="head" />
<h:outputScript library="primefaces" name="primefaces.js" target="head" />
<h:outputScript library="primefaces" name="layout/layout.js" target="head" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:form>
<a href="#{facesContext.externalContext.requestContextPath}"> <p:graphicImage
name="logo.png" library="images/application" />
</a>
<h:panelGrid columns="3" style="width: 100%">
<h:column>
<p:menubar style="width: 300px">
<p:menuitem value="Strona Główna" action="forwardTo" ajax="false">
<f:setPropertyActionListener target="#{flowController.flowId}"
value="main" />
</p:menuitem>
<p:submenu label="MENU_2">
</p:submenu>
</p:menubar>
</h:column>
<h:column>
<h:outputText value="Zalogowany jako: " style="float: right" />
</h:column>
<p:column>
<p:menuButton
value="#{mainController.loggedUser != null ? mainController.loggedUser.login : 'Gość'}">
<p:menuitem value="Zaloguj" action="forwardTo" ajax="false">
<f:setPropertyActionListener target="#{flowController.flowId}"
value="login" />
</p:menuitem>
<p:menuitem value="Wyloguj" />
</p:menuButton>
</p:column>
</h:panelGrid>
</h:form>
</ui:composition>
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"
abstract="true">
<end-state id="endAndForwardTo" view="flowRedirect:#{flowController.flowId}" />
<global-transitions>
<transition on="forwardTo" to="endAndForwardTo" validate="false" />
<transition on="endAndForwardTo" to="endAndForwardTo" />
</global-transitions>
</flow>
package tomashoov.polskielowiska.flow;
import org.apache.log4j.Logger;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@Component
@Scope("session")
public class FlowController {
private Logger LOG = Logger.getLogger(FlowController.class);
public final static String MAIN = "main";
public final static String LOGIN = "login";
private String flowId = MAIN;
public String getFlowId() {
return flowId;
}
public void setFlowId(String flowId) {
this.flowId = flowId;
}
}
<h:outputStylesheet library="primefaces" name="primefaces.css" />
<h:outputStylesheet library="primefaces" name="layout/layout.css" />
<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />
<h:outputScript library="primefaces" name="jquery/jquery-plugins.js" target="head" />
<h:outputScript library="primefaces" name="primefaces.js" target="head" />
<h:outputScript library="primefaces" name="layout/layout.js" target="head" />