THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
If you want to serialize the list within the !DataModel along with the managed bean, then do this:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
public class SomeManagedBean implements Serializable { private List myData; private transient DataModel myDataModel; public DataModel getDataModel() { if (myDataModel == null) { myDataModel = new ListDataModel(myData); } return myDataModel; } } |
...
If you want the old behavior, I suggest creating a custom selectItem component that converts the value using the converter from the input control. Here is the code:
Code Block | borderStyle | solid|||
---|---|---|---|---|
| ||||
public class UISelectItem extends javax.faces.component.UISelectItem { public final static String COMPONENT_TYPE = "org.apache.myfaces.wiki.SelectItem"; private Boolean convertValue; /** * @return the convertValue */ public boolean getConvertValue() { if (this.convertValue != null) return this.convertValue; ValueBinding vb = getValueBinding("convertValue"); return (vb == null) ? true : (Boolean) vb.getValue(getFacesContext()); } /** * @param convertValue the convertValue to set */ public void setConvertValue(boolean convertValue) { this.convertValue = convertValue; } /** * @see javax.faces.component.UISelectItem#getItemValue() */ @Override public Object getItemValue() { Object value = super.getItemValue(); if (getConvertValue()) { UIInput parent = null; for (UIComponent comp = getParent(); comp != null; comp = comp.getParent()) { if (comp instanceof UIInput) { parent = (UIInput)comp; break; } } if (parent != null) value = getConvertedValue(getFacesContext(), parent, value); } return value; } /** * @see javax.faces.component.UISelectItem#saveState(javax.faces.context.FacesContext) */ @Override public Object saveState(FacesContext context) { return new Object[] { super.saveState(context), convertValue, }; } /** * @see javax.faces.component.UISelectItem#restoreState(javax.faces.context.FacesContext, java.lang.Object) */ @Override public void restoreState(FacesContext context, Object state) { Object[] arr = (Object[]) state; int index = -1; super.restoreState(context, arr[++index]); this.convertValue = (Boolean) arr[++index]; } private Object getConvertedValue(FacesContext context, UIInput input, Object value) throws ConverterException { Renderer renderer = getRenderer(context); if (renderer != null) return renderer.getConvertedValue(context, this, value); else if (value instanceof String) { Converter converter = RendererUtils.findUIOutputConverter( context, input); if (converter != null) return converter.getAsObject(context, this, (String)value); } return value; } } |
...