Problem with the blend of Event and Session scope
ali1983 Jun 23, 2008 9:22 AMI want to do binding of UIDatascroller with my UI. For this I have made two action classes of scope Event and Session. The Problem I am facing is that whenever I try to get value from Event Scope class in Session scope class I always get a null value although the variable in not null in Event scoped class.
Below is my Class with Event Scope
package com.pcounts.server.action.sp;
import java.util.List;
import java.util.Set;
import java.util.Vector;
import javax.faces.component.UIData;
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.datamodel.DataModel;
import org.richfaces.component.UIDataTable;
import org.richfaces.component.UIDatascroller;
import com.pcounts.server.action.auth.PCUserSession;
import com.pcounts.server.hibernate.pojo.Printerscans;
import com.pcounts.server.hibernate.service.GroupService;
import com.pcounts.server.hibernate.service.PrinterScansService;
import com.pcounts.server.hibernate.service.UserService;
@Name("factoryClass")
@Scope(ScopeType.EVENT)
public class FactoryClass {
@In(create = true) PrinterScansService printerScansService;
@In(create = true) GroupService groupService;
@In(create = true) PCUserSession pcUserSession;
@In(create = true) UserService userService;
@In(create = true) SalesPersonDashboardBean SalesPersonDashboard;
@DataModel
private List<Printerscans> lstPrinterscans;
UIDataTable dashboardDataTable;
UIDatascroller dashboardDataScroller;
@Factory("lstPrinterscans")
public void listPrinterscans() {
System.out.println("----- OrderField ----- "+ SalesPersonDashboard.orderField);
List listSubSetRecords;
List lstGroups;
Set setSPsOfGroups;
int pageFirstIndex;
Long count;
lstGroups = groupService.getGroupsForSP(pcUserSession.getUserNumber());
setSPsOfGroups = userService.getSPsFromSalesGroups(lstGroups);
count = printerScansService.getPrinterscanRowCount(userService
.getCSVUserNumber(setSPsOfGroups));
Vector vector = new Vector();
vector.setSize(count.intValue());
pageFirstIndex = (this.getDashboardDataScroller().getPage() * getDashboardDataScroller()
.getDataTable().getRows())
- this.getDashboardDataScroller().getDataTable().getRows();
listSubSetRecords = printerScansService.getPrinterscansOfSPs(
userService.getCSVUserNumber(setSPsOfGroups), SalesPersonDashboard.orderField,
SalesPersonDashboard.ascendingOrder, pageFirstIndex);
for (int index = 0; index < listSubSetRecords.size(); index++) {
vector.set(pageFirstIndex + index, listSubSetRecords.get(index));
}
lstPrinterscans = vector;
}
public void nullList(){
this.lstPrinterscans = null;
}
public UIDatascroller getDashboardDataScroller() {
return dashboardDataScroller;
}
public void setDashboardDataScroller(UIDatascroller dashboardDataScroller) {
this.dashboardDataScroller = dashboardDataScroller;
}
}And this is the class with Session Scope.
@Scope(ScopeType.SESSION)
@Name("SalesPersonDashboard")
public class SalesPersonDashboardBean {
@In(required = false)
FactoryClass factoryClass;
public boolean ascendingOrder;
public String orderField;
public void sortAction(String field) {
System.out.println("-----Field----- " + field);
// System.out.println("-----Ascending Order----- " + ascendingOrder);
this.ascendingOrder = !this.ascendingOrder;
this.orderField = field;
// System.out.println("-----order Field----- " + orderField);
// factoryClass.dashboardDataScroller.setPage(1);
// System.out.println("DataScroller Page: " + factoryClass.dashboardDataScroller.getPage());
factoryClass.listPrinterscans();
}And the output which I get in Console is
13:10:42,015 INFO [STDOUT] ----- OrderField ----- null 13:11:02,796 INFO [STDOUT] -----Field----- locations.locationName 13:11:02,812 INFO [STDOUT] ----- OrderField ----- null
I want to get non-null value of the SalesPersonDashboard.orderField and SalesPersonDashboard.ascendingOrder in pcFactory class
Please sort out this problem as soon as possible.
I'll be thankful to you.
Bye