我正在使用Primefaces和JSF来开发此前端。我的问题是,我的一个selectonemenus从来没有设置它的值绑定,“selectedGroup”,所以第二个下拉列表从不填充。我的支持bean被调用来“更新”第二个selectonemenu,但是这个ajax的监听器没有被调用,也没有设置selectedGroup。该代码实际上与"Select"的Showcase相同。我甚至证实了展示代码从头开始工作(我没有怀疑),但没有看到我的情况与这个例子有什么不同。Primefaces/JSF:selectOneMenu值未设置,ajax侦听器未调用
有关此主题的其他计算器问题表明某些内容已被排除,但这些建议都不符合我的问题。
我有两个selectOneMenus,就像这样。
<h:form id="outerForm">
<p:panel id="outerPanel">
<p:panelGrid id="outerPanelGrid">
<h:outputLabel for="groupSelection" value="Group: "/>
<p:selectOneMenu id="groupSelection" value="#{myBean.selectedGroup}" >
<p:ajax update="commandSelection"
listener="#{myBean.handleGroupSelection}" />
<f:selectItem itemLabel="---Please Select Group---" itemValue=""/>
<f:selectItems var="group" value="#{myBean.groups}"
itemLabel="#{group.name}" itemValue="#{group.name}" />
</p:selectOneMenu>
<h:outputLabel for="commandSelection" value="Command: "/>
<p:selectOneMenu id="commandSelection" value="#{myBean.command}">
<f:selectItems value="#{myBean.commandStringsList}"/>
</p:selectOneMenu>
</p:panelGrid>
</p:panel>
</h:form>
此页面所显示的一样,所以我的布局模板的“中心”部分..
<ui:define id="content" name="content">
<p:panel id="contentPanel" style="float:left; border:none">
<ui:include src="#{anotherBean.currentView}.xhtml"/>
</p:panel>
</ui:define>
的支持bean确实使用了一些数据类包含一些其中填充数据,但我认为我正在尽一切努力将其映射到视图中。不过,大多数情况下,我使用的是字符串。
有没有人看到我失踪?至少,这个xhtml是否有效?
我还应该提到,在创建和使用模板之前,此页面正在工作。基本上,我使用ui:include在index.xhtml的主体中将其呈现在TabView的选项卡中。虽然我最初没有注意到,但是在我加入模板之后的某个时候,这个页面停止了工作(我知道我的测试很差)。
只是为了澄清:你的表单ID是outerForm。你还没有嵌套形式,对吧? – 757071
正确,ui:define存在于ui:composition中,并且模板布局也不包含任何表单。 – ThatsAMorais
通过http://stackoverflow.com/a/2120183/757071和http://stackoverflow.com/a/16125396/757071,答案中的要点可能会有所帮助。 – 757071