1 Reply Latest reply on Jun 16, 2010 4:24 AM by Thomas Jonsson

    Regarding two seam component sessions

    Venkatesh K Newbie

      I have two screens one displays all the parties and in another screen im going to select those parties
      first screen is as follows



      <!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"
          xmlns:a="http://richfaces.org/a4j"
          xmlns:a4j="http://richfaces.org/a4j"
          template="../layout/template.xhtml">
      
      <ui:define name="body">
             
      
             
              <div  class="scroll">
                      <rich:extendedDataTable  id="partyListTable" var="_party" rows="20" reRender="ds"
                                      selectionMode="single" height="572px" width="1905px" selectedClass="selection"
                              value="#{parties}" rowKeyVar="row"
                              rendered="#{parties.rowCount > 0}" headerClass="head">
      
                              <f:facet name="header">#{messages['com.infyz.toms.entity.Customer']} #{messages['com.infyz.toms.properties.Registration']}</f:facet>
                           
                              <rich:column width="25px">
                                      <s:link ajaxSingle="true" id="editlink"
                                                      action="#{partyAction.selectParty}"
                                                      view="/admin_configuration_ordermanagement/IcPartyEdit.xhtml"
                                                      rendered="#{s:hasRole(messages['com.infyz.toms.role.admin.configuration.cargo_operations.party.edit']) and (empty from)}">
                                                      <h:graphicImage value="#{messages['com.infyz.toms.label.button.Edit']}" style="border:0" />
                                              </s:link>
                                              <rich:toolTip for="editlink" value="#{messages['com.infyz.toms.label.button.tooltip.Edit']}" />
                              #{' '}
                              <s:link view="/#{empty from ? '' : from}.xhtml"
                                      propagation="#{empty from ? 'none' : 'default'}"
                                      rendered="#{!empty from}"
                                      action="#{partyAction.selectParty}"
                              id="party">
                              <h:graphicImage value="#{messages['com.infyz.toms.label.button.Select']}" style="border:0" length="15" width="15"/>
                              <f:param name="partyName" value="#{_party.partyName}"/>
                              
                              </s:link>
                              <rich:toolTip for="party" value="#{messages['com.infyz.toms.label.button.tooltip.Select']}"/>
                                      </rich:column>
                                      
                              <rich:column id="partyNumber" width="150px" sortable="true" 
                                              sortBy="#{_party.partyNumber}" 
                                              filterBy="#{_party.partyNumber}" 
                                              filterEvent="onkeyup" label=" #{messages['com.infyz.toms.properties.Customer_code']}">
                                      <f:facet name="header">
                                              <h:outputText styleClass="headerText" value=" #{messages['com.infyz.toms.properties.Customer_code']}"/>
                                  </f:facet>            
                                              <h:outputText value="#{_party.partyNumber}"/>
                              </rich:column>    
                              
                              <rich:column id="partyName" width="170px" sortable="true" 
                                              sortBy="#{_party.partyName}" 
                                              filterBy="#{_party.partyName}" 
                                              filterEvent="onkeyup" label="#{messages['com.infyz.toms.properties.Customer_name']}">
                              <f:facet name="header">
                                              <h:outputText styleClass="headerText" value=" #{messages['com.infyz.toms.properties.Customer_name']}"/>
                                      </f:facet>
                                              <h:outputText value="#{_party.partyName}"/>
                              </rich:column>
                           
                              <rich:column id="taxId" width="110px" sortable="true" 
                                              sortBy="#{_party.taxId}" 
                                              filterBy="#{_party.taxId}" 
                                              filterEvent="onkeyup" label="#{messages['com.infyz.toms.properties.Tax_id']}">
                                      <f:facet name="header">
                                              <h:outputText styleClass="headerText" value=" #{messages['com.infyz.toms.properties.Tax_id']}"/>
                                  </f:facet>            
                                              <h:outputText value="#{_party.taxId}"/>
                              </rich:column>    
                           
                              <rich:column id="address1" width="185px" sortable="true" 
                                              sortBy="#{_party.address1}" 
                                              filterBy="#{_party.address1}" 
                                              filterEvent="onkeyup" label="#{messages['com.infyz.toms.properties.Address1']}">
                              <f:facet name="header">
                                              <h:outputText styleClass="headerText" value=" #{messages['com.infyz.toms.properties.Address1']}"/>
                                      </f:facet>
                                              <h:outputText value="#{_party.address1}"/>
                              </rich:column>
                           
                              <rich:column id="address2" width="170px" sortable="true" 
                                              sortBy="#{_party.address2}" 
                                              filterBy="#{_party.address2}" 
                                              filterEvent="onkeyup" label="#{messages['com.infyz.toms.properties.Address2']}">
                              <f:facet name="header">
                                              <h:outputText styleClass="headerText" value=" #{messages['com.infyz.toms.properties.Address2']}"/>
                                      </f:facet>
                                              <h:outputText value="#{_party.address2}"/>
                              </rich:column>
                           
                              <rich:column id="address3" width="170px" sortable="true" 
                                              sortBy="#{_party.address3}" 
                                              filterBy="#{_party.address3}" 
                                              filterEvent="onkeyup" label="#{messages['com.infyz.toms.properties.Address3']}">
                              <f:facet name="header">
                                              <h:outputText styleClass="headerText" value=" #{messages['com.infyz.toms.properties.Address3']}"/>
                                      </f:facet>
                                              <h:outputText value="#{_party.address3}"/>
                              </rich:column>
                           
                              <rich:column id="city" width="170px" sortable="true" 
                                              sortBy="#{_party.icCity.code}" 
                                              filterBy="#{_party.icCity.code}" 
                                              filterEvent="onkeyup" label=" #{messages['com.infyz.toms.properties.City']}">
                              <f:facet name="header">
                                              <h:outputText styleClass="headerText" value=" #{messages['com.infyz.toms.properties.City']}"/>
                                      </f:facet>
                                              <h:outputText value="#{_party.icCity.code}"/>
                              </rich:column>
                           
                              <rich:column id="state" width="170px" sortable="true" 
                                              sortBy="#{_party.icState.code}" 
                                              filterBy="#{_party.icState.code}" 
                                              filterEvent="onkeyup" label="#{messages['com.infyz.toms.properties.State']}">
                              <f:facet name="header">
                                              <h:outputText styleClass="headerText" value=" #{messages['com.infyz.toms.properties.State']}"/>
                                      </f:facet>
                                              <h:outputText value="#{_party.icState.code}"/>
                              </rich:column>
                           
                              <rich:column id="country" width="170px" sortable="true" 
                                              sortBy="#{_party.icCountry.countryCode}" 
                                              filterBy="#{_party.icCountry.countryCode}" 
                                              filterEvent="onkeyup" label="#{messages['com.infyz.toms.entity.Country']}">
                              <f:facet name="header">
                                              <h:outputText styleClass="headerText" value=" #{messages['com.infyz.toms.entity.Country']}"/>
                                      </f:facet>
                                              <h:outputText value="#{_party.icCountry.countryCode}"/>
                              </rich:column>
                           
                              <rich:column id="zipCode" width="170px" sortable="true" 
                                              sortBy="#{_party.zipCode}" 
                                              filterBy="#{_party.zipCode}" 
                                              filterEvent="onkeyup" label="#{messages['com.infyz.toms.properties.Zip_code']}">
                              <f:facet name="header">
                                              <h:outputText styleClass="headerText" value=" #{messages['com.infyz.toms.properties.Zip_code']}"/>
                                      </f:facet>
                                              <h:outputText value="#{_party.zipCode}"/>
                              </rich:column>
                           
                              <rich:column id="comments" width="175px" sortable="true" 
                                              sortBy="#{_party.comments}" 
                                              filterBy="#{_party.comments}" 
                                              filterEvent="onkeyup" label="#{messages['com.infyz.toms.properties.Comments']}">
                              <f:facet name="header">
                                              <h:outputText styleClass="headerText" value=" #{messages['com.infyz.toms.properties.Comments']}"/>
                                      </f:facet>
                                              <h:outputText value="#{_party.comments}"/>
                              </rich:column>
                                              
                              <rich:column id="FActive" width="70px" sortable="true" 
                                              sortBy="#{_party.FActive}" label="#{messages['com.infyz.toms.properties.F_active']}"
                                              filterBy="#{_party.FActive}" filterEvent="onkeyup">
                                      <f:facet name="header">
                                              <h:outputText styleClass="headerText" value="#{messages['com.infyz.toms.properties.F_active']}"/>
                                      </f:facet>
                                              <h:outputText value="#{_party.FActive}"/>
                              </rich:column>            
                                      
                  </rich:extendedDataTable>
                      </div>
             
                    </h:form>
      </ui:define>
      
      </ui:composition>



      and it's seam component is as foolows



      @Stateful
      @Name("partyAction")
      @Scope(ScopeType.SESSION)
      @SuppressWarnings("unchecked")
      public class IcPartyAction implements IcPartyInterface {
      
              @PersistenceContext(type=PersistenceContextType.EXTENDED)
              private EntityManager em;
              
              @In
              private FacesMessages facesMessages;
              
              @In(create=true) 
              User user;
              
              @Logger
              private Log log;
              
              @In(required=false, create=true)
              private CurrentDate currentDate;
              
              @In(create=true)
              PartyTypeInterface partyTypeAction;
              
              private boolean managed;
              private int rows = 20;
              private int scrollerPage=1;
          
              @DataModel("parties")
          private List<IcParty> parties;
           
          @DataModelSelection("parties")
          @Out(value="party", required=false)
          @In(value="party", required=false)
          private IcParty selectedParty;    
      
              @Factory
          public void getParties()
          {
                      String qry = "select party from IcParty party order by party.partyName  asc ";
              parties = em.createQuery(qry).getResultList();
          }   
           
          @Begin(join=true, flushMode=FlushModeType.MANUAL)
          public void selectParty() {
               selectedParty = em.find(IcParty.class, selectedParty.getPartyId());
               managed = false;
          }
           
          public void setSelectedParty(IcParty selectedParty) {
              log.info("............................................................set :"+selectedParty);
                      this.selectedParty = selectedParty;
              }
           
          public IcParty getSelectedParty()
          {
             return selectedParty;
          }



      second screen is as follows




      <!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"
          xmlns:a4j="http://richfaces.org/a4j"
          template="../layout/template.xhtml">
      
      <ui:define name="body">
              
              <h:form>  
                      <rich:simpleTogglePanel switchType="ajax" headerClass="head">
                              <f:facet name="header" >Customer Visit Details</f:facet>
                              <table style="text-align: right;">
                                      <tr>
                                              <td>
                                                      <s:decorate id="number" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Customer_code']}</ui:define>
                                                              <h:inputText id="itNumber" disabled="true" size="15" value="#{party.partyNumber}"/>
                                                              <s:link value="#{messages['com.infyz.toms.label.Select']}" view="/admin_configuration_ordermanagement/IcPartyList.xhtml">
                                                   <f:param name="from" value="transportation_ocean/ItPartyVisitList"/>
                                              </s:link>
                                                      </s:decorate>
                                              </td>
                                              <td>
                                                      <s:decorate id="name" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Customer_name']}</ui:define>
                                                              <h:inputText id="itName" value="#{party.partyName}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                              <td>
                                                      <s:decorate id="group" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Customer_group']}</ui:define>
                                                              <h:inputText value="#{party.icPartyGroup.groupCode}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                      </tr>
                                      
                                      <tr>
                                              <td>
                                                      <s:decorate id="address1" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Address1']}</ui:define>
                                                              <h:inputText id="itAddress1" size="30" value="#{party.address1}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                              <td>
                                                      <s:decorate id="address2" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Address2']}</ui:define>
                                                              <h:inputText id="itAddress2" size="30" value="#{party.address2}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                              <td>
                                                      <s:decorate id="city" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.City']}</ui:define>
                                                              <h:inputText value="#{party.icCity.code}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                      </tr>
                                      
                                      <tr>
                                              <td>
                                                      <s:decorate id="state" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.State']}</ui:define>
                                                              <h:inputText value="#{party.icState.code}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                              <td>
                                                      <s:decorate id="country" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Country']}</ui:define>
                                                              <h:inputText value="#{party.icCountry.countryCode}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                              <td>
                                                      <s:decorate id="zip" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Zip_code']}</ui:define>
                                                              <h:inputText id="itZip" value="#{party.zipCode}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                      </tr>     
                                              
                                      <tr>
                                              <td>
                                                      <s:decorate id="contactPerson" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Contact_person']}</ui:define>
                                                              <h:inputText id="itContactPerson" value="#{party.contactPerson}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                              <td>
                                                      <s:decorate id="tph1" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Telephone_one']}</ui:define>
                                                              <h:inputText id="itTph1" size="15" value="#{party.telephoneNo1}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                              <td>
                                                      <s:decorate id="tph2" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Telephone_two']}</ui:define>
                                                              <h:inputText id="itTph2" size="15" value="#{party.telephoneNo2}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                      </tr>     
                                              
                                      <tr>
                                              <td>
                                                      <s:decorate id="mb1" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Mobile_one']}</ui:define>
                                                              <h:inputText id="itMb1" size="10" value="#{party.mobileNo1}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                              
                                              <td>
                                                      <s:decorate id="mb2" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Mobile_two']}</ui:define>
                                                              <h:inputText id="itMb2" size="10" value="#{party.mobileNo2}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                              <td>
                                                      <s:decorate id="natureOfBusiness" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Nature_of_business']}</ui:define>
                                                              <h:inputText value="#{party.icBusinessType.code}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                      </tr>
                                      
                                      <tr>
                                              <td>
                                                      <s:decorate id="emailId" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Email_id']}</ui:define>
                                                              <h:inputText id="itEmailId" size="30" value="#{party.emailId}" disabled="true">
                                                              </h:inputText>
                                                      </s:decorate>
                                              </td>
                                              <td>
                                                      <s:decorate id="businessVolumePa" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Business_volume_pa']}</ui:define>
                                                              <h:inputText id="itBusinessVolumePa" size="15" value="#{party.businessVolumePa}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                              
                                      </tr>     
                                                              
                                      <tr style="text-align:left;color:#3090C7;">
                                              <td>
                                                      <h3 class="section">Financial Details :</h3>
                                              </td>
                                      </tr>
                                              
                                      <tr>
                                              
                                              <td>
                                                      <s:decorate id="pan" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Pan_num']}</ui:define>
                                                              <h:inputText id="itPan" value="#{party.panNumber}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                              <td>
                                                      <s:decorate id="tan" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Tan_num']}</ui:define>
                                                              <h:inputText id="itTan" value="#{party.tanNumber}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                              <td>
                                                      <s:decorate id="bankAc" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Bank_account_num']}</ui:define>
                                                              <h:inputText id="itBankAc" value="#{party.bankAccountNumber}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                      </tr>                             
                                              
                                      <tr>
                                              <td>
                                                      <s:decorate id="bankName" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Bank_name']}</ui:define>
                                                              <h:inputText value="#{party.icBank.bankName}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                              <td>
                                                      <s:decorate id="branch" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Branch']}</ui:define>
                                                              <h:inputText id="itBranch" value="#{party.branch}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                              <td>
                                                      <s:decorate id="ifsc" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.IFSC_code']}</ui:define>
                                                              <h:inputText id="itIfsc" size="15" disabled="true"   value="#{party.ifsc}"/>
                                                      </s:decorate>
                                              </td>
                                      </tr>     
                                              
                                      <tr>
                                              <td>
                                                      <s:decorate id="rtgs" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Rtgs_code']}</ui:define>
                                                              <h:inputText id="itRtgs" size="15" disabled="true" value="#{party.rtgsCode}"/>
                                                      </s:decorate>
                                              </td>
                                              <td>
                                                      <s:decorate id="paymentTerms" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Payment_terms']}</ui:define>
                                                              <h:inputText value="#{party.icTerms.number}" disabled="true"/>
                                                      </s:decorate>
                                              </td>
                                      </tr>
                                              
                              </table>
                              <h:panelGrid columns="1" style="text-align:right;">
                                      <s:decorate id="comments" template="../layout/edit.xhtml">
                                                              <ui:define name="label">#{messages['com.infyz.toms.properties.Aditional_info']}</ui:define>
                                                              <h:inputTextarea id="itaComments" cols="72" rows="2" value="#{party.comments}" disabled="true"/>
                                                      </s:decorate>
                              </h:panelGrid>            
                      </rich:simpleTogglePanel></ui:define>
      </ui:composition>



      and it's seam component is




      @Stateful
      @Name("itPartyVisitAction")
      @Scope(ScopeType.SESSION)
      public class ItPartyVisitAction implements ItPartyVisitInterface{
              
              @PersistenceContext(type = PersistenceContextType.EXTENDED)
              private EntityManager em;
              
              @Logger
              private Log log;
              
              @In
              private FacesMessages facesMessages;
               
              @In(create=true,required=false)
              private SimpleQueueSender messageSender;
              
              @In(create=true)
              private IcPartyInterface partyAction;
              
              @DataModel("partyVisit")
              private List<ItPartyVisit> partyVisit;
              
              @DataModelSelection("partyVisit")
              @Out(required = false)
              private ItPartyVisit selectedPartyVisit;
              
              public List<ItPartyVisit> getPartyVisit() {
                      return partyVisit;
              }
              
              public ItPartyVisit getSelectedPartyVisit() {
                      return selectedPartyVisit;
              }
              
              public void addNewParty()
              {
                      partyAction.setSelectedParty(new IcParty());
                      log.info(".................................................................."+partyAction.getSelectedParty());
              }}



      in first screen because of factory all the parties will be loaded it's fine when i first open this screen and then if i move to second screen first party is taken as selected party defaultly but i don't need this when i move to second screen it should be blank if i selected using link then only they have to be populated for that i am calling the addNewParty method of partyVisit when i click the menuitem which opens the second screen





      <rich:menuItem submitMode="ajax" value="Customer Visit" action="#{itPartyVisitAction.addNewParty}" 
                              onclick="document.location.href='http://192.168.1.12:8080/toms/transportation_ocean/ItPartyVisitList.seam'"/>





      but im not succeded
      thank you in advance