ListShuttle validation and invokeOnComponent
gjeudy Feb 26, 2009 4:48 PMHi,
I'm using Richfaces 3.2.1.GA.
I'm trying to retrieve submitted values for items in a listShuttle from a JSF validator. I plugged a validator on the rich:listShuttle element. validate() gets called twice: once passing a list of source items, another time passing a list of target items. These items don't hold submitted values as you could have in inputText fields.
In order to retrieve submitted values from the JSF UI tree I am trying the approach UIComponent.invokeOnComponent() that works fine on a rich:dataTable by the way. More details can be read there:
http://weblogs.java.net/blog/jhook/archive/2006/02/new_feature_for.html
Stepping through the code with a rich:listShuttle usecase gives no luck. At first glance it seems like the problem is the lack of rowKeyConverter for a listShuttle. Debugging rich:dataTable reveals that an IntegerConverter is used to convert the rowKey. Does this mean I should implement a rowKeyConverter for org.richfaces.model.ListShuttleRowKey ? If that is the case what should be the logic contained in the converter?
Here are some code excerpts of UIDataAdaptor.invokeOnComponent() to put you into context.
int indexOfSecondColon = clientId.indexOf(NamingContainer.SEPARATOR_CHAR, baseId.length()); String rowKeyString = null; if (indexOfSecondColon > 0) { rowKeyString = clientId.substring(baseId.length(), indexOfSecondColon); Converter keyConverter = getRowKeyConverter(); if (null != keyConverter) { try { newRowKey = keyConverter.getAsObject(context, this, rowKeyString); } catch (ConverterException e) { // TODO: log error } } } if( null != oldRowKey || null != newRowKey){ captureOrigValue(context); setRowKey(newRowKey); } Iterator<UIComponent> itr = this.getFacetsAndChildren(); while (itr.hasNext() && !found) { found = itr.next().invokeOnComponent(context, clientId, callback); } if( null != oldRowKey || null != newRowKey){ setRowKey(oldRowKey); restoreOrigValue(context); }
getRowConverter() always returns null therefore newRowKey is never set and I guess that is the reason why found variable never resolves to true even though the clientId is valid and refers to column in one of the listShuttle rows.
Forgive the bad indentation, I pasted from EclipseIDE and thats what it gave...
Any insights appreciated,
-Guillaume