Entities Get Updated--Screen Doesn't (Usually)
gzoller Feb 21, 2007 7:49 PMI'm having a strange problem where particular entity changes are not (usually) being reflected on my screens. I start with a vanilla seam-gen application that generates these artifacts:
DepartmentList.xhtml (main application screen)
DepartmentList.page.xml
ProjectList.xhmtl (List of Projects)
ProjectList.page.xhtml
Department.java (@Entity)
DepartmentList.java (extends EntityQuery)
DeparmentHome (extends EntityHome)
Project.java (@Entity)
ProjectList.java (extends EntityQuery)
ProjectHome (extends EntityHome)
Easiest way to show you where I'm going is to look at a picture of part of the DepartmentList screen: http://sawdust.50webs.com/images/spurs_display.jpg
(No comments on the artwork please--I'm a server-side guy! I'll let the UI pros do what they do best.)
You'll see departments with a sub-listing of projects for ea. dept.
You see the "tape recorder" buttons? They change the status on Projects (update the entity). When I push these buttons the Project entities actually are correctly persisted to the database but no changes appear on the DisplayList screen. :-( Reloading the screen or visiting most other screens has no effect--the db and the screen are still out-of-sync.
Here's the weird part: If I first go to the ProjectList.xhtml screen (not touching anything there--just let it render) then immediately go back to DepartmentList.xhtml then click on a tape-recorder button for one click only the on-screen status changes immediately as desired. Subsequent clicks continue to change the persisted Project status but no screen changes occur unless I again visit ProjectList.xhtml. Huh?
This is hard to diagnose w/o seeing all the code, but I didn't want to dump reams of useless code into the forum. I'll post a chunk of ProjectList.xhtml since there seems to be some "magic" in simply visiting this page. If other files would be helpful let me know and I'll post them.
When I click a tape-recorder button in DepartmentList.xhtml (<s:link> w/image) I pass the ProjectId as a <f:param>. A stateful session bean does an em.find() on the ProjectId to get the Project entity, simply calls proj.setStatus() and we're done. Nothing fancy. Somewhere, somehow--something in the UI is still holding onto a copy of the previous Project object.
Thanks in advance for any advice/clues!
Greg
ProjectList.xhtml
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" template="layout/template.xhtml"> <ui:define name="body"> <h:messages globalOnly="true" styleClass="message" id="globalMessages"/> <div class="results" id="projectList"> <h3>Projects</h3> <h:outputText value="No project exists" rendered="#{empty projectList.resultList}"/> <h:dataTable id="projectList" var="project" value="#{projectList.resultList}" rendered="#{not empty projectList.resultList}"> <h:column> <f:facet name="header"> <s:link styleClass="columnHeader" value="projectId #{projectList.order=='projectId asc' ? messages.down : ( projectList.order=='projectId desc' ? messages.up : '' )}"> <f:param name="order" value="#{projectList.order=='projectId asc' ? 'projectId desc' : 'projectId asc'}"/> </s:link> </f:facet> #{project.projectId} </h:column> <h:column> <f:facet name="header"> <s:link styleClass="columnHeader" value="version #{projectList.order=='version asc' ? messages.down : ( projectList.order=='version desc' ? messages.up : '' )}"> <f:param name="order" value="#{projectList.order=='version asc' ? 'version desc' : 'version asc'}"/> </s:link> </f:facet> #{project.version} </h:column> <h:column> <f:facet name="header"> <s:link styleClass="columnHeader" value="department deptId #{projectList.order=='department.deptId asc' ? messages.down : ( projectList.order=='department.deptId desc' ? messages.up : '' )}"> <f:param name="order" value="#{projectList.order=='department.deptId asc' ? 'department.deptId desc' : 'department.deptId asc'}"/> </s:link> </f:facet> #{project.department.deptId} </h:column> <!-- CLIP! Lots more like this to draw out the rest of Project's fields --> </h:dataTable> </div> <div class="tableControl"> <s:link view="/ProjectList.xhtml" rendered="#{projectList.previousExists}" value="#{messages.left}#{messages.left} First Page" id="firstPage"> <f:param name="firstResult" value="0"/> </s:link> <s:link view="/ProjectList.xhtml" rendered="#{projectList.previousExists}" value="#{messages.left} Previous Page" id="previousPage"> <f:param name="firstResult" value="#{projectList.previousFirstResult}"/> </s:link> <s:link view="/ProjectList.xhtml" rendered="#{projectList.nextExists}" value="Next Page #{messages.right}" id="nextPage"> <f:param name="firstResult" value="#{projectList.nextFirstResult}"/> </s:link> <s:link view="/ProjectList.xhtml" rendered="#{projectList.nextExists}" value="Last Page #{messages.right}#{messages.right}" id="lastPage"> <f:param name="firstResult" value="#{projectList.lastFirstResult}"/> </s:link> </div> <s:div styleClass="actionButtons" rendered="#{empty from}"> <s:button view="/ProjectEdit.xhtml" id="create" value="Create project"> <f:param name="projectProjectId"/> </s:button> </s:div> </ui:define> </ui:composition>