如何从命令按钮在另一页更新Primefaces部件在一个页面时两页被包括在一个页 [英] How to update Primefaces component in one page from command button in another page when both pages are included in one page

查看:226
本文介绍了如何从命令按钮在另一页更新Primefaces部件在一个页面时两页被包括在一个页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2页

input.xhtml

<h:form>
    <p:panelGrid>
        <p:row>
            <p:column>
                <h:outputText value="Name : "/>
            </p:column>
            <p:column>
                <p:inputText id="name" value="#{inputBean.name}"/>
            </p:column>
        </p:row>
        <p:row>
            <p:column colspan="2" >
                <p:commandButton action="#{inputBean.buttonAction}" value="Submit"/>
            </p:column>
        </p:row>
    </p:panelGrid>
</h:form>

display.xhtml

<h:form id="form1">
    <h:outputText value="#{inputBean.name}" id="dis123"/>
</h:form>

如果我象下面这样一个页面包括他们的

If I include both of them in a single page like below

的index.xhtml

<p:accordionPanel widgetVar="main" multiple="true">
    <p:tab title="Input">
        <ui:include src="input.xhtml"/>
    </p:tab>

    <p:tab title="Output">
        <ui:include src="display.xhtml"/>
    </p:tab>
</p:accordionPanel>

我可以叫更新=dis123 input.xhtml

推荐答案

没有,你不能。像相对客户端ID 更新=dis123基本搜索在同一 NamingContainer 父组件是在你的情况下, &LT; H:形式GT; 的第一页。但是,没有这样的组分存在。它实际上是在不同的 NamingContainer 父。您需要提供一个绝对的客户端ID来代替:更新=:窗口1:dis123

No, you can't. A relative client ID like update="dis123" basically searches in the same NamingContainer parent component which is in your case the <h:form> of the first page. However, no such component exist. It's actually in a different NamingContainer parent. You need to provide an absolute client ID instead: update=":form1:dis123".

对于初学者来说,一个简单的方法来计算正确的绝对客户端ID是通过看在JSF生成的HTML输出(单击鼠标右键,查看源文件的浏览器),用于在生成的HTML元素的ID所需的组件,然后preFIX用

For starters, an easy way to figure the right absolute client ID is by just looking in the JSF-generated HTML output (rightclick, View Source in browser) for the generated HTML element ID of the desired component and then prefix it with :.

请注意,这一切都无关,包括。具有在单一页面中的所有code时,你就必须有完全相同的问题。

Please note that this all has nothing to do with includes. You'd have had exactly the same problem when having all the code in a single page.

  • <一个href="http://stackoverflow.com/questions/8634156/how-to-reference-components-in-jsf-ajax-cannot-find-component-with-identifier/8644762#8644762">How引用组件的JSF AJAX?无法找到标识符QUOT组成部分;富&QUOT;鉴于

这篇关于如何从命令按钮在另一页更新Primefaces部件在一个页面时两页被包括在一个页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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