JSF 中的循环管理bean 检测错误
我必须访问页面 A 和 B,我想在 JSF 中从 A 导航到 B,然后从 B 导航到 A。我在 A 的托管 bean 中设置了托管属性 B,反之亦然,但问题是我收到了类似的错误 托管 Bean 循环检测。
<managed-bean>
<managed-bean-name>viewBulkMetalIssueBean</managed-bean-name>
<managed-bean-class>com.cc.jas.web.manufacturing.bulkmetalissue.ViewBulkMetalIssueBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>viewJobcardBean</property-name>
<property-class>com.cc.jas.web.manufacturing.jobcard.ViewJobcardBean</property-class>
<value>#{viewJobcardBean}</value>
</managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>viewJobcardBean</managed-bean-name>
<managed-bean-class>com.cc.jas.web.manufacturing.jobcard.ViewJobcardBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>viewBulkMetalIssueBean</property-name>
<property-class>com.cc.jas.web.manufacturing.bulkmetalissue.ViewBulkMetalIssueBean</property-class>
<value>#{viewBulkMetalIssueBean}</value>
</managed-property>
</managed-bean>
这个问题有任何解决方案或替代解决方案吗?
I have to pages A and B, I want to navigate from A to B and back from B to A in JSF. I set managed property B in managed bean of A and visa versa but problem is i got an error like
MANAGED BEAN CYCLIC DETECTION.
<managed-bean>
<managed-bean-name>viewBulkMetalIssueBean</managed-bean-name>
<managed-bean-class>com.cc.jas.web.manufacturing.bulkmetalissue.ViewBulkMetalIssueBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>viewJobcardBean</property-name>
<property-class>com.cc.jas.web.manufacturing.jobcard.ViewJobcardBean</property-class>
<value>#{viewJobcardBean}</value>
</managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>viewJobcardBean</managed-bean-name>
<managed-bean-class>com.cc.jas.web.manufacturing.jobcard.ViewJobcardBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>viewBulkMetalIssueBean</property-name>
<property-class>com.cc.jas.web.manufacturing.bulkmetalissue.ViewBulkMetalIssueBean</property-class>
<value>#{viewBulkMetalIssueBean}</value>
</managed-property>
</managed-bean>
Is there any solution or alternate solution for this problem ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这确实是不可能的。如果没有这种检测,只会导致托管属性设置的无限循环。
为了解决这个问题,只需让“父”bean 在注入后将其自身设置在“子”bean 中即可。
和
That's indeed not possible. Without this detection, it would only lead to an infinite loop of managed property setting.
To go around this, just let the "parent" bean set itself in the "child" bean when it has been injected.
With
您不能在 JSF 托管 Bean 中进行循环注入。 MyFaces wiki 对此进行了很好的解释。
另一种解决方案是使用 EL 解析器(对于 JSF 1.2)从托管 bean 中的 java 代码查找引用:
请参阅 MyFaces wiki 条目 以获得进一步的解释,以及其他 JSF 版本的实现。
You can't have cyclic injections in your JSF managed beans. This is explained nicely in the MyFaces wiki.
An alternate solution is to look up the reference from java code within your managed bean using an EL resolver (for JSF 1.2):
See the MyFaces wiki entry for further explanation, and implementations for other JSF versions.