下面的代码是从PrimeFaces的DataGrid + DataTable的教程启发和放入<p:tab>一个的<p:tabView>居住在<p:layoutUnit>的<p:layout>.这是代码的内部部分(从p:tab组件开始); 外部是微不足道的.
<p:tabView id="tabs">
<p:tab id="search" title="Search">
<h:form id="insTable">
<p:dataTable id="table" var="lndInstrument" value="#{instrumentBean.instruments}">
<p:column>
<p:commandLink id="select" update="insTable:display" oncomplete="dlg.show()">
<f:setPropertyActionListener value="#{lndInstrument}"
target="#{instrumentBean.selectedInstrument}" />
<h:outputText value="#{lndInstrument.name}" />
</p:commandLink>
</p:column>
</p:dataTable>
<p:dialog id="dlg" modal="true" widgetVar="dlg">
<h:panelGrid id="display">
<h:outputText value="Name:" />
<h:outputText value="#{instrumentBean.selectedInstrument.name}" />
</h:panelGrid>
</p:dialog>
</h:form>
</p:tab>
</p:tabView>
Run Code Online (Sandbox Code Playgroud)
当我单击时<p:commandLink>,代码停止工作并给出消息:
找不到表达式为"insTable:display"的组件,引用自"tabs:insTable:select".
当我尝试相同的使用时<f:ajax>,它失败了,基本上告诉相同的不同消息:
<f:ajax>包含一个未知的id"insTable:display"无法在组件"tabs:insTable:select"的上下文中找到它
这是怎么造成的,我该如何解决?
我想创建一个可以与其他人迭代的复合组件。问题是复合组件是一个命名容器,并且一个简单的 selectOnMenu 更改和刷新其他 selectOnMenu 是不可能的,因为给 selectOnMenu 的“id”是combo1:combo并且看不到的combo2:combo。
最好的情况是form1:combo1and form1:combo2,然后,combo1 和 combo2 使用 uinamingcontainer of h:form。此链接讨论了这一点,但没有解决方案。
https://cwiki.apache.org/MYFACES/create-a-non-namingcontainer-composite-component.html
另一个尝试但不起作用。p:commandbutton在 CC 中看不到 div 的 id。
获取 JSF2 复合组件的父级的 clientId
<p:commandButton value="asd" partialSubmit="true" process="@this" update="fooId"/>
<cf:label id="fooId" title="xxxxx" />[index.xhtml]
<composite:interface componentType="RootComponent" preferred="false">
<composite:attribute name="title" />
</composite:interface>
<composite:implementation>
<div id="#{cc.immediateParent.clientId}:#{cc.id}">
#{currentDate}
<h:panelGroup id="#{cc.clientId}" layout="block">
<p:outputLabel id="#{cc.clientId}_lb" value="#{cc.attrs.title}">
<composite:insertChildren />
</p:outputLabel>
</h:panelGroup>
</div>
</composite:implementation>[label.xhtml](compositecomponent)
Run Code Online (Sandbox Code Playgroud)