导航到页面时如何首先初始化某个 MBean
我的页面分为 3 部分。第一部分是绑定到 mBean (MLeft) 的链接列表,第二部分是当前的 mBean (MCenter)我所在的页面。MCenter 将数据插入到 MLeft 中,以便第一部分中的链接是我当前所在页面的自定义链接。问题是,当呈现页面并评估链接时 MLeft 是在 MCenter 之前创建 (因为在页面的前面找到)并且 MCenter 没有机会在 MLeft 中插入链接,因此不会显示任何链接。我在链接之前使用引用 dummy
属性的输出文本调用 MCenter,该属性是一个空字符串
。
我不喜欢这种解决方法,我过去也曾使用 Seam 和 @Out
遇到过这个问题,我这样解决了它。有更好的方法吗?
I have a page split in 3. First part is a list of links which is bound to a mBean (MLeft), and the second is the current mBean (MCenter) of the page I'm in. MCenter inserts data into MLeft so that the links from the first part are custom to the page I'm currently in. The thing is that when the page is rendered and the links are evaluated MLeft is created before MCenter (because is found earlier in the page) and MCenter doesn't get the chance to insert the links in MLeft, so no links are displayed. I put a call to MCenter before the links using an output text referring a dummy
property which is an empty string
.
I don't like this workaround, I had this problem in the past too with Seam and @Out
and I solved it like this. Is there a better approach?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许您可以使用 follow 方法:
该方法将在页面加载时被调用
Maybe you can use follow method:
the method will be invoked when the page be loaded
我认为您需要使用模板:
template.xhtml
content1.xhtml
我假设 links 是一个列表或字符串数组,但您可以对其进行任何操作:自定义 MyLink 对象的列表,...(只要有一个合适的 getter)
您也可以将 middle.links 替换为您喜欢的任何内容,事件调用如 #{middle.getLinks(page1)}
I think you need to use templates:
template.xhtml
content1.xhtml
I'm assuming links is a list or an array of strings, but you could make anything of it: a list of custom MyLink object, ... (as long as there is an appropriate getter)
You could also replace middle.links with whatever you like, event a method call like #{middle.getLinks(page1)}
只需将
Center
设为Left
的托管属性即可。例如Just make
Center
a managed property ofLeft
. E.g.