Primefaces dataTable ajax功能在包含在< ui:include标签/>中时会制动. [英] Primefaces dataTable ajax functionality brakes when included in a <ui:include tag/>

查看:118
本文介绍了Primefaces dataTable ajax功能在包含在< ui:include标签/>中时会制动.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我整天都在抱怨这个问题,我不确定该怎么办,我希望这个论坛中的人能为我提供帮助.

Hi I have been beating my head all day with this issue and I am not sure what to do about it and I am hoping someone in this forum can help me.

当我使用dataTable元素呈现独立页面时,所有Ajax功能都可以工作:排序,导航等.

When I render a standalone page with a dataTable element, all Ajax functionality works: Sorting, Navigation, etc.

但是当我通过"ui:include"标签将同一页的dataTable元素包含在另一页中时,该表将呈现,但所有Ajax功能都将丢失.

But when I include the same page with the dataTable element inside another page via the "ui:include" tag, the table renders but all Ajax functionality is lost.

这是我的"p:dataTable"页面的代码:

Here is the code for my "p:dataTable" page:

    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
        <p:dataTable id="dataTable"
                     var="alarm" 
                     value="#{alarmsBean.alarms}"
                     paginator="true" rows="10"
                     paginatorTemplate="{FirstPageLink} {PreviousPageLink} {NextPageLink} {LastPageLink}"
                     paginatorPosition="bottom">
            <f:facet name="header">
                Alarms
            </f:facet>
            <p:column id="deviceHeader" sortBy="#{alarm.device}">
                <f:facet name="header">
                    <h:outputText value="Device" />
                </f:facet>
                <h:outputText value="#{alarm.device}" />
            </p:column>
            <p:column sortBy="#{alarm.alarm}">
                <f:facet name="header">
                    <h:outputText value="Alarm" />
                </f:facet>
                <h:outputText value="#{alarm.alarm}" />
            </p:column>            
            <p:column sortBy="#{alarm.managedObject}">
                <f:facet name="header">
                    <h:outputText value="Managed Object" />
                </f:facet>
                <h:outputText value="#{alarm.managedObject}" />
            </p:column>            
            <p:column sortBy="#{alarm.alarmTime}">
                <f:facet name="header">
                    <h:outputText value="Alarm Time" />
                </f:facet>
                <h:outputText value="#{alarm.alarmTime}" />
            </p:column>            
            <p:column sortBy="#{alarm.severity}">
                <f:facet name="header">
                    <h:outputText value="Severity" />
                </f:facet>
                <h:outputText value="#{alarm.severity}" />
            </p:column>            
            <p:column sortBy="#{alarm.message}">
                <f:facet name="header">
                    <h:outputText value="Message" />
                </f:facet>
                <h:outputText value="#{alarm.message}" />
            </p:column>
        </p:dataTable>
    </ui:composition>

这是另一页中包含该页面的部分:

And here is the section of the other page that includes that page:

    <h:form id="mainF">
      <pe:layoutPane id="center" position="center">
          <h:panelGroup id="centerContent">
              <ui:include src="#{navigationBean.pageName}.xhtml" />
          </h:panelGroup>
      </pe:layoutPane>
    </h:form>

我在做什么错?这是PrimeFaces 3.3中的错误吗?

What am I doing wrong or is this a bug in PrimeFaces 3.3?

推荐答案

<ui:include src="#{navigationBean.pageName}.xhtml" />

您需要确保在处理(ajax)表单提交期间,#{navigationBean.pageName}返回的值与显示初始页面时的值完全相同.如果不是这种情况,那么JSF将无法找到(ajax)表单提交中涉及的输入和命令组件.

You need to make sure that #{navigationBean.pageName} returns exactly the same value during processing the (ajax) form submit as it was when the initial page was displayed. If this is not the case, then JSF won't be able to find the input and command components involved in the (ajax) form submit.

因此,如果该值取决于基于请求的参数/变量,那么您需要确保此请求参数/变量在表单提交期间保留并在Bean的(后期)构造期间可用.您可以通过在命令按钮中将其作为<f:param>传递并将其设置为@ManagedProperty来实现.请注意,由于<ui:include src>,将bean放置在视图作用域中将不起作用,因为作为视图构建时间标记将获得其自己的全新实例.您需要关闭部分状态保存或升级到JSF 2.2.

So if that value depends on a request based parameter/variable, then you need to make sure that this request parameter/variable is preserved across form submits and available during bean's (post)construction. You can achieve that by passing it as <f:param> in the command buttons and setting it as @ManagedProperty. Note that placing the bean in the view scope won't work as the <ui:include src> as being a view build time tag gets its own brand new instance. You would need to turn off the partial state saving or to upgrade to JSF 2.2.

这篇关于Primefaces dataTable ajax功能在包含在&lt; ui:include标签/&gt;中时会制动.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆