Hi, I wrote an editable table where one column contains a selectOneChoice component. If I edit a row and try to save the changes, all underlaying values of the selectOneChoice component of all rows other then the edited row will be set to null. I could not figure it out why.
I'm using PPR to change the components of one row from read-only to editable and I also use partialSubmit to submit the data. Below is the sample jsp and the backing bean (registered in faces-config.xml as managed bean "tb" with session scope). What did I forget to implement or made wrong? test.jsp: <[EMAIL PROTECTED] uri="http://java.sun.com/jsf/core" prefix="f"%> <[EMAIL PROTECTED] uri="http://myfaces.apache.org/trinidad" prefix="tr"%> <[EMAIL PROTECTED] uri="http://myfaces.apache.org/trinidad/html" prefix="trh"%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <f:view> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <trh:styleSheet/> </head> <body> <tr:form defaultCommand="sSave" id="frmSamples"> <tr:panelCaptionGroup captionText="Properties"> <tr:table id="tblExtProperties" value="#{tb.propertySet.extProperties}" binding="#{tb.propertiesTable}" var="extProperties"> <tr:column headerText="ID"> <tr:outputText value="#{extProperties.id}" /> </tr:column> <tr:column headerText="Base Property"> <tr:selectOneChoice id="baseProperty" value="#{extProperties.baseProperty}" readOnly="#{tb.visibleOnly}" partialTriggers="sEdit sSave sReset" immediate="true"> <f:selectItems value="#{tb.properties}" id="selectedProperty"/> </tr:selectOneChoice> </tr:column> <tr:column headerText="Actions"> <tr:panelButtonBar partialTriggers="sEdit sSave sReset"> <tr:commandLink id="sEdit" actionListener="#{tb.edit}" text="Edit" partialSubmit="true" rendered="#{tb.visibleOnly}" immediate="true" /> <tr:commandLink id="sSave" actionListener="#{tb.save}" text="Save" partialSubmit="true" rendered="#{!tb.visibleOnly}" /> <tr:commandLink id="sReset" actionListener="#{tb.cancel}" text="Cancel" partialSubmit="true" rendered="#{!tb.visibleOnly}" immediate="true"> <tr:resetActionListener/> </tr:commandLink> </tr:panelButtonBar> </tr:column> <tr:messages globalOnly="true" styleClass="errors"/> <f:facet name="footer"> <tr:panelButtonBar halign="center"> <tr:commandButton id="sSave2" text="Edit All" actionListener="#{tb.edit}" immediate="true" /> </tr:panelButtonBar> </f:facet> </tr:table> </tr:panelCaptionGroup> </tr:form> </body> </html> </f:view> backing bean: /** * */ package beans; import java.util.ArrayList; import java.util.List; import javax.faces.event.ActionEvent; import javax.faces.model.SelectItem; import org.apache.myfaces.trinidad.component.UIXTable; public class TestBean { public class Property { int id; String name; public Property(int id, String name) { this.id = id; this.name = name; } @Override public String toString() { return name; } } Property[] m_Properties = new Property[] { new Property(1, "prop1"), new Property(2, "prop2"), new Property(3, "prop3") }; public class ExtendedProperty { int id; Property baseProperty; public ExtendedProperty(int id, Property bp) { this.id = id; this.baseProperty = bp; } public int getId() { return id; } public Property getBaseProperty() { return baseProperty; } public void setBaseProperty(Property baseProperty) { System.err.println("Changing base property from " + this.baseProperty + " to " + baseProperty); this.baseProperty = baseProperty; } @Override public String toString() { return id + ":" + baseProperty; } } public class PropertySet { List<ExtendedProperty> extProperties = new ArrayList<ExtendedProperty>(); public PropertySet() { extProperties.add(new ExtendedProperty(1, m_Properties[0])); extProperties.add(new ExtendedProperty(2, m_Properties[2])); } public List<ExtendedProperty> getExtProperties() { return extProperties; } public void setExtProperties(List<ExtendedProperty> extProperties) { this.extProperties = extProperties; } } private boolean visibleOnly = true; PropertySet propertySet = new PropertySet(); private UIXTable propertiesTable; public UIXTable getPropertiesTable() { return propertiesTable; } public void setPropertiesTable(UIXTable propertiesTable) { this.propertiesTable = propertiesTable; } public List getProperties() { List properties = new ArrayList(); for (Property p : m_Properties) properties.add(new SelectItem(p, p.toString())); return properties; } public PropertySet getPropertySet() { return propertySet; } public void setPropertySet(PropertySet propertySet) { this.propertySet = propertySet; } public void setVisibleOnly(boolean attribute) { this.visibleOnly = attribute; } public boolean isVisibleOnly() { return visibleOnly; } public void edit(ActionEvent actionEvent) { visibleOnly = false; } public void cancel(ActionEvent actionEvent) { visibleOnly = true; } public void reset(ActionEvent actionEvent) { visibleOnly = true; } public void save(ActionEvent actionEvent) { System.err.println("saving property..."); ExtendedProperty ep = (ExtendedProperty)propertiesTable.getRowData(); System.err.println(ep); System.err.println(propertySet.extProperties); visibleOnly = true; } }