6 Replies Latest reply on Jan 31, 2008 6:57 AM by xiaocheng yuan

    why list empty

    xiaocheng yuan Newbie

      In order not to use auto search,i make some change to the resultList,in my action i print the resultList info,there are datas,but when it comes to the page,the list becomes empty,why?
      list

       package org.domain.demo.session;
      
      import org.domain.demo.entity.*;
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Out;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.annotations.Transactional;
      import org.jboss.seam.framework.EntityQuery;
      
      import java.lang.reflect.Field;
      import java.util.List;
      import java.util.Arrays;
      
      import javax.faces.model.DataModel;
      import javax.persistence.Query;
      
      import org.jboss.seam.faces.DataModels;
      
      @Name("kokyakuList")
      public class KokyakuList extends EntityQuery {
      
       private static final long serialVersionUID = 1L;
      
       private static final String[] RESTRICTIONS = {
       "lower(kokyaku.kokyakuCd) like concat(lower(#{kokyakuList.kokyaku.kokyakuCd}))",
       "lower(kokyaku.kokyakuName) like concat(lower(#{kokyakuList.kokyaku.kokyakuName}),'%')",
       "lower(kokyaku.kokyakuKana) like concat(lower(#{kokyakuList.kokyaku.kokyakuKana}),'%')",
       "lower(kokyaku.kokyakuAddr) like concat(lower(#{kokyakuList.kokyaku.kokyakuAddr}),'%')",
       "lower(kokyaku.kokyakuTel) like concat(lower(#{kokyakuList.kokyaku.kokyakuTel}),'%')",
       "lower(kokyaku.kokyakuFax) like concat(lower(#{kokyakuList.kokyaku.kokyakuFax}),'%')",
       "lower(kokyaku.kokyakuMail) like concat(lower(#{kokyakuList.kokyaku.kokyakuMail}),'%')",
       "lower(kokyaku.kokyakuNinzu) like concat(lower(#{kokyakuList.kokyaku.kokyakuNinzu}),'%')",
       "lower(kokyaku.kokyakuPresidentName) like concat(lower(#{kokyakuList.kokyaku.kokyakuPresidentName}),'%')",
       "lower(kokyaku.kokyakuGyosyu) like concat(lower(#{kokyakuList.kokyaku.kokyakuGyosyu}),'%')",
       "lower(kokyaku.kokyakuNaiyo) like concat(lower(#{kokyakuList.kokyaku.kokyakuNaiyo}),'%')",
       "lower(kokyaku.shain.syainCd) like concat(lower(#{kokyakuList.shainCd}))",};
      
       private Kokyaku kokyaku = new Kokyaku();
      
       private String shainCd;
      
       private SearchCodition searchCodition = new SearchCodition();
      
       public SearchCodition getSearchCodition() {
       return searchCodition;
       }
      
       public void setSearchCodition(SearchCodition searchCodition) {
       this.searchCodition = searchCodition;
       }
      
       public String getShainCd() {
       return shainCd;
       }
      
       public void setShainCd(String shainCd) {
       this.shainCd = shainCd;
       }
      
       @Override
       public String getEjbql() {
       return "select kokyaku from Kokyaku kokyaku";
      
       }
      
       @Override
       public Integer getMaxResults() {
       return 10;
       }
      
       public Kokyaku getKokyaku() {
       return kokyaku;
       }
      
       @Override
       public List<String> getRestrictions() {
       return Arrays.asList(RESTRICTIONS);
       }
      
       public String doSearch(){
      
       list = getResultList();
       System.out.println(list.size());
       return "success";
       }
      
       //i also try @DataModel
       private List list;
      
       public List getList() {
       return list;
       }
      
       public void setList(List list) {
       this.list = list;
       }
      
      
      }
      
      


      list
       <?xml version="1.0" encoding="Windows-31J"?>
      <!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/template2.xhtml">
      
       <ui:define name="pageTitle">
       <h4>顧客情報検索</h4>
       </ui:define>
      
       <ui:define name="body">
       <h:messages globalOnly="true" styleClass="message" id="globalMessages" />
      
       <h:form id="kokyakuSearch" styleClass="edit"
       style="margin-bottom:5px;">
       <input type="hidden" name="firstLoad" value="2" />
       <input type="hidden" name="firstResult" value="0" />
       <rich:simpleTogglePanel label="検索�件" switchType="ajax">
      
       <s:decorate template="layout/display.xhtml">
       <ui:define name="label">顧客CD</ui:define>
       <h:inputText id="kokyakuCd"
       value="#{kokyakuList.kokyaku.kokyakuCd}" />
       </s:decorate>
      
       <s:decorate template="layout/display.xhtml">
       <ui:define name="label">担当社員CD</ui:define>
       <h:inputText value="#{kokyakuList.shainCd}"></h:inputText>
       </s:decorate>
      
       <div style="clear: both" />
      
       <div class="actionButtons" align="right"><h:commandButton
       id="search" value="検索" action="#{kokyakuList.doSearch}" /></div>
      
       </rich:simpleTogglePanel>
      
       </h:form>
      
       <!-- Result List -->
      
       <h:form id="update">
       <rich:panel rendered="#{firstLoad != '1'}">
       <f:facet name="header">検索�果</f:facet>
       <div style="width: 100%;" class="results" id="kokyakuList"><h:outputText
       value="No kokyaku exists"
       rendered="#{empty kokyakuList.list}" /> <rich:dataTable
       id="kokyakuList" var="kokyaku" value="#{kokyakuList.list}"
       rows="10" columns="5"
       rendered="#{not empty kokyakuList.list}">
      
       <h:column>
       <f:facet name="header">�択</f:facet>
       <input type="radio" name="pid" id="pid"
       value="#{kokyaku.kokyakuCd}" />
       </h:column>
       <h:column>
       <f:facet name="header">
       <s:link styleClass="columnHeader"
       value="顧客CD #{kokyakuList.order=='kokyakuCd asc' ? messages.down : ( kokyakuList.order=='kokyakuCd desc' ? messages.up : '' )}">
       <f:param name="order"
       value="#{kokyakuList.order=='kokyakuCd asc' ? 'kokyakuCd desc' : 'kokyakuCd asc'}" />
       </s:link>
       </f:facet>
       #{kokyaku.kokyakuCd}
       </h:column>
       <h:column>
       <f:facet name="header">
       <s:link styleClass="columnHeader"
       value="顧客�称 #{kokyakuList.order=='kokyakuName asc' ? messages.down : ( kokyakuList.order=='kokyakuName desc' ? messages.up : '' )}">
       <f:param name="order"
       value="#{kokyakuList.order=='kokyakuName asc' ? 'kokyakuName desc' : 'kokyakuName asc'}" />
       </s:link>
       </f:facet>
       #{kokyaku.kokyakuName}
       </h:column>
       <h:column>
       <f:facet name="header">
       <s:link styleClass="columnHeader"
       value="担当社員CD #{kokyakuList.order=='shain.syainCd asc' ? messages.down : ( kokyakuList.order=='shain.syainCd desc' ? messages.up : '' )}">
       <f:param name="order"
       value="#{kokyakuList.order=='shain.syainCd asc' ? 'shain.syainCd desc' : 'shain.syainCd asc'}" />
       </s:link>
       </f:facet>
       #{kokyaku.shain.syainCd}
       </h:column>
       <h:column>
       <f:facet name="header">
       <s:link styleClass="columnHeader"
       value="担当社員� #{kokyakuList.order=='shain.syainName asc' ? messages.down : ( kokyakuList.order=='shain.syainName desc' ? messages.up : '' )}">
       <f:param name="order"
       value="#{kokyakuList.order=='shain.syainName asc' ? 'shain.syainName desc' : 'shain.syainName asc'}" />
       </s:link>
       </f:facet>
       #{kokyaku.shain.syainName}
       </h:column>
       <h:column>
       <f:facet name="header">
       <s:link styleClass="columnHeader"
       value="�引開始日 #{kokyakuList.order=='startDate asc' ? messages.down : ( kokyakuList.order=='startDate desc' ? messages.up : '' )}">
       <f:param name="order"
       value="#{kokyakuList.order=='startDate asc' ? 'startDate desc' : 'startDate asc'}" />
       </s:link>
       </f:facet>
       <h:outputLabel value="#{kokyaku.startDate}">
       <s:convertDateTime type="date" pattern="yyyy/MM/dd" />
       </h:outputLabel>
       </h:column>
       </rich:dataTable>
       <div class="tableControl" align="right">
       <div class="icon-h" align="right"><s:div styleClass="icon"
       rendered="#{kokyakuList.previousExists}">
       <s:link action="/KokyakuList.xhtml">
       <h:graphicImage value="/img/dleft.png" width="15" height="15"
       align="middle" />
       <f:param name="firstResult" value="0" />
       </s:link>
       <s:link view="/KokyakuList.xhtml" value=" First Page"
       id="firstPage">
       <f:param name="firstResult" value="0" />
       </s:link>
       </s:div> <s:div styleClass="icon" rendered="#{kokyakuList.previousExists}">
       <s:link action="/KokyakuList.xhtml">
       <h:graphicImage value="/img/left.png" width="15" height="15"
       align="middle" />
       <f:param name="firstResult"
       value="#{kokyakuList.previousFirstResult}" />
       </s:link>
       <s:link view="/KokyakuList.xhtml" value=" Previous Page"
       id="previousPage">
       <f:param name="firstResult"
       value="#{kokyakuList.previousFirstResult}" />
       </s:link>
       </s:div> <s:div styleClass="icon" rendered="#{kokyakuList.nextExists}">
       <s:link view="/KokyakuList.xhtml" value="Next Page " id="nextPage">
       <f:param name="firstResult" value="#{kokyakuList.nextFirstResult}" />
       </s:link>
       <s:link action="/KokyakuList.xhtml">
       <h:graphicImage value="/img/right.png" width="15" height="15"
       align="middle" />
       <f:param name="firstResult" value="#{kokyakuList.nextFirstResult}" />
       </s:link>
       </s:div> <s:div styleClass="icon-s" rendered="#{kokyakuList.nextExists}">
       <s:link view="/KokyakuList.xhtml" value="Last Page " id="lastPage">
       <f:param name="firstResult" value="#{kokyakuList.lastFirstResult}" />
       </s:link>
       <s:link action="/KokyakuList.xhtml">
       <h:graphicImage value="/img/dright.png" width="15" height="15"
       align="middle" />
       <f:param name="firstResult" value="#{kokyakuList.lastFirstResult}" />
       </s:link>
       </s:div></div>
      
       </div>
       </div>
       <div class="actionButtons" align="right"><h:commandButton
       id="detailButton" value="詳細表示" action="#{kokyakuHome.detail}"
       rendered="#{not empty kokyakuList.list}">
       </h:commandButton> <h:commandButton id="updateButton" value="æ›´æ–°"
       action="#{kokyakuHome.modify}"
       rendered="#{not empty kokyakuList.list}">
       </h:commandButton> <h:commandButton id="deleteButton" value="削除"
       action="#{kokyakuHome.delete}"
       rendered="#{not empty kokyakuList.list}">
       </h:commandButton></div>
      
      
       </rich:panel>
       <div class="actionButtons" align="right"><h:commandButton
       action="#{kokyakuHome.createKokyaku}" id="create" value="新�登録">
       </h:commandButton></div>
       </h:form>
      
      
       </ui:define>
      
      </ui:composition>
      
      
      

      can someone give me some advice?

        • 1. Re: why list empty
          xiaocheng yuan Newbie

          also navigation file

           <page xmlns="http://jboss.com/products/seam/pages"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd">
          
           <begin-conversation join="true" />
          
           <param name="firstResult" value="#{kokyakuList.firstResult}" />
           <param name="order" value="#{kokyakuList.order}" />
           <param name="firstLoad" />
          
           <navigation from-action="#{kokyakuHome.createKokyaku}">
           <rule if-outcome="success">
           <redirect view-id="/KokyakuEdit.xhtml" />
           </rule>
           </navigation>
          
           <navigation from-action="#{kokyakuHome.detail}">
           <rule if-outcome="success">
           <redirect view-id="/Kokyaku.xhtml" />
           </rule>
           <rule if-outcome="input">
           <redirect view-id="/KokyakuList.xhtml" />
           </rule>
           </navigation>
          
           <navigation from-action="#{kokyakuHome.modify}">
           <rule if-outcome="success">
           <redirect view-id="/KokyakuEdit.xhtml" />
           </rule>
           <rule if-outcome="input">
           <redirect view-id="/KokyakuList.xhtml" />
           </rule>
           </navigation>
          
           <navigation from-action="#{kokyakuHome.delete}">
           <rule if-outcome="success">
           <redirect view-id="/Kokyaku.xhtml" />
           </rule>
           <rule if-outcome="input">
           <redirect view-id="/KokyakuList.xhtml" />
           </rule>
           </navigation>
          
           <navigation from-action="#{kokyakuList.doSearch}">
           <rule if-outcome="success">
           <redirect view-id="/KokyakuList.xhtml" />
           </rule>
           </navigation>
          </page>
          
          
          
          
          


          • 2. Re: why list empty
            Nicklas Karlsson Master

            but debug output in the list getter shows 0?

            • 3. Re: why list empty
              Nicklas Karlsson Master

              Hmmm. Not sure about the statefull/lessness and scope of the EntityQuery, have to check.

              • 4. Re: why list empty
                xiaocheng yuan Newbie

                i change a little about my getList()

                 public List getList() {
                 if(list != null)
                 System.out.println(list.size() + "***************");
                 else
                 System.out.println("sssssssssssssssssss");
                 return list;
                 }
                


                and i got
                 19:36:30,656 INFO [STDOUT] Hibernate:
                 select
                 kokyaku0_.kokyaku_cd as kokyaku1_17_,
                 kokyaku0_.start_date as start2_17_,
                 kokyaku0_.kokyaku_tel as kokyaku3_17_,
                 kokyaku0_.kokyaku_fax as kokyaku4_17_,
                 kokyaku0_.tanto_cd as tanto17_17_,
                 kokyaku0_.kokyaku_name as kokyaku5_17_,
                 kokyaku0_.kokyaku_kana as kokyaku6_17_,
                 kokyaku0_.kokyaku_addr as kokyaku7_17_,
                 kokyaku0_.kokyaku_mail as kokyaku8_17_,
                 kokyaku0_.kokyaku_ninzu as kokyaku9_17_,
                 kokyaku0_.kokyaku_president_name as kokyaku10_17_,
                 kokyaku0_.kokyaku_shihon as kokyaku11_17_,
                 kokyaku0_.kokyaku_date as kokyaku12_17_,
                 kokyaku0_.kokyaku_gyosyu as kokyaku13_17_,
                 kokyaku0_.kokyaku_naiyo as kokyaku14_17_,
                 kokyaku0_.create_date as create15_17_,
                 kokyaku0_.apply_date as apply16_17_
                 from
                 kokyaku kokyaku0_
                 where
                 lower(kokyaku0_.kokyaku_cd) like concat(lower(?)) limit ?
                19:36:30,687 INFO [STDOUT] 1
                19:36:30,687 INFO [STDOUT] in search------------
                19:36:31,296 INFO [STDOUT] sssssssssssssssssss
                

                so here shows the list have been null when navigation to the page,i wonder if it is something about lifecycle.
                and my list is extended from EntityQuery ----Query----PersistenceController----Controller,nothing special about the scope,i am at a lost

                • 5. Re: why list empty
                  Nicklas Karlsson Master

                  What happens if you scope it to session just for test?

                  • 6. Re: why list empty
                    xiaocheng yuan Newbie

                    i find the reason.

                     <rule if-outcome="success">
                     <redirect view-id="/KokyakuList.xhtml" />
                     </rule>
                    

                    because of redirect just like a new request,different instance.