Xtr*_*ica 2 java primefaces jsf-2
我的Mojarra 2.1.6 Web应用程序有问题,我正在使用@ViewScoped托管bean 开发它,每个bean都附加到xhtml页面.这个页面正在接收一些视图参数,并在以这种方式初始化bean之后:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui"
template="/templates/general_template.xhtml">
<ui:define name="metadata">
<f:metadata>
<f:viewParam id="user" name="user"
value="#{navegableUserData._ParamUser}" />
<f:viewParam id="NavIndex" name="NavIndex"
value="#{navegableUserData._QueueIndex}" />
<f:event type="preRenderView"
listener="#{navegableUserData.initialize}" />
</f:metadata>
<h:message for="user" />
</ui:define>
<ui:define name="general_content">
<p:outputPanel autoUpdate="false" id="Datos_Loged" name="Datos_Loged"
layout="block">
<h:form id="SystemUserForm">
<ui:include
src="/system/manage_user/content/edit_user/system_user_data/system_user.xhtml">
<ui:param name="manager" value="#{navegableUserData}" />
</ui:include>
</h:form>
</p:outputPanel>
</ui:define>
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我将我的页面嵌套到一个通用模板中,看起来像这样:
<?xml version='1.0' encoding='UTF-8' ?>
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui">
<h:head>
<meta http-equiv="Pragma" CONTENT="no-cache"></meta>
<meta http-equiv="cache-control" content="no-cache"></meta>
<meta http-equiv="Expires" CONTENT="-1"></meta>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-15" />
<h:outputStylesheet library="css" name="prime_styles.css" />
<h:outputScript library="js" name="prime_translations.js" />
</h:head>
<h:body>
<ui:insert name="metadata" />
<o:importConstants
type="com.company.system.view.beans.NavigationResults" />
<!-- More stuff -->
Run Code Online (Sandbox Code Playgroud)
当我发出诸如Primefaces表过滤之类的ajax请求时出现问题.虽然我的辅助bean没有再次创建,但是再次<f:event type="preRenderView" listener="#{navegableUserData.initialize}" />被调用.
我正在基于视图参数进行数据加载,并且需要该方法仅在第一次呈现页面时执行.我一直非常小心地使用<c:xxx>标签,并认为这不是问题,因为我只在一般模板中使用它们,我的视图bean属性没有附加到它们.我的所有页面都有这个问题,所以我认为这不是特定支持bean的问题.
Joh*_*shy 11
如果仅在ajax请求期间发生这种情况,请尝试以下操作:
public void initialize() {
if (!FacesContext.getCurrentInstance().isPostback()) {
// -----------
// -----------
}
}
Run Code Online (Sandbox Code Playgroud)
相关的BalusC建议:
| 归档时间: |
|
| 查看次数: |
5044 次 |
| 最近记录: |