在渲染/更新属性中获取模板中父命名容器的ID [英] Get id of parent naming container in template for in render / update attribute

查看:67
本文介绍了在渲染/更新属性中获取模板中父命名容器的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个模板,在其定义中,我使用了几种形式和按钮.

I have a template and in its Definition I use several forms and buttons.

问题是定义(定义)xhtml文件不知道组件层次结构.

The problem is the definition (define) xhtml file does not know the component hierarchy.

例如,我想在同一定义文件中以不同的形式更新元素"table2".

And for example I want to update the element "table2" in a different form in the same define file.

模板插入:

<p:tabView id="nav"> <!-- nav -->
    <ui:insert name="content_nav">content navigation</ui:insert>
</p:tabView>

定义层次结构导航"的第一级

defines the first level of my hierarchy "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>

在我定义的部分中,我不想知道导航"!

In my define part I don't want to know "nav"!

我该怎么做?或如何向上移动一个命名组件?或将最高父级完整ID保存在变量中?

How can I do this? or how can I move one naming component upwards?, or save the highest parent complete id in a variable?

有时候我看到类似的东西:

sometimes i saw something like:

update=":table2"

但是我找不到有关此的任何信息吗?JavaEE 6文档只提到了@关键字.

But I could not find any informations about this?, the JavaEE 6 documentation just mentions the @ keywords.

推荐答案

丑陋,但这应该可以为您解决:

Ugly, but this should work out for you:

<p:commandButton action="..." update=":#{component.namingContainer.parent.namingContainer.clientId}:form2:table2" />

当您已经在使用PrimeFaces时,一种替代方法是使用#{p:component(componentId)},此帮助程序功能将扫描整个视图根目录以查找具有给定ID的组件,然后返回其客户端ID:

As you're already using PrimeFaces, an alternative is to use #{p:component(componentId)}, this helper function scans the entire view root for a component with the given ID and then returns its client ID:

<p:commandButton action="..." update=":#{p:component('table2')}" />

这篇关于在渲染/更新属性中获取模板中父命名容器的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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