[jboss-user] [JBoss Seam] - Re: DataTable Sorting Example

griffitm do-not-reply at jboss.com
Thu Oct 25 16:55:59 EDT 2007


Ok, I tried restructuring this as a framework query, and the query works, but the pagination throws an exception.

First the query as defined in components.xml:
   <framework:entity-query name="deliverableSearchList"
  |                            entity-manager="#{em}"
  |                            ejbql="select d from Deliverable d"
  |                            order="d.dueDate">
  |        <framework:restrictions>
  |            <value>d.dueDate > #{search.fromDate}</value>
  |            <value>d.dueDate < #{search.toDate}</value>
  |        </framework:restrictions>                           
  |    </framework:entity-query>                                
  | 

And My 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"
  |                 xmlns:rich="http://richfaces.org/rich"
  |                 template="layout/template.xhtml">
  |                        
  | <ui:define name="body">
  |     
  |     <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>
  | 
  |     <h:form id="searchCriteria" styleClass="edit">
  |         
  |         <fieldset>
  |         <rich:simpleTogglePanel label="Deliverable Date Search" switchType="ajax">
  |             
  |             <s:decorate template="layout/display.xhtml">
  |                 <ui:define name="label">From Due Date:</ui:define>
  | 		<rich:calendar id="fromDueDate" popup="true" enableManualInput="true"
  |                           value="#{search.fromDate}" pattern="MM/dd/yyyy" 
  |                           event="onclick" reRender="completionDateDecoration" bypassUpdates="true"/>
  |                 
  |             </s:decorate>
  | 
  |             <s:decorate template="layout/display.xhtml">
  |                 <ui:define name="label">To Due Date:</ui:define>
  | 		<rich:calendar id="toDueDate" popup="true" enableManualInput="true"
  |                           value="#{search.toDate}" pattern="MM/dd/yyyy" 
  |                           event="onclick" reRender="completionDateDecoration" bypassUpdates="true"/>
  |             </s:decorate>
  |             
  |         </rich:simpleTogglePanel>
  |         
  |         <div class="actionButtons">
  |             <h:commandButton id="search" value="Search" action="/Search.xhtml"/>
  |         </div>
  |        </fieldset>
  |     </h:form>
  |     
  |     
  |     <rich:panel>
  |         <f:facet name="header">Deliverable Search Results</f:facet>
  |     <div class="results" id="deliverableSearchList">
  | 
  |     <h:outputText value="No deliverable exists" 
  |                rendered="#{empty deliverableSearchList.resultList}"/>
  |                
  |     <rich:dataTable id="deliverableSearchList" 
  |                 var="deliverable"
  |               value="#{deliverableSearchList.resultList}" 
  |            rendered="#{not empty deliverableSearchList.resultList}">
  |         <h:column>
  |             <f:facet name="header">
  |                 <s:link styleClass="columnHeader"
  |                              value="Deliverable #{deliverableSearchList.order=='description asc' ? messages.down : ( deliverableSearchList.order=='description desc' ? messages.up : '' )}">
  |                     <f:param name="order" value="#{deliverableSearchList.order=='description asc' ? 'description desc' : 'description asc'}"/>
  |                 </s:link>
  |             </f:facet>
  |             #{deliverable.description}
  |         </h:column>
  |         <h:column>
  |             <f:facet name="header">
  |                 <s:link styleClass="columnHeader"
  |                              value="Due Date #{deliverableSearchList.order=='dueDate asc' ? messages.down : ( deliverableSearchList.order=='dueDate desc' ? messages.up : '' )}">
  |                     <f:param name="order" value="#{deliverableSearchList.order=='dueDate asc' ? 'dueDate desc' : 'dueDate asc'}"/>
  |                 </s:link>
  |             </f:facet>
  |             #{deliverable.dueDate}
  |         </h:column>
  |     </rich:dataTable>
  | 
  |     </div>
  |     </rich:panel>
  |     
  |     <div class="tableControl">
  |       
  |         <s:link view="/Search.xhtml" 
  |             rendered="#{deliverableSearchList.previousExists}" 
  |                value="#{messages.left}#{messages.left} First Page"
  |                   id="firstPage">
  |           <f:param name="firstResult" value="0"/>
  |         </s:link>
  |         
  |         <s:link view="/Search.xhtml" 
  |             rendered="#{deliverableSearchList.previousExists}" 
  |                value="#{messages.left} Previous Page"
  |                   id="previousPage">
  |             <f:param name="firstResult" 
  |                     value="#{deliverableSearchList.previousFirstResult}"/>
  |         </s:link>
  |         
  |         <s:link view="/Search.xhtml" 
  |             rendered="#{deliverableSearchList.nextExists}" 
  |                value="Next Page #{messages.right}"
  |                   id="nextPage">
  |             <f:param name="firstResult" 
  |                     value="#{deliverableSearchList.nextFirstResult}"/>
  |         </s:link>
  |         
  |         <s:link view="/Search.xhtml" 
  |             rendered="#{deliverableSearchList.nextExists}" 
  |                value="Last Page #{messages.right}#{messages.right}"
  |                   id="lastPage">
  |             <f:param name="firstResult" 
  |                     value="#{deliverableSearchList.lastFirstResult}"/>
  |         </s:link>
  |         
  |     </div>
  |     
  |      
  |     <s:div styleClass="actionButtons" rendered="#{empty from}">
  |         <s:button view="/DeliverableEdit.xhtml"
  |                     id="create" 
  |                  value="Create Deliverable">
  |             <f:param name="deliverableId"/>
  |         </s:button>
  |     </s:div>
  |     
  | </ui:define>
  | 
  | </ui:composition>
  | 
And my managed Bean:

  | @Name("search")
  | @Scope(ScopeType.SESSION)
  | public class Search {
  |     
  |     /** Creates a new instance of Search */
  |     public Search() {
  |         
  |     }
  |     private Date fromDate;
  |     private Date toDate;
  | 
  |     public Date getFromDate() {
  |         if(fromDate == null){
  |             fromDate= Calendar.getInstance().getTime();
  |         }
  |         return fromDate;
  |     }
  | 
  |     public void setFromDate(Date fromDate) {
  |         this.fromDate = fromDate;
  |     }
  | 
  |     public Date getToDate() {
  |         if(toDate == null){
  |             Calendar calendar= Calendar.getInstance();
  |             calendar.roll(Calendar.DAY_OF_YEAR, 30);
  |             toDate= calendar.getTime();
  |         }
  |         return toDate;
  |     }
  | 
  |     public void setToDate(Date toDate) {
  |         this.toDate = toDate;
  |     }
  |     
  |     
  | }
  | 

Throws Exception:

  | javax.faces.FacesException: javax.el.ELException: /Search.xhtml @162,33 rendered="#{deliverableSearchList.nextExists}":
  | Error reading 'nextExists' on type org.jboss.seam.framework.EntityQuery_$$_javassist_9
  |         at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:373)
  |         at javax.faces.component.UIComponent.encodeAll(UIComponent.java:880)
  | 

If I remove the pagination, the search works fine.  How is this any different  from the managed components generated by seam gen?
Any help would be much appreciated!

Best Regards, 
MG

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4099015#4099015

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4099015



More information about the jboss-user mailing list