我有3个丰富的:选择控件,其中有id select1,select2,select3.I要点击select1,将控制“select2”呈现,我点击控件select2,select3会呈现,像这样。我通过netbeans 7.0.1创建了我的应用程序,并使用框架jsf 2.0和richFaces 4.2.0。两个丰富:ajax冲突的问题(在3丰富:选择控件)
我的解决方案是创建两个ajj:ajax,它们分别具有id ajax1和ajax2,以便根据select1和select2 selectItem事件分配select2和select3基础的渲染。我将ajax1和ajax2安排在队列ID为queue1的队列中。
这里是页面的代码:遇到
<h:form>
<a4j:queue name="queue1" onerror="window.alert('alert in queue');" onrequestdequeue="window.alert('queue1 dequeue');" onrequestqueue="window.alert('queue1 enqueue');" requestDelay="1000" ignoreDupResponses="true"/>
<h3 style="text-align: center">Test case 1: 3 selection controls problem</h3>
<br/><br/>
<h:outputLink value="../index.xhtml">View Index </h:outputLink>
<br/><br/>
Problem: <h:outputText escape="false" value="#{carBean.testDescription}"/>
<br/><br/>
<table>
<tr>
<td>Car Firm (selection1)</td>
<td>Car type (selection2)</td>
<td>Production (selection3)</td>
</tr>
<tr>
<td>
<rich:select id="select1" value="#{carBean.companyName}" maxListHeight="100" enableManualInput="true" defaultLabel="Type here">
<a4j:ajax id="ajax1" queueId="queue1" execute="@form" render="select2, errorText" event="selectitem" listener="#{carBean.changeCompanyEvent()}">
</a4j:ajax>
<f:selectItems value="#{carBean.lstCompany}"></f:selectItems>
</rich:select>
</td>
<td>
<rich:select id="select2" value="#{carBean.typeName}" maxListHeight="100" enableManualInput="true" defaultLabel="Type here" >
<a4j:ajax id="ajax2" queueId="queue1" immediate="true" execute="@form" render="select3, errorText" event="selectitem" listener="#{carBean.changeCarTypeEvent()}">
</a4j:ajax>
<f:selectItems value="#{carBean.lstCarType}"></f:selectItems>
</rich:select>
</td>
<td>
<rich:select id="select3" value="#{carBean.productionName}"
maxListHeight="100" enableManualInput="true" defaultLabel="Type here" >
<f:selectItems value="#{carBean.lstCarProduction}"></f:selectItems>
</rich:select>
</td>
</tr>
</table>
<br/><br/>
<h:outputText id="errorText" escape="false" value="#{carBean.alertError}"/>
</h:form>
问题:我有还是没有找到原因,但2个问题:
- 的选择2必须设置immediate = true,否则在ajax2中定义的事件将不会完成。
我不知道是什么原因造成的。
- 当我为select2设置immediate = true时,调用了ajax2事件。但是,被分配为select2控件的值的typeName变量仍未选定,因此select3尚未分配一个值。
以下是错误图片:http://i970.photobucket.com/albums/ae190/swenteiger7/richFaces%20error-%20110312/testcase1Error.png
应用:我也把我的应用程序项目(由净豆IDE中打开)这个问题相处。您可以集中3个项目: - Web/Web-INF文件夹中的faces-config.xml文件,它定义了CarBean管理的Bean - web文件夹中的testcase1文件夹(具有threeSelectExample.xhtml)。 - 用于保存托管bean的beans包和utils包(我们在CarBean托管Bean中隐藏的testcase1中)。
您可以在我的附件文件中下载我的归档项目。请加JSF2.0和RichFaces的框架来运行应用程序(https://community.jboss.org/wiki/HowToAddRichFaces4xToProjectsNotBasedOnMaven)
这里是我的应用程序:http://www.mediafire.com/?fnab3824b8vwd93
如果你有一些问题,下载,请联系我。谢谢。
非常感谢你的惊人答案。我会检查它:) – 2012-03-22 20:33:22
你好Luiggi。我在3天前尝试了您的建议。我仍然不能使用2 ajax事件。当我使用2 时,出现这个问题,不幸的是,在
2012-03-28 19:29:27