JSF ui:repeat 标签内子类的条件渲染
以类似于此处的方式,我正在使用抽象用于键入项目集列表的类 ui:repeat。具体子类重写 getType() 方法,该方法用于 有条件地渲染相应的子类型及其特定属性:
<!-- AbstractAction Rule#getActions() -->
<ui:repeat value="#{rule.actions}" var="action">
<!-- render when "action" instance of NotificationAction -->
<h:panelGroup rendered="#{action.type == 'notification'}">
... UI for NotificationAction properties
<h:panelGroup rendered="#{action.type == 'callback'}">
...
在 Glassfish 3 上运行时,出现有关属性未在列表中定义的错误 其他子类的成员 (PropertyNotFoundException),发生在以下分支中: 实际上是由 rendered 属性关闭的。 c:forEach/c:choose 似乎没有 合适的。任何想法如何使渲染真正有条件并绕过 高度赞赏财产检查!
谢谢。 哈罗
in a way similar to here I am using an abstract class to type the item set list
of ui:repeat. Concrete subclasses override the getType() method, that is used to
conditionally render the respective subtype with its particular properties:
<!-- AbstractAction Rule#getActions() -->
<ui:repeat value="#{rule.actions}" var="action">
<!-- render when "action" instance of NotificationAction -->
<h:panelGroup rendered="#{action.type == 'notification'}">
... UI for NotificationAction properties
<h:panelGroup rendered="#{action.type == 'callback'}">
...
When run on Glassfish 3 there is an error about properties not being defined on list
members of other subclasses (PropertyNotFoundException), which occurs in a branch that
is actually switched off by the rendered property. c:forEach/c:choose do not seem
appropriate. Any ideas how to make the rendering really conditional and bypass the
property checking are highly appreciated!
Thank you.
Jaro
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一些测试后发现,ui:repeat 组件本身导致了错误。
尽管处于最后的 RenderResponse 阶段,但它仍尝试保存其子输入组件的状态。这里是一个缩短的异常转储:
这里 rendered 条件被忽略,并且 EL 解释器抱怨不存在的属性。有一个简单的解决方案,即使用带有单列的 h:dataTable 迭代器:
干杯。
哈罗
after some testing it turned out, that the ui:repeat component itself caused the error.
Despite being in the final RenderResponse phase it tries to save the status of its child input components. Here a shortened exception dump:
Hereby the rendered condition is ignored and the EL interpreter complains about non-existent properties. There is a simple solution by using the h:dataTable iterator with a single column instead:
Cheers.
Jaro