[英]JSF listeners in selectOneMenu
I have a selectOneMenu item with some products. 我有一些产品的selectOneMenu项目。 Some of them are unavailable so after you click on it the button "Add" should be disabled and some message should appear that "Sorry the product you chose is currently unavailable".
其中一些不可用,因此单击它后,应禁用“添加”按钮,并应显示一些消息,“抱歉,您选择的产品当前不可用”。 I have no idea how to achieve that.
我不知道如何实现这一目标。 Tried listeners, ajax and still nothing.
试听者,ajax仍然没有。
This is one of many versions of my JSF Page: 这是我的JSF页面的许多版本之一:
<h:form>
<h:selectOneMenu value="#{productBean.productName}">
<f:selectItems id ="other" value="#{productBean.other}" var="other" itemValue="#{ordersBean.productName}" itemLabel="#{other.name}" />
<f:ajax listener="#{productBean.valueChanged}" />
</h:selectOneMenu>
<h:commandButton value ="Dodaj do zamówienia" rendered="#{productBean.available}"/>
<h:outputLabel id="orderSummary"/>
</h:form>
Beans are rather standard. 豆是相当标准的。 I just need a clue how to do that and probably I will be able to do it myself.
我只需要一个提示如何做到这一点,也许我自己就能做到。
Thanks in advance. 提前致谢。
Here's one of the ways: 这是方法之一:
#{bean.available ? '' : 'Sorry, out of stock'}
#{bean.available ? '' : 'Sorry, out of stock'}
#{bean.available ? '' : 'Sorry, out of stock'}
value, or enclose it within a <h:panelGroup>
and let that component have a rendered
attribute, or attach <h:message>
/ <h:messages>
somewhere in your view. #{bean.available ? '' : 'Sorry, out of stock'}
值,或将其包含在<h:panelGroup>
并让该组件具有rendered
属性,或在视图中的某个位置附加<h:message>
/ <h:messages>
。 render
attribute of <f:ajax>
tag. <f:ajax>
标记的render
属性中指定要呈现的消息持有者的ID。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.