-
1. Re: Delete selected row from DataModel
Nicklas Karlsson Apr 16, 2008 8:29 AM (in response to roger phillips)Could there be something with the fact that there is no submit (s:link)? Try a commandLink or something submitting...
-
2. Re: Delete selected row from DataModel
Daniel Roth Apr 16, 2008 8:43 AM (in response to roger phillips)I do it this way. Works fine for me
<rich:dataTable value="#{regionList}" var="region" id="products" rows="10" width="100%"> <h:column> <f:facet name="header"> <h:outputText value="#{messages['regions.account']}" styleClass="text" /> </f:facet> <h:outputText value="#{region.account}" styleClass="text" /> </h:column> <h:column> <f:facet name="header"> <h:outputText value="#{messages['regions.delete']}" styleClass="text" /> </f:facet> <s:button action="#{adminRegions.delete(region)}" value="#{messages['regions.delete']}" disabled="#{region.deleted}" styleClass="text" /> </h:column> <h:column> <f:facet name="header"> <h:outputText value="#{messages['regions.undelete']}" styleClass="text" /> </f:facet> <s:button action="#{adminRegions.undelete(region)}" value="#{messages['regions.undelete'] }" disabled="#{!region.deleted}" styleClass="text" /> </h:column> </rich:dataTable>
@DataModel private List<Region> regionList; @In private EntityManager em; @Factory("regionList") public void findRegions() { regionList = em.createQuery("SELECT o FROM Region o ORDER by o.id desc").getResultList(); } public void delete(Region region) { region.setDeleted(true); em.persist(region); } public void undelete(Region region) { region.setDeleted(false); em.persist(region); }
Hopefully I didn't cut out anything essential :-)
-
3. Re: Delete selected row from DataModel
roger phillips Apr 16, 2008 9:13 PM (in response to roger phillips)Thanks for the response. The difference between your example and what I'm doing is that I'm physically removing an object from an ArrayList in the delete method rather than a
soft
delete. The stack error indicates an illegal argument error trying to fetch rowData from the ListDataModel wrapper.All the examples I've see use entity queries (resultList) with DataModel - no ArrayList.
-
4. Re: Delete selected row from DataModel
roger phillips Apr 16, 2008 9:16 PM (in response to roger phillips)Thanks for your response. The s:link is working fine and returning the selected object id using @DataModelSelectonIndex. I've also returned the object itself successfully using both delete(ownr) and @DataModelSelection.
I think I'm dealing with an ArrayList issue.
-
5. Re: Delete selected row from DataModel
roger phillips Apr 21, 2008 7:09 PM (in response to roger phillips)The work-around is to create a new ArrayList in the delete method. I'm runnng Seam 1.2.1 and this is apparently fixed in Seam 2.0.