Java 如何在 jsf 呈现的属性中指定来自 2 个不同 bean 的条件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1004382/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I specify conditions from 2 different beans in a jsf rendered attribute?
提问by rojoca
I want to do something along the lines of the following but when I use it like this I get a parse error telling me an entity needs to directly follow the '&' character:
我想按照以下方式做一些事情,但是当我像这样使用它时,我收到一个解析错误,告诉我一个实体需要直接跟随“&”字符:
<ice:selectManyCheckbox
rendered="#{!bean1.condition1 && bean2.condition2}"
value="#{bean1.selected}">
<f:selectItems value="#{bean2.items}" />
</ice:selectManyCheckbox>
How can I get rendered to check conditions from 2 different beans?
如何渲染以检查来自 2 个不同 bean 的条件?
采纳答案by karim79
Use 'and' instead:
改用“和”:
<ice:selectManyCheckbox rendered="#{!bean1.condition1 and bean2.condition2}" value="#{bean1.selected}">
回答by Romain Linsolas
回答by snehasish
Maybe you are using facelets which assumes every jsp page after compilation is a xml file. And you know in an xml file you have to provide an xml entity name just after the &
symbol. So to escape this situation use &
in place of &
.
也许您正在使用 facelets,它假定编译后的每个 jsp 页面都是一个 xml 文件。您知道在 xml 文件中,您必须在&
符号后提供一个 xml 实体名称。因此,要摆脱这种局面的使用&
代替&
。