This content has been marked as final.
Show 1 reply
-
1. Re: @DataModelSelection defaults to first value in model??
ebu Mar 21, 2007 6:06 PM (in response to edeprez)Hi
I met the same problem, but in slightly different context - i have a CRUD SFSL and it's instance member after creation was overwritten with new value:public class ItemEditor implements ItemEditorLocal{ @DataModelSelection private Item item = new Item(); ... public void persist() { em.persist(this.item); .... this.item = new Item(); } ... }
by this i wanted to clean the form which displays current item. But instead i got my form populated with recently entered data. Even after killing all cookies and refreshing the page it was filled. I was completely baffled!
But it appears that most likely the problem is caused by javax.faces.model.ListDataModel - it sets rowIndex to 0 when it has some data and then when injectDataModelSelections is being called on a component the first element in a datamodel is picked up and injected into member annotated with @DataModelSelection... hardly it was expected behaviour...
btw, there is a astounding code in injectDataModelSelection:if (null!=null) { setFieldValue( bean, null, name, wrapper.getWrappedData(dataModelAnn, dataModel) ); //for PAGE scope datamodels (does not work for properties!) }
i mean null!=null ... what is that?
wbr, eugen.