JSF 2.0如何显示不同的H:一个项目从一个selectOneMenu用于选定panelGroup中每次 [英] JSF 2.0 How to display a different h:panelGroup each time an item is selected from a selectOneMenu
本文介绍了JSF 2.0如何显示不同的H:一个项目从一个selectOneMenu用于选定panelGroup中每次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个selectOneMenu用于显示一些不同的东西的类别:
I have a selectOneMenu that displays some different stuff categories:
<h:selectOneMenu value="#{searchController.selectedCategory}">
<f:selectItems value="#{searchController.formatedCategories()}" >
</f:selectItems>
</h:selectOneMenu>
我需要显示一个不同panelGroup中根据所选择的类别。 实施例(这其中需要显示,当第一项被选中)
I need to display a different panelGroup depending on the selected category. Example(This one needs to be displayed, when the first item is selected)
<h:panelGroup id="carInfo">
<h:outputText value="marka" />
<h:selectOneMenu>
<f:selectItems value="#{searchController.formatedCarMarks()}" />
</h:selectOneMenu>
<h:outputText value="godina" />
<h:selectOneMenu>
<f:selectItems value="#{searchController.formatedYearFrom()}" />
</h:selectOneMenu>
<h:selectOneMenu>
<f:selectItems value="#{searchController.formatedYearTo()}" />
</h:selectOneMenu>
<h:outputText value="kms.:" />
<h:selectOneMenu>
<f:selectItems value="#{searchController.kmsFrom()}" />
</h:selectOneMenu>
<h:selectOneMenu>
<f:selectItems value="#{searchController.kmsTo()}" />
</h:selectOneMenu>
</h:panelGroup>
我不知道如何做到这一点,因为我需要与出刷新页面做到这一点。 有任何想法吗?阿贾克斯能帮助我吗?如果是的话能有人告诉我怎么请?我不熟悉的。
I dont know how to do this, because i need to do it with out refreshing the page. Any ideas? Can Ajax help me here? If so could somebody tell me how please? I am not familiar with at all.
推荐答案
这可以很容易地通过AJAX完成的:
This could be done easily via ajax:
- 把
&LT; H:panelGroup中&GT;
外&LT内部因素; H:panelGroup中&GT;
李> - 在巢的
&LT; F:AJAX&GT;
在&LT; H:selectOneMenu用于&GT;
放的id外&LT; H:panelGroup中&GT;
在渲染
属性 - 给每个内
&LT; H:panelGroup中&GT;
元素的渲染
属性计算结果为真实的,只有当相应的类别中选择。
- Put the
<h:panelGroup>
elements inside an outer<h:panelGroup>
- Nest an
<f:ajax>
inside the<h:selectOneMenu>
and put the id of the outer<h:panelGroup>
in itsrender
attribute. - Give each of the inner
<h:panelGroup>
elements arendered
attribute that evaluates to true only if the corresponding category is selected.
这篇关于JSF 2.0如何显示不同的H:一个项目从一个selectOneMenu用于选定panelGroup中每次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文