teh*_*kio 2 composite-component jsf-2
我想创建一个可以与其他人迭代的复合组件。问题是复合组件是一个命名容器,并且一个简单的 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)
复合组件真的需要命名容器接口吗?
是的。否则,在同一个父命名容器中使用多个组件时,最终会出现来自复合组件实现的“重复组件 ID”错误。
如果您绝对不想要NamingContainer基于组件的组件,那么请创建一个标记文件。它只需要一些.taglib.xml样板。
另一个尝试但不起作用。
p:commandbutton在 CC 中看不到 div 的 id
您的复合实现无效。为了通过 ajax 正确引用复合,您需要一个纯 HTML<div>或<span>ID 正好为#{cc.clientId}.
例如
<composite:implementation>
<div id="#{cc.clientId}">
#{currentDate}
<h:panelGroup layout="block">
<p:outputLabel id="#{cc.clientId}_lb" value="#{cc.attrs.title}">
<composite:insertChildren />
</p:outputLabel>
</h:panelGroup>
</div>
</composite:implementation>
Run Code Online (Sandbox Code Playgroud)
(顺便说一下,我的印象是<h:panelGroup>是多余的,您可以放心地省略它;此外,id="#{cc.clientId}_lb"最好是id="label"或尽量减少重复/重复的东西)
| 归档时间: |
|
| 查看次数: |
2277 次 |
| 最近记录: |