5 Replies Latest reply on Aug 5, 2008 1:45 PM by Alexander Torstling

    Action class is getting called eachtime

    Bala Puli Newbie

      Hi,
      This is Balu. In my new project I am integrating ICEFaces with JBoss Seam. My problem is, In my view I had whole bunch of fields with selectInputDate and selectOneMenu and all. While loading page I am filling all the selectOneMenu controls. It is just data entry page. For entering date, once I click on Calender it is calling all the list methods in my action class . once i select the date it is calling all the list methods in my action class. All those methods are calling more than once each field in the form i tried to enter data. Because of this my application had very poor performance. Please help me in this. I appriciate your response.
      Thanks,
      Balu.

        • 1. Re: Action class is getting called eachtime
          Daniel Roth Apprentice

          Post some code. xhtml + action bean.

          • 2. Re: Action class is getting called eachtime
            judy guglielmin Novice

            See the icefaces example in the Seam distribution.....the book.xhtml page has all of these things already and you can use this as an example.

            • 3. Re: Action class is getting called eachtime
              Bala Puli Newbie
              Hi Daniel,
              Thanks for your reply.
              Following are my .xhtml and action classes.

              <ice:panelGroup style="clear: center;"
                   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" xml:lang="en" lang="en"
                   xmlns:ice="http://www.icesoft.com/icefaces/component"
                   xmlns:s="http://jboss.com/products/seam/taglib"
                   xmlns:c="http://java.sun.com/jstl/core" >


                        <div class="entry output" title="Messages">
                             <h:messages globalOnly="true"/>
                        </div>
                        <div id="addressFormPanel" style="width:100%" title="#{messages['patient.outRegisterHead']}">
                             <h1>#{messages['REGISTRATION_HEAD']}</h1>
                             <ice:panelGrid columns="8" style="width:100%" align="center">     
                                            <ice:outputLabel value="#{messages['FIRST_NAME']}" for="fName" styleClass="formLabel"/>
                                            <ice:inputText value="#{patient.firstName}" id="fName" required="true"/>
                                            <ice:outputLabel value="#{messages['LAST_NAME']}" for="lName" styleClass="formLabel"/>
                                            <ice:inputText value="#{patient.lastName}" id="lName" required="true"/>
                                       <ice:outputLabel value="#{messages['SEX']}" for="sex" styleClass="formLabel"/>
                                       <ice:selectOneRadio id="#{messages['SEX']}" value="#{patient.sex}" required="true">
                                            <f:selectItem itemValue="M" itemLabel="#{messages['MALE']}" />
                                            <f:selectItem itemValue="F" itemLabel="#{messages['FEMALE']}" />
                                       </ice:selectOneRadio>
                                            <ice:outputLabel value="#{messages['AGE']}" for="age" styleClass="formLabel"/>
                                            <ice:inputText value="#{patient.age}" id="age" />
                                            <ice:outputLabel value="#{messages['DOB']}" for="dob" styleClass="formLabel" required="true"/>
                                            <ice:selectInputDate id="dob" value="#{patient.dateOfBirth}" renderAsPopup="true" />
                                            <ice:outputLabel value="#{messages['MOBILE_NUMBER']}" for="mobileNumber" styleClass="formLabel"/>
                                            <ice:inputText value="#{patient.mobileNumber}" id="mobileNumber" />
                                       <ice:outputLabel value="#{messages['HOUSE_NUMBER']}" for="houseNumber" styleClass="formLabel"/>
                                       <ice:inputText value="#{patient.houseNumber}" id="houseNumber" />
                                            <ice:outputLabel value="#{messages['OFFICE_NUMBER']}" for="officeNumber" styleClass="formLabel"/>
                                            <ice:inputText value="#{patient.officeNumber}" id="officeNumber" />
                                            <ice:outputLabel value="#{messages['ADDRESS1']}" for="address1" styleClass="formLabel"/>
                                            <ice:inputText value="#{patient.address1}" id="address1" />
                                            <ice:outputLabel value="#{messages['ADDRESS2']}" for="address2" styleClass="formLabel"/>
                                            <ice:inputText value="#{patient.address2}" id="address2" />
                                            <ice:outputLabel value="#{messages['CITY']}" for="city" styleClass="formLabel"/>
                                            <ice:inputText value="#{patient.city}" id="city" />
                                            <ice:outputLabel value="#{messages['STATE']}" for="state" styleClass="formLabel"/>
                                            <ice:inputText value="#{patient.state}" id="state" />
                                            <ice:outputLabel value="#{messages['ZIP']}" for="zip" styleClass="formLabel"/>
                                            <ice:inputText value="#{patient.zip}" id="zip" />
                                            <ice:outputLabel value="#{messages['FAX_NUMBER']}" for="faxNumber" styleClass="formLabel"/>
                                            <ice:inputText value="#{patient.faxNumber}" id="faxNumber" />
                                            <ice:outputLabel value="#{messages['EMAIL']}" for="email" styleClass="formLabel"/>
                                            <ice:inputText value="#{patient.email}" id="email" />
                                            <ice:outputLabel value="#{messages['VISIT_STATUS']}" for="visitStatus" styleClass="formLabel" />
                                            <ice:selectOneMenu id="visitStatus" value="#{patientVisit.visitStatus}" >
                                                 <f:selectItem itemValue="W" itemLabel="#{messages['WALKIN']}" />
                                                 <f:selectItem itemValue="A" itemLabel="#{messages['APPOINTMENT']}" />
                                            </ice:selectOneMenu>
                                            <ice:outputLabel value="#{messages['PAYER']}" for="payer" styleClass="formLabel"/>
                                            <ice:selectOneMenu id="payer" value="#{patient.payer}" >
                                                 <f:selectItems value="#{registrationAction.partnersList}" />
                                            </ice:selectOneMenu>
                                            <ice:outputLabel value="#{messages['DOCTOR']}" for="doctor" styleClass="formLabel"/>
                                            <ice:selectOneMenu id="doctor" value="#{patientVisit.doctor}" >
                                                 <f:selectItems value="#{registrationAction.doctorList}" />
                                            </ice:selectOneMenu>
                                            <ice:outputLabel value="#{messages['REF_DOCTOR']}" for="refDoctor" styleClass="formLabel"/>
                                            <ice:selectOneMenu id="refDoctor" value="#{patientVisit.refDoctor}" >
                                                 <f:selectItems value="#{registrationAction.refDoctorList}" />
                                            </ice:selectOneMenu>
                                            <ice:outputLabel value="#{messages['OTHER_REFERAL']}" for="otherReferal" styleClass="formLabel"/>
                                            <ice:inputText value="#{patientVisit.otherReferal}" id="otherReferal" />
                                            <ice:outputLabel value="#{messages['VALID_FROM']}" for="validFrom" styleClass="formLabel"/>
                                            <ice:selectInputDate id="validFrom" value="#{registration.validFrom}" renderAsPopup="true" />
                                            <ice:outputLabel value="#{messages['VALID_UPTO']}" for="validUpto" styleClass="formLabel"/>
                                            <ice:selectInputDate id="validUpto" value="#{registration.validUpto}" renderAsPopup="true" />
                                            <ice:outputLabel value="#{messages['REQUESTED_DATE_TIME']}" for="requestedDateTime" styleClass="formLabel"/>
                                            <ice:selectInputDate id="requestedDateTime" value="#{patientVisit.requestedDateTime}" renderAsPopup="true" />
                                            <ice:outputLabel value="#{messages['ADMITED_DATE_TIME']}" for="admitedDateTime" styleClass="formLabel" />
                                            <ice:selectInputDate id="admitedDateTime" value="#{patientVisit.admitedDateTime}" renderAsPopup="true" />
                             </ice:panelGrid>
                        </div>
              </ice:panelGroup>


              ACTION CLASS

              package com.inc.irxes.action;

              import com.icesoft.faces.component.inputfile.InputFile;
              import com.inc.core.IncBUS;
              import com.inc.core.IncNumberRange;

              import java.awt.event.ActionEvent;
              import java.util.ArrayList;
              import java.util.Collections;
              import java.util.List;

              import org.apache.commons.collections.map.ListOrderedMap;
              import org.jboss.seam.ScopeType;
              import org.jboss.seam.annotations.In;
              import org.jboss.seam.annotations.Logger;
              import org.jboss.seam.annotations.Name;
              import org.jboss.seam.annotations.Scope;
              import org.jboss.seam.faces.FacesMessages;
              import javax.faces.model.SelectItem;

              import org.jboss.seam.log.Log;

              import com.inc.irxes.bo.PatientRegistrationObject;
              import com.inc.irxes.params.PatientParams;
              import com.inc.irxes.params.PatientVisitParams;
              import com.inc.irxes.params.RegistrationParams;
              import com.inc.irxes.params.VisitServiceParams;


              @Name("registrationAction")
              @Scope(ScopeType.PAGE)
              public class RegistrationAction {

                   @Logger
                   private static Log log;

                   @In(create=true)
                   private RegistrationParams registration;
                   @In(create=true)
                   private PatientParams patient;
                   @In(create=true)
                   private PatientVisitParams patientVisit;
                   @In(create=true)
                   private VisitServiceParams visitService;
                   @In(create=true)
                   private IncPartnerAction partnerAction;
                   @In(create=true)
                   private IncPersonnelAction personnelAction;
                   @In(create=true)
                   private PatientServicesAction patientServices;
                   @In
                   private IncMenuAction menuBar;
                   @In(create=true)
                   private VisitEquipmentsAction visitEquipmentAction;
                   
                   private boolean confirmFlag = false;
                   private List<SelectItem> doctorList;
                   private List<SelectItem> refDoctorList;
                   private List<SelectItem> partnersList = null;
                   
                   public List<SelectItem> getPartnersList()
                   {
                        if(partnersList==null)
                        {
                             List<ListOrderedMap> pList = null;
                             partnersList = new ArrayList<SelectItem>();
                             pList = partnerAction.getPartnerList();
                             
                             SelectItem s = null;
                             ListOrderedMap map = null;
                             for(int i=0;i<pList.size();i++)
                             {
                                  map = (ListOrderedMap)pList.get(i);
                                  s = new SelectItem();     
                                  s.setLabel((String)map.get("NAME"));
                                  s.setValue(((Integer)map.get("PARTNER_ID")).intValue());
                                  partnersList.add(s);
                             }
                        }
                        return partnersList;
                   }
                   
                   public List<SelectItem> getDoctorList()
                   {
                        doctorList = new ArrayList<SelectItem>();
                        refDoctorList = new ArrayList<SelectItem>();

                        List myList = null;
                        myList = personnelAction.getPersonnelList();
                        SelectItem s = null;
                        ListOrderedMap m = null;
                        String doctorType = null;
                        for(int i=0;i<myList.size();i++)
                        {
                             m = (ListOrderedMap)myList.get(i);
                             s = new SelectItem((Integer.parseInt((String)m.get("PER_ID"))), checkForNull((String)m.get("FIRST_NAME")) + " " + checkForNull((String)m.get("LAST_NAME")));
                             doctorType = (String)m.get("PERSON_TYPE");
                             if("CD".equals(doctorType) || "ID".equals(doctorType))
                                  doctorList.add(s);
                             else if("RD".equals(doctorType))
                                  refDoctorList.add(s);
                        }
                        return doctorList;
                   }
                   
                   public List<SelectItem> getRefDoctorList()
                   {
                        return refDoctorList;
                   }
                   
                   public String checkForNull(String str)
                   {

                        if(str==null || "null".equalsIgnoreCase(str))
                             str = "";
                        return str;
                   }
                   
                   private long getPresentVisitID()
                   {
                        long presentVisitID = 0;
                        
                        return presentVisitID;
                   }

                   public boolean isConfirmFlag() {
                        return confirmFlag;
                   }

                   public void setConfirmFlag(boolean confirmFlag) {
                        this.confirmFlag = confirmFlag;
                   }
              }

              Please help me.
              Thanks,
              Bala.
              • 4. Re: Action class is getting called eachtime
                Bala Puli Newbie

                Daniel Roth wrote on Jul 26, 2008 23:14:


                Post some code. xhtml + action bean.



                Hi Daniel,
                Could you please help me out.
                Thanks,
                Bala.

                • 5. Re: Action class is getting called eachtime
                  Alexander Torstling Newbie

                  Your behaviour is expected. JSF does this, google it. To prevent, use lazy loading or seam factories.