I have an <h:selectOneListbox>
populated with an <s:selectItems>
, which is just attached to a list property on my Seam object. Here's my (simplified) JSF code:
<a4j:outputPanel ajaxRendered="true" id="valuesListPanel">
<table border="0" cellspacing="5">
<tr><td rowspan="5">
<h:selectOneListbox id="pickValue" value="#{seamObject.selectedValue}">
<s:selectItems value="#{seamObject.propertyValues}" var="properties" label="#{properties}" />
</h:selectOneListbox>
</td>
<td><a4j:commandButton value="Move Up"
action="#{seamObject.moveUp}"/></td></tr>
<tr><td><a4j:commandButton value="Move Down" action="#{seamObject.moveDown}"/></td></tr>
</table>
</a4j:outputPanel>
The moveUp and moveDown methods in the Seam object find the selected item in the backi开发者_运维技巧ng list, and move it up, or down.
Here's the problem I'm having: When I click one of these buttons, the AJAX request goes through, and the backing object does change. However, the list doesn't update. The second time I click one of these buttons, however, the previous change is reflected in the list box.
So, if I "move down" one item, no change is visible. However, if I "move up" another item, nothing happens to that one, but the item I previously wanted to move down, moves down.
Hacking this by forcing another AJAX request "works," with the exception that the second request wipes out any FacesMessages that are supposed to be showing.
How can I get this to work? Is there a better way to approach the problem?
Is there a particular reason you are not using the rich:orderingList
? Ordering a list is exactly what it is intended for.
If you can't do that, what does a4j:log
say? Is the panel rerendered? If yes, with what data?
I ended up putting immediate="true" on both a4j:commandButtons. This, combined with putting an AJAX call on the onchange event for the listbox (so that the server knows what the selected item is), gave me the desired behavior. It's not pretty, but it works, and I can't afford to spend a whole lot more time on it.
精彩评论