JSF 复合组件 儿童
有没有什么方法可以使用 EL 检索子列表,以便我可以通过它进行迭代。
<ul>
<ui:repeat value="#{Magic El expression}" var="children" >
<li>
<p> #{children.title} *</p>
</li>
</ui:repeat>
</ul>
<div>
<cc:insertChildren />
</div>
* perhaps #{children.attrs.title} I don't know?
我在这里尝试做的是创建一个 Tab 复合组件。我知道诸如 primefaces 之类的库提供 tabview 等。但由于扩展了 jquery 功能,我需要创建自己的库。另外,我正在使用特定的模板。 我需要获取选项卡标题来创建选项卡列表。选项卡是子组件,我是否可以迭代并获取它们的属性?我的意思是 primefaces 以某种方式做到了这一点。
如果您查看他们的 html 标记,他们会创建一个无序列表,其中包含每个子选项卡视图组件的标题。这是如何实施的?
Is there any way using EL to retrieve a children list so i can iterate through it with
<ul>
<ui:repeat value="#{Magic El expression}" var="children" >
<li>
<p> #{children.title} *</p>
</li>
</ui:repeat>
</ul>
<div>
<cc:insertChildren />
</div>
* perhaps #{children.attrs.title} I don't know?
What I'm trying to do here is create a Tab composite component. I know libraries such as primefaces offer tabview etc. Yet I need to create my own because of extended jquery functionality. Plus I'm working with a specific template.
I need to get the tabs title to create a list for tabs. Tabs are children components is there anyway i can iterate and fetch their attributes? I mean primefaces does that somehow.
If you look at their html markup they create an unordered list with the titles of each children tabview component. How is that implemented?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您显示的标记位于复合组件内部(我猜是这样),那么以下表达式将允许您访问其子组件:
#{component.getCompositeComponentParent(component).children}
稍微相关的问题:在JSF2中,如何知道复合组件是否有子组件?
If the markup you show is inside a composite component (I guess it is), then the following is the expression that will give you access to its children:
#{component.getCompositeComponentParent(component).children}
Slightly related question: In JSF2, how to know if composite component has children?
如果您的复合组件是以下实例: javax. faces.component.UINamingContainer
试试这个:
您可以通过将 JSF 变量打印到页面(例如
#{cc}
或#{component}
)来轻松调试哪个实例是您的 JSF 变量干杯!
If you Composite Component is an instance of : javax.faces.component.UINamingContainer
Try this:
You can easily debug which instance are your JSF variables by printing them to the page like
#{cc}
or#{component}
Cheers!