2 Replies Latest reply on Jul 22, 2008 8:33 PM by Francisco Jose Peredo Noguez

    DataModel outjecting the very first value instead of selected one

    Syed Muhammad Ali Naqvi Newbie

      I am using two action classes both with Event Scope. I am sending you the code of the classes please take a look at it and see if u can save the problem


      LocationFactory.java


      This is the class in which I have DataModelSelection


      @Name("locationFactory")
      @Scope(ScopeType.EVENT)
      public class LocationFactory {
      
           @In(create = true) SalesPersonActionBean salesPersonAction;
           @In(create = true) LocationService locationService;
           @In(create = true, required = false) CustomerActionFactory customerActionFactory;
           
           @DataModel
           private List<Locations> lstLocations;
           @DataModelSelection("lstLocations")
           @Out(required = false, scope=ScopeType.SESSION)
           Locations location;
           
           UIDatascroller locationDatascroller;
           
           @SuppressWarnings("unchecked")
           @Factory(value = "lstLocations")
           public void listLocations() {
                int locationsPageFirstIndex;
                List listLocationSubSetRecords;          
                Long locationCount;
                java.util.Vector locationsVector = new Vector();
      
                locationCount = locationService
                          .getLocationRowCount(customerActionFactory.getCustomerWrapper()
                                    .getCustomers().getCustomerNumber());
      
                locationsVector.setSize(locationCount.intValue());
                
                // This statement fetches the current pages first row index
                
                locationsPageFirstIndex = (this.getLocationDatascroller().getPage() * 
                          this.getLocationDatascroller().getDataTable().getRows()) - 
                          this.getLocationDatascroller().getDataTable().getRows();
                
                
                listLocationSubSetRecords = locationService.getLocations(
                          salesPersonAction.getLocationOrderField(), salesPersonAction
                                    .isAscendingOrder(), locationsPageFirstIndex,
                          customerActionFactory.getCustomerWrapper().getCustomers()
                                    .getCustomerNumber());
      
                for (int index = 0; index < listLocationSubSetRecords.size(); index++) {
                     locationsVector.set(locationsPageFirstIndex + index,
                               listLocationSubSetRecords.get(index));
                }
      
                lstLocations = locationsVector;
           }
           
           public void nullLocationList(){
                this.lstLocations = null;
           }
      
           public List<Locations> getLstLocations() {
                return lstLocations;
           }
      
           public void setLstLocations(List<Locations> lstLocations) {
                this.lstLocations = lstLocations;
           }
      
           public UIDatascroller getLocationDatascroller() {
                return locationDatascroller;
           }
      
           public void setLocationDatascroller(UIDatascroller locationDatascroller) {
                this.locationDatascroller = locationDatascroller;
           }
      
           public Locations getLocation() {
                return location;
           }
      
           public void setLocation(Locations location) {
                this.location = location;
           }
      }



      LocationPrinterFactory.java



      @Name("locationPrinterFactory")
      @Scope(ScopeType.EVENT)
      
      public class LocationPrinterFactory {
           
           @In(create = true)LocationPrinterService locationPrinterService;
           @In(create = true, required = false)LocationFactory locationFactory;
           @DataModel private List<Locationprinters> lstLocationPrinters;
           
           UIDatascroller locationPrinterDatascroller;
           
           @SuppressWarnings("unchecked")
           @Factory("lstLocationPrinters")
           public void listLocationPrinters() {
                Long locationPrinterCount;
                Vector locationPrintersVector = new Vector();
                
                int locationPrinterCurrentPageIndex;
                int locationPrintersPageFirstIndex;
                List listLocationPrintersSubSetRecords;
      
                
      *System.out.println("this.this.locationFactory.getLocation().getLocationName(): " + this.locationFactory.getLocation().getLocationName());
      System.out.println("this.locationFactory.getLocation.getLocationNumber: " + this.locationFactory.getLocation().getLocationNumber());*
      
                
                locationPrinterCount = locationPrinterService
                          .getlocationPrinterRowCount(this.locationFactory.getLocation().getLocationNumber());
      
                locationPrintersVector.setSize(locationPrinterCount.intValue());
      
                
                // This statement fetches the current pages first row index
                locationPrintersPageFirstIndex = (this.locationPrinterDatascroller.getPage() *
                          this.locationPrinterDatascroller.getDataTable().getRows()) - 
                          this.locationPrinterDatascroller.getDataTable().getRows();
                
                listLocationPrintersSubSetRecords = locationPrinterService
                          .getLocationPrinter(locationPrintersPageFirstIndex,
                                    this.locationFactory.getLocation().getLocationNumber());
      
                for (int index = 0; index < listLocationPrintersSubSetRecords.size(); index++) {
                     locationPrintersVector.set(locationPrintersPageFirstIndex + index,
                               listLocationPrintersSubSetRecords.get(index));
                }
      
                lstLocationPrinters = locationPrintersVector;
           }
      
           public List<Locationprinters> getLstLocationPrinters() {
                return lstLocationPrinters;
           }
      
           public void setLstLocationPrinters(List<Locationprinters> lstLocationPrinters) {
                this.lstLocationPrinters = lstLocationPrinters;
           }
      
           public UIDatascroller getLocationPrinterDatascroller() {
                return locationPrinterDatascroller;
           }
       
           public void setLocationPrinterDatascroller(
                     UIDatascroller locationPrinterDatascroller) {
                this.locationPrinterDatascroller = locationPrinterDatascroller;
           }
                
           public void nullLocationPrinter(){
                this.lstLocationPrinters = null;
           }     
      }



      I am trying to access the DataModelSelection in LocationPrinterFactory class but it always print me the very first value.


      Someone from this forum said that his/her problem was solved by updating jsf jar files. But I am still having that problem. So Please answer A.S.A.P