4 Replies Latest reply on Sep 11, 2008 9:26 PM by alin.heyoulin.qq.com

    why do the @Factory menthod preform again while leaving a page?

    alin.heyoulin.qq.com

      I have conversation component with @Factory.
      why do the @Factory menthod preform again while leaving a page?

        • 1. Re: why do the @Factory menthod preform again while leaving a page?
          gjeudy

          Can you give a detailed usecase with code samples?

          • 2. Re: why do the @Factory menthod preform again while leaving a page?
            alin.heyoulin.qq.com

            component


            package com.yosc.mis.action;
            
            import java.io.Serializable;
            import java.text.SimpleDateFormat;
            import java.util.Date;
            import java.util.List;
            
            import javax.persistence.EntityManager;
            import javax.persistence.Query;
            import javax.transaction.SystemException;
            
            
            import org.jboss.seam.ScopeType;
            import org.jboss.seam.annotations.Factory;
            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.annotations.datamodel.DataModel;
            import org.jboss.seam.annotations.datamodel.DataModelSelection;
            import org.jboss.seam.annotations.security.Restrict;
            import org.jboss.seam.faces.FacesMessages;
            import org.jboss.seam.international.StatusMessages;
            import org.jboss.seam.transaction.Transaction;
            
            import com.yosc.mis.domain.Inventory;
            import com.yosc.mis.domain.User;
            import com.yosc.mis.domain.WsFibre;
            import com.yosc.mis.service.TransService;
            import com.yosc.mis.util.StringUtil;
            import com.yosc.mis.util.YoscException;
            import com.yosc.mis.webservice.YoscWebServiceClient;
            @Name("fibreAction")
            @Scope(ScopeType.CONVERSATION)
            @Restrict("#{identity.loggedIn}")
            public class FibreAction implements Serializable{
                 
                 /**
                  * 
                  */
                 private static final long serialVersionUID = 1L;
                 @In User user;
                 @In(create=true)
                    private StatusMessages statusMessages;
                 @In(create=true)
                  TransService transService;
                 @In EntityManager entityManager;
                 @In(required=false)@Out(required=false,scope=ScopeType.PAGE)
                 private String searchString;
                 @In(required=false)@Out(required=false,scope=ScopeType.PAGE)
                 private String invstatus;
                 @In(required=false)@Out(required=false,scope=ScopeType.PAGE)
                 private String selectstatus;
                 @In(required=false)@Out(required=false,scope=ScopeType.PAGE)
                 private String invbatchno;
                 @In(required=false)@Out(required=false,scope=ScopeType.PAGE)
                 private String outvbatchno;
                 @In(required=false)@Out(required=false,scope=ScopeType.PAGE)
                 private String invlocation;
                 @In(required=false)@Out(required=false,scope=ScopeType.PAGE)
                 private String grade;
                 @In(required=false)@Out(required=false,scope=ScopeType.PAGE)
                 private String deliverLenghth;
                 
                 @In(required=false)@Out(required=false,scope=ScopeType.PAGE)
                 private String pmdup;
                 @In(required=false)@Out(required=false,scope=ScopeType.PAGE)
                 private String totalup;
                 @In(required=false)@Out(required=false,scope=ScopeType.PAGE)
                 private String pmddown;
                 @In(required=false)@Out(required=false,scope=ScopeType.PAGE)
                 private String totaldown;
                 @In(required=false)@Out(required = false,scope=ScopeType.PAGE)
                private Integer pageSize;
                 private WsFibre addFibre=new WsFibre();
                 @In(required=false)@Out(required=false,scope=ScopeType.PAGE)
                 private WsFibre editFibre;
                 
                 @In("#{netclient}")
                 private YoscWebServiceClient yws;
                 
                 
                 private String fibreSelectNo="";
                 
                 @DataModel
                 private List<WsFibre> fibres;
                 @Factory
                 public void getFibres()
                 {
                      
                      queryFibres();
                 }
                 @DataModelSelection
                 private WsFibre fibre;
                 public void find()
                {
                      queryFibres();
                } 
               @SuppressWarnings("unchecked")
               private void queryFibres()
               {
                    pageSize=pageSize==null?10:pageSize;
                    String sql="from WsFibre i where (lower(i.fibreNo) like :search " +
                        "or lower(i.fibreType) like :search or lower(i.receiveNo) like :search " +
                        "or lower(i.location) like :search or lower(i.selBatch) like :search " +
                        "or lower(i.selBatch) like :search or lower(i.inBatch) like :search " +
                        "or lower(i.outBatch) like :search) " ;
                     if(!this.getInvstatus().equals(""))
                          sql+=" and i.invStatus="+this.getInvstatus();
                     if(!this.getSelectstatus().equals(""))
                          sql+=" and i.status="+this.getSelectstatus();
                     if(!this.getInvbatchno().equals(""))
                          sql+=" and i.inBatch='"+this.getInvbatchno()+"'";
                     if(!this.getInvlocation().equals(""))
                          sql+=" and i.location='"+this.getInvlocation()+"'";
                     if(!this.getOutvbatchno().equals(""))
                          sql+=" and i.outBatch='"+this.getOutvbatchno()+"'";
                     if(!this.getGrade().equals(""))
                          sql+=" and i.grade='"+this.getGrade()+"'";
                     
                     if(!this.getPmdup().equals(""))
                          sql+=" and i.pmd>="+this.getPmdup();
                     if(!this.getPmddown().equals(""))
                          sql+=" and i.pmd<="+this.getPmddown();
                     
                     if(!this.getTotalup().equals(""))
                          sql+=" and i.total>="+this.getTotalup();
                     if(!this.getTotaldown().equals(""))
                          sql+=" and i.total<="+this.getTotaldown();
                     
                     if(!this.getDeliverLenghth().equals(""))
                          sql+=" and i.deliverLenghth="+this.getDeliverLenghth();
                     
                    fibres= entityManager.createQuery(sql)
                              .setParameter("search", getSearchPattern()).getResultList();
            
               }
               public Integer getPageSize() {
                  return pageSize==null?10:pageSize;
               }
               public void setPageSize(Integer pageSize) {
                  this.pageSize=pageSize==null?10:pageSize;
               }
               
               public String getSearchPattern()
               {
                  return searchString==null ? 
                        "%" : '%' + searchString.toLowerCase().replace('*', '%') + '%';
               }
               
               public String getSearchString()
               {
                  return searchString;
               }
               
               public void setSearchString(String searchString)
               {
                  this.searchString = searchString;
               }
               @SuppressWarnings("unchecked")
               @Transactional
               public void addFibre()
               {
                    if(StringUtil.notNull(addFibre.getFibreNo()).equals(""))
                         {
                         statusMessages.add( "error" );
                         queryFibres();
                            return;
                         }
                    Query q = entityManager.createQuery("from WsFibre a where a.fibreNo=:fibreNo");
                    q.setParameter("fibreNo", addFibre.getFibreNo());
                 
                    List<WsFibre> results = q.getResultList();
                    if(results.size()>0)
                         {
                         statusMessages.add( "error" );
                              queryFibres();
                              return;
                         }
                    entityManager.persist(addFibre);
                  queryFibres();
                    }
                @SuppressWarnings("unchecked")
                @Transactional
                 public void editFibre() throws YoscException
                {          
                      if(StringUtil.notNull(editFibre.getFibreNo()).equals(""))
                         {
                           statusMessages.add( "error" );
                         queryFibres();
                            return;
                         }
                    Query q = entityManager.createQuery("from WsFibre a where a.fibreNo=:fibreNo");
                    q.setParameter("fibreNo", editFibre.getFibreNo());
            
                    List<WsFibre> results = q.getResultList();
                    
                    if(results.size()>=1)
                         {
                         int idd=0;
                           idd=results.get(0).getId().intValue();
                          if(idd!=editFibre.getId().intValue())
                          {
                               statusMessages.add( "error" );
                                   queryFibres();
                                   return;
                          }
                         
                         }
                    if(editFibre.getSalesLenght()==null)
                        {
                             statusMessages.add( "error" );
                             return; 
                        }
                        if(editFibre.getItem()==null)
                        {
                             FacesMessages.instance().add( "error" );
                              return;
                       }
                    editFibre.setIsReturn(1);
                    editFibre.setInvStatus(1);
                    
                    try{
                             SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
                             transService.dotrans(editFibre.getItem(), entityManager.find(Inventory.class,"yosc-m"),
                                       editFibre.getSalesLenght(), "fibreturn"+df.format(new Date()), "material-return", editFibre.getFibreNo(), user);
                        }catch(Exception e)
                        {
                             try {
                                Transaction.instance().setRollbackOnly();
                           } catch (IllegalStateException e1) {
                                // TODO Auto-generated catch block
                                e1.printStackTrace();
                           } catch (SecurityException e1) {
                                // TODO Auto-generated catch block
                                e1.printStackTrace();
                           } catch (SystemException e1) {
                                // TODO Auto-generated catch block
                                e1.printStackTrace();
                           }
                           //queryFibres();
                           FacesMessages.instance().add( e.getMessage() );
                           return;
                        }
                   
                   entityManager.merge(editFibre); 
                  queryFibres();
                }
                
                @SuppressWarnings("unchecked")
                @Transactional
                 public void rejectFibre()
                throws YoscException
                {          
                      if(StringUtil.notNull(editFibre.getFibreNo()).equals(""))
                         {
                           statusMessages.add( "error" );
                         queryFibres();
                            return;
                         }
                    Query q = entityManager.createQuery("from WsFibre a where a.fibreNo=:fibreNo");
                    q.setParameter("fibreNo", editFibre.getFibreNo());
            
                    List<WsFibre> results = q.getResultList();
                    
                    if(results.size()>=1)
                         {
                         int idd=0;
                           idd=results.get(0).getId().intValue();
                          if(idd!=editFibre.getId().intValue())
                          {
                               statusMessages.add( "error" );
                                   queryFibres();
                                   return;
                          }
                         
                         }
                   editFibre.setIsReturn(1);
                   editFibre.setInvStatus(90);
                   editFibre.setStatus(90);
            
                   try{
                        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
                        transService.dotrans(editFibre.getItem(), entityManager.find(Inventory.class,"yosc-m"),
                                  -1*editFibre.getSalesLenght(), "fibrereject"+df.format(new Date()), "material-reject", editFibre.getFibreNo(), user);
                   }catch(Exception e)
                   {
                        try {
                           Transaction.instance().setRollbackOnly();
                      } catch (IllegalStateException e1) {
                           // TODO Auto-generated catch block
                           e1.printStackTrace();
                      } catch (SecurityException e1) {
                           // TODO Auto-generated catch block
                           e1.printStackTrace();
                      } catch (SystemException e1) {
                           // TODO Auto-generated catch block
                           e1.printStackTrace();
                      }
                      //queryFibres();
                      FacesMessages.instance().add( e.getMessage() );
                      return;
                   }
                   
                   entityManager.merge(editFibre);
                  queryFibres();
                }
                public void selectEditFibre() {
                      this.editFibre=this.fibre;
                 }
                 public WsFibre getAddFibre() {
                      return addFibre;
                 }
                 public void setAddFibre(WsFibre addFibre) {
                      this.addFibre = addFibre;
                 }
                 public WsFibre getEditFibre() {
                      return editFibre;
                 }
                 public void setEditFibre(WsFibre editFibre) {
                      this.editFibre = editFibre;
                 }
                 public String getFibreSelectNo() {
                      return fibreSelectNo;
                 }
                 public void setFibreSelectNo(String fibreSelectNo) {
                      this.fibreSelectNo = fibreSelectNo;
                 }
                 public void importFibre()
                 {
                      String[] aa=null;
                      try {
                           aa=yws.importFiberDate(fibreSelectNo);
                      } catch (Exception e) {
                           // TODO Auto-generated catch block
                           FacesMessages.instance().add("error"+e.getMessage());
                           e.printStackTrace();
                      }
                      statusMessages.add(aa[0]+"error:"+aa[1]+","+aa[2]);
                 }
                 public String getInvstatus() {
                      
                      invstatus=invstatus==null?"":invstatus;
                      if(!invstatus.equals(""))
                           try{
                                Integer.parseInt(invstatus);
                           }catch(Exception e)
                           {
                                statusMessages.add( "error" );
                                invstatus="";
                           }
                      return invstatus;
                 }
                 public void setInvstatus(String invstatus) {
                      this.invstatus = invstatus;
                 }
                 public String getSelectstatus() {          
                      selectstatus=selectstatus==null?"":selectstatus;
                      if(!selectstatus.equals(""))
                           try{
                                Integer.parseInt(selectstatus);
                           }catch(Exception e)
                           {
                                statusMessages.add( "error" );
                                selectstatus="";
                           }
                      return selectstatus;
                 }
                 public void setSelectstatus(String selectstatus) {
                      this.selectstatus = selectstatus;
                 }
                 public String getInvbatchno() {          
                      return invbatchno==null?"":invbatchno;
                 }
                 public void setInvbatchno(String invbatchno) {
                      this.invbatchno = invbatchno;
                 }
                 public String getInvlocation() {
                      return invlocation==null?"":invlocation;
                 }
                 public void setInvlocation(String invlocation) {
                      this.invlocation = invlocation;
                 }
                 public String getOutvbatchno() {
                      return outvbatchno==null?"":outvbatchno;
                 }
                 public void setOutvbatchno(String outvbatchno) {
                      this.outvbatchno = outvbatchno;
                 }
                 public String getGrade() {
                      return grade==null?"":grade;
                 }
                 public void setGrade(String grade) {
                      this.grade = grade;
                 }
                 public String getPmdup() {
                      pmdup=pmdup==null?"":pmdup;
                      if(!pmdup.equals(""))
                           try{
                                Double.parseDouble(pmdup);
                           }catch(Exception e)
                           {
                                statusMessages.add( "error" );
                                pmdup="";
                           }
                      return pmdup;
                 }
                 public void setPmdup(String pmdup) {
                      this.pmdup = pmdup;
                 }
                 public String getTotalup() {
                      totalup=totalup==null?"":totalup;
                      if(!totalup.equals(""))
                           try{
                                Double.parseDouble(totalup);
                           }catch(Exception e)
                           {
                                statusMessages.add( "error" );
                                totalup="";
                           }
                      return totalup;
                 }
                 public void setTotalup(String totalup) {
                      this.totalup = totalup;
                 }
                 public String getPmddown() {
                      pmddown=pmddown==null?"":pmddown;
                      if(!pmddown.equals(""))
                           try{
                                Double.parseDouble(pmddown);
                           }catch(Exception e)
                           {
                                statusMessages.add( "error" );
                                pmddown="";
                           }
                      return pmddown;
                 }
                 public void setPmddown(String pmddown) {
                      this.pmddown = pmddown;
                 }
                 public String getTotaldown() {
                      totaldown=totaldown==null?"":totaldown;
                      if(!totaldown.equals(""))
                           try{
                                Double.parseDouble(totaldown);
                           }catch(Exception e)
                           {
                                statusMessages.add( "error" );
                                totaldown="";
                           }
                      return totaldown;
                 }
                 public void setTotaldown(String totaldown) {
                      this.totaldown = totaldown;
                 }
                 public String getDeliverLenghth() {
                      deliverLenghth=deliverLenghth==null?"":deliverLenghth;
                      if(!deliverLenghth.equals(""))
                           try{
                                Double.parseDouble(deliverLenghth);
                           }catch(Exception e)
                           {
                                statusMessages.add( "error" );
                                deliverLenghth="";
                           }
                      return deliverLenghth;
                 }
                 public void setDeliverLenghth(String deliverLenghth) {
                      this.deliverLenghth = deliverLenghth;
                 }
                 
                 
            }
            
            
            
            
            and the xmhtl page
            
            
            <!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:ui="http://java.sun.com/jsf/facelets"
                                  xmlns:h="http://java.sun.com/jsf/html"
                                  xmlns:f="http://java.sun.com/jsf/core"
                                  xmlns:s="http://jboss.com/products/seam/taglib"
                            xmlns:a="http://richfaces.org/a4j"
                                template="../template/template.xhtml"
                            xmlns:rich="http://richfaces.org/rich">
            
            <!-- content -->
            <ui:define name="content">
            
            <script type="text/javascript">setTimeout('yofc.endLoading()',1);</script>
                 <link rel="stylesheet" href="#{facesContext.externalContext.requestContextPath}/app/yosc/css/screen.css" type="text/css" />
            
            <div style="width:96%;padding: 15px 15px 0 15px;">
              
                <a:outputPanel ajaxRendered="true"> 
                     <span style="font-weight: bold;color:red;">
                        <h:messages/>
                     </span>
                    </a:outputPanel> 
                <h1>list</h1>
            
                      <a:form id="searchCriteria">
                      <fieldset> 
                      <div style="float:right;position:left;">
                                  <a:commandButton value="fibre data import" onclick="Richfaces.showModalPanel('panel1')"/>
                                  <!--  <a:commandButton value="add" onclick="#{rich:component('panel')}.show()"/>-->
                 
                             <h:outputLabel for="pageSize">record/page:</h:outputLabel>&#160;
                             
                             <h:selectOneMenu value="#{fibreAction.pageSize}" id="pageSize">
                                <f:selectItem itemLabel="5" itemValue="5"/>
                                <f:selectItem itemLabel="10" itemValue="10"/>
                                <f:selectItem itemLabel="20" itemValue="20"/>
                             </h:selectOneMenu>
                        </div>
                         <div >
                              <h:inputText id="searchString" value="#{fibreAction.searchString}" style="width: 100px;height:22px;border:1px;border-color: blue">
                               <a:support event="onkeyup" RequestDelay="3000" eventsQueue="find" actionListener="#{fibreAction.find}" reRender="searchResults" />
                             </h:inputText>
                             &#160;
                              <a:commandButton id="findCustermers" value="find" action="#{fibreAction.find}" reRender="searchResults"/>
                             &#160;
                             <a:status>
                                <f:facet name="start">
                                   <h:graphicImage value="../../img/spinner.gif"/>
                                </f:facet>
                             </a:status>
                             <p/>
                             <h:outputText value="inv status"/>
                             <h:inputText id="invstatus" value="#{fibreAction.invstatus}" style="width: 20px;height:22px;border:1px;border-color: blue"/>
                             <h:outputText value="fib status"/>
                             <h:inputText id="selectstatus" value="#{fibreAction.selectstatus}" style="width: 20px;height:22px;border:1px;border-color: blue"/>
                             <h:outputText value="In Batch No"/>
                             <h:inputText id="invbatchno" value="#{fibreAction.invbatchno}" style="width: 80px;height:22px;border:1px;border-color: blue"/>
                             <h:outputText value="Out Batch No"/>
                             <h:inputText id="outvbatchno" value="#{fibreAction.outvbatchno}" style="width: 80px;height:22px;border:1px;border-color: blue"/>
                             <h:outputText value="Locattion"/>
                             <h:inputText id="invlocation" value="#{fibreAction.invlocation}" style="width: 80px;height:22px;border:1px;border-color: blue"/>
                             <h:outputText value="grade"/>
                             <h:inputText id="grade" value="#{fibreAction.grade}" style="width: 20px;height:22px;border:1px;border-color: blue"/>
                             <h:outputText value="length"/>
                             <h:inputText id="deliverLenghth" value="#{fibreAction.deliverLenghth}" style="width: 20px;height:22px;border:1px;border-color: blue"/>
                             <p/>
                             <h:outputText value="pmd("/>
                             <h:inputText id="pmdup" value="#{fibreAction.pmdup}" style="width: 20px;height:22px;border:1px;border-color: blue"/>
                             <h:outputText value="--"/>
                             <h:inputText id="pmddown" value="#{fibreAction.pmddown}" style="width: 20px;height:22px;border:1px;border-color: blue"/>
                             <h:outputText value=")"/>
                             &#160;&#160;&#160;
                             <h:outputText value="total("/>
                             <h:inputText id="totalup" value="#{fibreAction.totalup}" style="width: 20px;height:22px;border:1px;border-color: blue"/>
                             <h:outputText value="--"/>
                             <h:inputText id="totaldown" value="#{fibreAction.totaldown}" style="width: 20px;height:22px;border:1px;border-color: blue"/>
                                <h:outputText value=")"/>
                        </div>
                        
                     </fieldset>
                     </a:form>
                
            </div>
            <div class="section">
            <a:outputPanel id="searchResults" style="overflow:auto" layout="none">
            
                 <h:outputText value="no record" rendered="#{fibres == null || fibres.rowCount==0}"/>
                 <a:form>
                 
                 <rich:dataTable id="fibresid" value="#{fibres}" var="wfibre" rows="#{fibreAction.pageSize}" 
                            style="width:100%" rendered="#{fibres.rowCount>0}">
                      <rich:column>
                           <f:facet name="header">Fibre No</f:facet>
                           #{wfibre.fibreNo}
                      </rich:column>
                      <rich:column>
                           <f:facet name="header">Type</f:facet>
                           #{wfibre.fibreType}
                      </rich:column>
                      <rich:column>
                           <f:facet name="header">Grade</f:facet>
                           #{wfibre.grade}
                      </rich:column>
                      <rich:column>
                           <f:facet name="header">Item</f:facet>
                           #{wfibre.item.itemno}
                      </rich:column>
                      <rich:column>
                           <f:facet name="header">Delivery Length</f:facet>
                           #{wfibre.deliverLenghth}
                      </rich:column>
                      <rich:column>
                           <f:facet name="header">Sales Length</f:facet>
                           #{wfibre.salesLenght}
                      </rich:column>
                      
                      <rich:column>
                           <f:facet name="header">In Batch</f:facet>
                           #{wfibre.receiveNo}
                      </rich:column>
                      <rich:column>
                           <f:facet name="header">Att_1525</f:facet>
                           #{wfibre.att_1525}
                      </rich:column>
                      <rich:column>
                           <f:facet name="header">disp_1545</f:facet>
                           #{wfibre.disp_1545}
                      </rich:column>
                      <rich:column>
                           <f:facet name="header">total</f:facet>
                           #{wfibre.total}
                      </rich:column>
                      <rich:column>
                           <f:facet name="header">rds</f:facet>
                           #{wfibre.rds}
                      </rich:column>
                      <rich:column>
                           <f:facet name="header">pmd</f:facet>
                           #{wfibre.pmd}
                      </rich:column>
                      <rich:column>
                           <f:facet name="header">length</f:facet>
                           #{wfibre.length}
                      </rich:column>
                      <rich:column>
                           <f:facet name="header">Match Status</f:facet>
                           #{wfibre.status}
                      </rich:column>
                      <rich:column>
                           <f:facet name="header">Inv Status</f:facet>
                           #{wfibre.invStatus}
                      </rich:column>
                      
                      <rich:column>
                           <f:facet name="header">Locattion</f:facet>
                           #{wfibre.location}
                      </rich:column>
                      <rich:column>
                           <f:facet name="header">Match Batch No</f:facet>
                           #{wfibre.selBatch}
                      </rich:column>
                      <rich:column>
                           <f:facet name="header">In Batch</f:facet>
                           #{wfibre.inBatch}
                      </rich:column>
                      <rich:column>
                           <f:facet name="header">Out Batch No</f:facet>
                           #{wfibre.outBatch}
                      </rich:column>
                      <rich:column>
                           <f:facet name="header">Return Comfirm</f:facet>
                           <a:commandButton value="Comfirm"  reRender="panel" ajaxSingle="true" rendered="#{wfibre.invStatus==9}"
                                  action="#{fibreAction.selectEditFibre}" oncomplete="Richfaces.showModalPanel('panel')"/>
                      </rich:column>
                      <f:facet name="footer">
                           <rich:datascroller pageIndexVar="pageIndex" pagesVar="pages" >
                           
                                <f:facet name="previous">     
                                     <h:outputText value="last"/>               
                                </f:facet>
                                <f:facet name="pages">
                                     <h:outputText value="No#{pageIndex}page/total#{pages}page"></h:outputText>
                                </f:facet>
                                <f:facet name="next">               
                                     <h:outputText value="next"/>               
                                </f:facet>
                           </rich:datascroller>
                      </f:facet>
                 </rich:dataTable>
                 
                 </a:form>
                 
            </a:outputPanel>
            </div>
            
                <rich:modalPanel id="panel" autosized="true">
                    <f:facet name="header">
                        <h:panelGroup>
                            <h:outputText value="In Comfirm"></h:outputText>
                        </h:panelGroup>
                    </f:facet>
                    <f:facet name="controls">
                        <h:panelGroup>
                            <h:graphicImage value="../../../public/images/tab-close.gif" style="cursor:pointer" id="hidelink"/>
                            <rich:componentControl for="panel" attachTo="hidelink" operation="hide" event="onclick"/>
                        </h:panelGroup>
                    </f:facet>
                    <a:form id="editfibre">
                    
                      
                    <h:panelGrid columns="2" columnClasses="dLeft, dRight" width="100%">
                      <h:panelGroup>
                        <h:panelGrid columns="2" columnClasses="tLeft, tRight" width="100%">
                           <h:outputLabel value="Fibre No:"/>
                           <h:outputText value="#{fibreAction.editFibre.fibreNo}" />
                           </h:panelGrid>
                      </h:panelGroup>
                      <h:panelGroup>
                        <h:panelGrid columns="2" columnClasses="tLeft, tRight" width="100%">
                           <h:outputLabel value="Type:"/>
                           <h:outputText value="#{fibreAction.editFibre.fibreType}" />
                           </h:panelGrid>
                      </h:panelGroup>
                      <h:panelGroup>
                        <h:panelGrid columns="2" columnClasses="tLeft, tRight" width="100%">
                           <h:outputLabel value="D-Length:"/>
                           <h:inputText value="#{fibreAction.editFibre.deliverLenghth}" />
                           </h:panelGrid>
                      </h:panelGroup>
                      <h:panelGroup>
                        <h:panelGrid columns="2" columnClasses="tLeft, tRight" width="100%">
                           <h:outputLabel value="total:"/>
                           <h:inputText value="#{fibreAction.editFibre.total}" />
                           </h:panelGrid>
                      </h:panelGroup>
                      <h:panelGroup>
                        <h:panelGrid columns="2" columnClasses="tLeft, tRight" width="100%">
                           <h:outputLabel value="pmd:"/>
                           <h:inputText value="#{fibreAction.editFibre.pmd}" />
                           </h:panelGrid>
                      </h:panelGroup>
                      <h:panelGroup>
                        <h:panelGrid columns="2" columnClasses="tLeft, tRight" width="100%">
                           <h:outputLabel value="Length"/>
                           <h:inputText value="#{fibreAction.editFibre.length}" />
                           </h:panelGrid>
                      </h:panelGroup>
                      <h:panelGroup>
                        <h:panelGrid columns="2" columnClasses="tLeft, tRight" width="100%">
                           <h:outputLabel value="Sale Length:"/>
                           <h:inputText value="#{fibreAction.editFibre.salesLenght}"  converterMessage="SalesLength Invalidation"/>
                           </h:panelGrid>
                      </h:panelGroup>
                      <f:facet name="footer">
                      <h:panelGroup>
                              <a:commandButton value="submit" action="#{fibreAction.editFibre}" oncomplete="Richfaces.hideModalPanel('panel');" reRender="searchResults" />
                              <a:commandButton value="reject" action="#{fibreAction.rejectFibre}" oncomplete="Richfaces.hideModalPanel('panel')" reRender="searchResults" />
                              <input type="button" value="cancel" onclick="#{rich:component('panel')}.hide()"/>
                       </h:panelGroup>
                       </f:facet>
                    </h:panelGrid> 
                    </a:form>
                </rich:modalPanel>
                <rich:modalPanel id="panel1" autosized="true">
                    <f:facet name="header">
                        <h:panelGroup>
                            <h:outputText value="Fibre Import"></h:outputText>
                        </h:panelGroup>
                    </f:facet>
                    <f:facet name="controls">
                        <h:panelGroup>
                            <h:graphicImage value="../../../public/images/tab-close.gif" style="cursor:pointer" id="hidelink1"/>
                            <rich:componentControl for="panel1" attachTo="hidelink1" operation="hide" event="onclick"/>
                        </h:panelGroup>
                    </f:facet>
                    <a:form id="fibredatain" >
                    <h:panelGrid columns="2" columnClasses="dLeft, dRight" width="100%">
                      <h:panelGroup>
                        <h:panelGrid columns="2" columnClasses="tLeft, tRight" width="100%">
                           <h:outputLabel value="Fibre Select Batch:"/>
                           <h:inputText value="#{fibreAction.fibreSelectNo}" />
                           </h:panelGrid>
                      </h:panelGroup>
                      
                      <f:facet name="footer">
                      <h:panelGroup>
                              <a:commandButton value="Submit" action="#{fibreAction.importFibre}" onclick="Richfaces.hideModalPanel('panel1')" reRender="searchResults" />
                              <input type="button" value="Cancel" onclick="Richfaces.hideModalPanel('panel1')"/>
                       </h:panelGroup>
                       </f:facet>
                    </h:panelGrid> 
                    </a:form>
                </rich:modalPanel>
            
            
            </ui:define>
            
            </ui:composition>
            
            



            All the things work well. But when i navigate to other page i can trace the factory function preform.All like this stage is same problem.

            • 3. Re: why do the @Factory menthod preform again while leaving a page?
              gjeudy

              Can you please make a bit of effort of showing only relevant code samples to the problem ? You are lucky someone helps you at all, dumping your whole code will not make you friends.


              It looks like an improper use of Factory annotation. Please read up some Seam doc.


              Your code:


              @Factory
                   public void getFibres()
                   {
                        
                        queryFibres();
                   }
              



              Seam doc:


              4.8 Factory and manager components

              • 4. Re: why do the @Factory menthod preform again while leaving a page?
                alin.heyoulin.qq.com
                It is correct use
                
                I found the problem.
                
                When i change
                
                <h:outputText value="no record" rendered="#{fibres == null || fibres.rowCount==0}"/>
                <a:form>
                
                to
                
                <a:form>
                <h:outputText value="no record" rendered="#{fibres == null || fibres.rowCount==0}"/>
                
                the problem is going. 
                
                Factory variable must inner Form?
                
                is bug?