Need help - new user
francof Sep 10, 2007 3:04 PMHi
I tried converting my standard datatable into a rich:datatable.
I'm using Seam 1.2.1GA with myfaces
I have a simple CRUD page with all records in a datatable, one of the cols in is a name(hyperlink) and the other a disabled checkbox pointing to this
@Column (name="active", nullable=false, length=1)
@Type(type="yes_no")
private boolean active;
in my hibernate entity. When the name link is clicked, a detail form allows edit and when a save button is pressed, the name & checkbox in the list should reflect changed values. The name reflects changes but not the checkbox. The other problem (if I use the rich:datatable) is that multiple updates to the same row causes javax.persistence.OptimisticLockException - Note if I do not have the rich:datatable in my page, I don't see this problem.
This is the code for standard and rich datatables
<h:dataTable id="catalogs" var="_catalog" value="#{catalogs}"
styleClass="listing" columnClasses=",,fixed,,actions" footerClass="hide" rendered="#{not empty(catalogs)}" >
<f:facet name="footer">
<!-- -->
</f:facet>
<h:column>
<f:facet name="header">Catalog Name</f:facet>
<h:commandLink value="#{_catalog.name}" action="#{catalogList.select()}"/>
</h:column>
<h:column>
<f:facet name="header">Active</f:facet>
<h:selectBooleanCheckbox id="activeflag" value="#{_catalog.active}" disabled="true" />
</h:column>
</h:dataTable>
<-- rich datatable with same cols as standard dattable above -->
<rich:dataTable id="dtCatalogList"
onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
cellpadding="0" cellspacing="0" width="500" border="0"
var="_catalog" value="#{catalogs}" rendered="#{catalogs.rowCount>0}">
<f:facet name="header">
<rich:columnGroup>
<rich:column>
<h:outputText value="Catalog Name" />
</rich:column>
<rich:column>
<h:outputText value="Active" />
</rich:column>
</rich:columnGroup>
</f:facet>
<rich:column> <h:commandLink value="#{_catalog.name}" action="#{catalogList.select()}"/></rich:column>
<rich:column align="center" > <h:selectBooleanCheckbox value="#{_catalog.active}" disabled="true" /></rich:column>
</rich:dataTable>
This is my table definition (Oracle) if that matters
CREATE TABLE CATALOG ( CATALOG_ID NUMBER(19) NOT NULL, CATALOG_NAME VARCHAR2(200 CHAR) NOT NULL, ACTIVE CHAR(1 BYTE) DEFAULT 'N', OBJ_VERSION INTEGER )
This is my Seam components in SFSB which work fine with standard datatable.
@PersistenceContext private EntityManager em; @DataModel private List<Catalog> catalogs; @DataModelSelection @Out(required=false) @In (required=false) private Catalog catalog ;