同时调用多个支持 bean 方法
有没有办法从 JSF 中的不同支持 bean 调用多个方法?
我有一个存储用户信息的应用程序。我有多个支持 bean,它们被分解为时间表、地址、电话等。
当应用程序最初加载时,所有内容都可以找到,但由于我所有的视图都是 @ViewScope
类型的时间表列表,即使显示新用户,地址、电话也会保留。
当用户离开当前正在查看 IE 的用户时,我需要手动将日程表、地址和电话列表设置为 null 我需要在某个时间点调用每个托管 bean 中的方法(当用户单击命令链接)。
是否可以在一个 commandLink 上调用多个 bean 方法?
Is there a way to call multiple methods from different backing beans in JSF?
I have an application that stores user information. I have multiple backing beans which are broken down into schedule, address, phone.. etc.
When the application initially loads everything works find but since all of my views are of type @ViewScope
the lists of schedule, address, phone are maintained even if a new user is displayed.
I need to manually set the schedule, address, and phone lists to null when the user navigates away from the current person they are viewing IE I need to call a method in each managed bean at one point in time (When the user clicks on a commandLink).
Is it possible to call multiple bean methods on one commandLink?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用上面的代码,bean 中的方法具有
actionListener(ActionEvent event)
的(“默认”)签名,当您首先单击 commandLink 时,将执行 Submit 方法。之后所有其他的actionListener将被一一执行...希望有帮助;)
Using the above code, with methods in the beans have the ('default') signature of
actionListener(ActionEvent event)
when you click the commandLink first the submit method will be executed. After that all the other actionListeners will be executed one by one...Hope that helps ;)
您可以让您的 commandLink 引用一种方法,该方法本身会调用所有必要的方法。
You can have your commandLink reference one method which itself calls all the necessary methods.
这里的答案接近为我工作,但还必须在 f:actionListener 中的方法中添加括号:
The answers here were close to working for me but also had to add parenthesis to the methods in the f:actionListener: