Potential bug in selectOneMenu reRendering
callatis Jan 20, 2011 7:08 PMI have the following code:
{code}
<h:panelGrid columns="2" columnClasses="col1,col2">
<rich:panel id="treePanelId">
<rich:tree style="width:100%; height: 100%;"
ajaxSubmitSelection="true" ajaxSingle="true"
switchType="client"
var="item"
nodeFace="#{item.type}"
value="#{myBean.treeNode}"
ajaxKeys="#{null}">
<rich:treeNode type="xxx"
nodeSelectListener="#{myBean.processTreeSelection}" reRender="detailsPanelId" >
<h:outputText value="#{item.value}"/>
</rich:treeNode>
<rich:treeNode type="yyy">
<h:outputText value='#{item.type}=#{item.value}' nodeSelectListener="#{null}"/>
</rich:treeNode>
<rich:treeNode>
<h:outputText value='WTF! #{item.type}=#{item.value}' nodeSelectListener="#{null}"/>
</rich:treeNode>
</rich:tree>
</rich:panel>
<rich:panel id="detailsPanelId">
<rich:panel header="Samples" id="selectPanelId">
<a4j:region>
<h:selectOneMenu label="Select Item" id="selectFieldId" value="#{myBean.selectedItemId}"
valueChangeListener="#{myBean.changeSelection}">
<f:selectItems value="${myBean.selectItems}"/>
<a4j:support event="onchange" reRender="requestPanelId"/>
</h:selectOneMenu>
</a4j:region>
<a4j:outputPanel layout="none" id="requestPanelId">
<h:inputTextarea label="Sample Request" id="sampleFieldId" value="#{myBean.myRequest}"
rows="8" cols="80"/>
</a4j:outputPanel>
</rich:panel>
</rich:panel>
</h:panelGrid>
{code}
As I keep clicking the tree, the backing bean resets selectedItemId to empty string "". The 'myBean.selectItems' property includes an entry with "-- New --" as the display and "" as the value. My backing bean is request-scoped, with an a4j:keepAlive defined earlier in the page.
Since a tree selection sets the value of the SELECT back to "", I would expect to see the drop-down repositioned to an empty string. Unfortunately though, this only happens if I select something from the drop-down after repositioning in the tree. In other words, the following sequence works:
- click tree node TN1
- change drop-down selection to non-empty "A1"
- click tree node TN2
- change drop-down selection to non-empty "B1"
- click back TN1
- Expected: empty ("-- New --") ; actual: -- New -- (CORRECT)
The following scenario fails, though:
- click tree node TN1
- change drop-down selection to non-empty A1
- click tree node TN2
- skip step: change drop-down selection to non-empty "B1"
- click back TN1
- Expected: empty ("-- New --") ; actual: A1 (INcorrect)
I'm using RichFaces 3.3.Final with JSF 2.0.2 (in backwards-compatible mode as RichFaces requires).
-
RichFaces_Bug_POM.xml 2.7 KB