在显示之前初始化 h:selectOneMenu
我有一个访问页面,在其中检查有效用户,如果存在,则传递到下一页并
String[] options;
根据 typeOfUser 创建一个。因此,如果用户是 A 型,选项应该是:
String[] options = {"1","2","3"};
如果用户是 B 型,选项应该是:
String[] options = {"1","2"};
在任何其他情况下,选项应该是:
String[] options = {"1","2","3","4","5"};
在 xhtml 页面中如下:
<h:selectOneMenu id="option">
<f:selectItems value="#{Bean.options}>
</h:selectOneMenu>
我可以在 @PostConstruct 方法中实现这一点吗?或者有没有更好的地方。
谢谢 !
I have the access page where I check for a valid user, if it exists then pass to the next page and create a
String[] options;
based on the typeOfUser. So if user is type-A the options should be:
String[] options = {"1","2","3"};
if user is type-B, options should be:
String[] options = {"1","2"};
in any other case, options should be:
String[] options = {"1","2","3","4","5"};
and in the xhtml page is as follows:
<h:selectOneMenu id="option">
<f:selectItems value="#{Bean.options}>
</h:selectOneMenu>
can I achieve this in the @PostConstruct method? or is there a better place.
Thanks !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我做得对。在 @PostConstruct 方法中,我可以初始化选项变量并使用正确的选项填充 selectOneMenu。
I was doing it right. In the @PostConstruct method, I could initialize the options variable and populate the selectOneMenu with the correct options.