djm*_*jmj 17 el naming-containers primefaces jsf-2
我有一个模板,在其定义中我使用了几个表单和按钮.
问题是定义(定义)xhtml文件不知道组件层次结构.
例如,我想在同一个定义文件中以不同的形式更新元素"table2".
模板插入:
<p:tabView id="nav"> <!-- nav -->
<ui:insert name="content_nav">content navigation</ui:insert>
</p:tabView>
Run Code Online (Sandbox Code Playgroud)
定义我的层次结构"nav"的第一级
模板定义:
<ui:define name="content_nav">
<h:form id="form1"> <!-- nav:form1 -->
<h:dataTable id="table1"/> <!-- nav:form1:table1 -->
<p:inputText value="#{bean.value}"/>
<p:commandButton action="..." update="nav:form2:table2"/>
</h:form>
<h:form id="form2">
<h:dataTable id="table2"/> <!-- nav:form2:table2 -->
<!-- other elements -->
</h:form>
</ui:define>
Run Code Online (Sandbox Code Playgroud)
在我的定义部分,我不想知道"导航"!
我怎样才能做到这一点?或者如何向上移动一个命名组件?或者将最高父完整ID保存在变量中?
有时我看到类似的东西:
update=":table2"
Run Code Online (Sandbox Code Playgroud)
但是我找不到任何关于这个的信息?,JavaEE 6文档只是提到@关键字.
Bal*_*usC 49
丑陋,但这应该适合你:
<p:commandButton action="..." update=":#{component.namingContainer.parent.namingContainer.clientId}:form2:table2" />
Run Code Online (Sandbox Code Playgroud)
由于您已经在使用PrimeFaces,另一种方法是使用#{p:component(componentId)}
,此帮助程序函数扫描整个视图根目录以查找具有给定ID的组件,然后返回其客户端ID:
<p:commandButton action="..." update=":#{p:component('table2')}" />
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
27540 次 |
最近记录: |