Howto : orderingList with inputText?
asterius May 5, 2008 10:19 AMHello!
I'm trying to set inputText in the orderingList, but I get a problem when sending it.
Maybe can you help me?
Here is my code :
<h:form id="domainForm"> <rich:orderingList value="#{DKVEditFace.currentKeyValueList}" var="keyValue"> <rich:column> <h:outputText value="#{keyValue.keyName}"/> </rich:column> <rich:column> <h:inputText value="#{keyValue.value}"/> </rich:column> </rich:orderingList> <p> <h:commandButton value="#{Bundle.button_save}" actionListener="#{DKVEditFace.saveKeyValues}" eventsQueue="default"/> </p> </h:form>
public class DKVEditFace{ private List<KeyValue> currentKeyValueList; public List<KeyValue> getCurrentKeyValueList() { return currentKeyValueList; } public void setCurrentKeyValueList(List<KeyValue> currentKeyValueList) { this.currentKeyValueList = currentKeyValueList; } public void saveKeyValues(ActionEvent event) { System.out.println("Save"); } ... } public class KeyValue implements Cloneable,java.io.Serializable { protected java.lang.String keyName; protected java.lang.String value; protected java.lang.Integer keyIndex; public java.lang.String getKeyName() { return keyName; } public void setKeyName(java.lang.String keyName) { this.keyName = keyName; } public java.lang.String getValue() { return value; } public void setValue(java.lang.String value) { this.value = value; } public java.lang.Integer getKeyIndex() { return keyIndex; } public void setKeyIndex(java.lang.Integer keyIndex) { this.keyIndex = keyIndex; } ... }
The first display is ok. But when I click on the button, I get this error :
javax.servlet.ServletException: /pages/admin/dropdownManagement.xhtml @52,50 value="#{keyValue.keyName}": Property 'keyName' not found on type java.lang.String
The orderingList seems to want to set the property on a String. But the var="keyValue" contains a KeyValue object which is not a String. As the list is correctly displayed before the submit, I guess the problem is probably not on my attributes?
Any idea?
In addition to this, do you know how I can link the setIndex() of my KeyValue object with the user changing the order of the list? I tried many ways , but never succeed...
Thanks for your help!