This is the jsf page: <p:dataTable editable="true" editMode="cell" var="data" value="#{tableBean.dynaObjectList}" scrollable="true" scrollWidth="100%" scrollHeight="100%"> <p:ajax event="cellEdit" immediate="true" listener="#{tableBean.onCellEdit}" /> <c:forEach items="#{tableBean.columns}" var="column" varStatus="loop"> <p:column sortBy="#{data.map[column.property]}" headerText="#{column.header}"> <p:cellEditor> <f:facet name="input"> <p:inputText value="#{data.map[column.property]}" /> </f:facet> <f:facet name="output"> <h:outputText value="#{data.map[column.property]}" /> </f:facet> </p:cellEditor> </p:column> </c:forEach> </p:dataTable>
Normally, for viewing the data , there is not any restriction. I added inline editing support to the table and can't set the value. When i tried LazyDynaMap like mentioned at the wiki, I am only able to add one data value, because the map has keys with properties. So if i have a DynaBean list which has properties like firstname, lastname firstname=Ercan lastname=Canlier firstname=Ercan2 lastname=Canlier2 Map will include only Ercan2 because the key is firstname for instance. How can i create Dynamic table from the DynaBeans which will be also editable? Wiki information like below: *2. LazyDynaMap <http://commons.apache.org/proper/commons-beanutils/javadocs/v1.9.2/apidocs/org/apache/commons/beanutils/LazyDynaMap.html>* is a *light weight* DynaBean facade to a Map with all the usual *lazy* features. Its *light weight* because it doesn't have an associated DynaClass containing all the properties. In fact it actually implements the DynaClass interface itself (and MutableDynaClass) and derives all the *DynaClass* information from the actual contents of the Map. A LazyDynaMap can be created around an existing Map or can instantiate its own Map. After any DynaBean processing has finished the Map can be retrieved and the DynaBean *facade* discarded. If you need a new Map then to use.... DynaBean dynaBean = new LazyDynaMap(); // create DynaBean dynaBean.set("foo", "bar"); // simple dynaBean.set("customer", "title", "Mr"); // mapped dynaBean.set("address", 0, addressLine1); // indexed Map myMap = dynaBean.getMap() // retrieve the Map *or* to use with an existing Map .... Map myMap = .... // exisitng Map DynaBean dynaBean = new LazyDynaMap(myMap); // wrap Map in DynaBean dynaBean.set("foo", "bar"); // set properties 2015-06-22 23:29 GMT+03:00 Oliver Heger <oliver.he...@oliver-heger.de>: > > > Am 22.06.2015 um 21:56 schrieb Ercan Canlıer: > > Hello, > > As i mentioned at the mail subject, i am having problem with not mutable > > map inside BasicDynaBean. > > As far as i know, it is the default behaviour of this map. > > What i would like to do is, simply retrieve the resultset from db which > > will create a list including DynaBeans. > > For viewing the database table, everything works fine, the problem occurs > > when i try to edit it and i get the following exception: > > > > Caused by: javax.el.PropertyNotWritableException > > at javax.el.MapELResolver.setValue(MapELResolver.java:267) > > at > > > com.sun.faces.el.DemuxCompositeELResolver._setValue(DemuxCompositeELResolver.java:255) > > at > > > com.sun.faces.el.DemuxCompositeELResolver.setValue(DemuxCompositeELResolver.java:281) > > at com.sun.el.parser.AstValue.setValue(AstValue.java:201) > > at > com.sun.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:291) > > at > > > com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:131) > > ... 50 more > > This stack trace does not contain a reference to Commons BeanUtils. > Also, the exception thrown is from the Java expression language (EL), > not from BeanUtils. It seems to me that there is already a problem in > your path expression before the DynaBean is actually hit. > > I don't know EL well enough, but could it be the case that it simply > cannot handle dyna beans? > > Oliver > > > > > I assume, this is because of the map inside dyna bean is not mutable. > > I think one option is to change the default behaviour of the map by > editing > > the source code of BeanUtils library. > > On the other hand, i think the implementors of this library must have > > thought this functionality somehow... > > Below is the code snippet that i use for retrieving the result set as > > DynaBeans. > > > > > > String query = "SELECT * FROM test.a"; > > > > Statement stmt = (Statement) con.createStatement(); > > ResultSet rs = stmt.executeQuery(query); > > RowSetDynaClass rsdc = new RowSetDynaClass(rs); > > > > rs.close(); > > stmt.close(); > > dynaObjectList= rsdc.getRows(); > > > > I tried to use LazyDynaMap as well, editing the table worked fine but the > > Map didnt allow me to put multiple data since the key is not unique for > > other datasets. > > Because the key is the property name. > > > > I would be really appreciated if you suggest me hints. > > Thanks in advance. > > I am really looking forward to see the answers if possible. > > Best regards. > > Ercan CANLIER > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@commons.apache.org > For additional commands, e-mail: user-h...@commons.apache.org > > -- Ercan CANLIER