1 Reply Latest reply on May 4, 2009 1:25 PM by Juan Ignacio Sánchez Lara

    Null Session Action and Outjected variables

    Earnest Dyke Novice

      Ok, I have been trying to find out why the tsYear property and the outjected value are both null when the page is rendered.

      Here is the xhtml:

      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
           xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml">
           <ui:define name="body">
                  <td class="detailLabel"><h:outputText value="Select year" /></td>
                  <td class="detailData"><h:selectOneListbox id="tsYears"
                     value="#{TimesheetAction.tsYear}" size="1">
                     <a4j:support event="onchange"
                     action="#{TimesheetAction.loadTimesheetsForYear()}" />
                     <f:selectItem itemValue="" itemLabel="-- Select Year" />
                     <f:selectItems value="#{timesheetYears}" />
                <s:fragment rendered="#{tsYear!= null}">
                  <td class="detailLabel"><h:outputText
                       value="Select timesheet" /></td>
                  <td class="detailData"><h:selectOneListbox id="tsList"
                       value="#{TimesheetAction.ts}" size="3"
                       <a4j:support event="onchange"
                             action="#{TimesheetAction.loadEmployeeTimesheetView()}" />
                        <f:selectItem itemValue="" itemLabel="-- Select Timesheet" />
                     <f:selectItems value="#{timesheets}" />
                       <s:fragment rendered="#{TimesheetAction.viewable}" id="ts">
                  <table border="1" class="dr-table rich-table">
                    <thead class="dr-table-thead">
                       <th colspan="#{timesheetView.days}">Hello</th>
                      <tr class="dr-table-header rich-table-header">
                     <ui:repeat value="#{timesheetView.dates}" var="d">
                       <th class="dr-table-headercell rich-table-headercell"><h:outputText
                         value="#{d}" /></th>
                <h:outputText value="#{TimesheetAction.viewable}" />
                <rich:spacer width="50" />
                <h:outputText value="Year? #{tsYear}" />

      And the action:

      package org.ebsinc.admin.action;
      import static org.jboss.seam.ScopeType.SESSION;
      import java.io.Serializable;
      import java.text.SimpleDateFormat;
      import java.util.ArrayList;
      import java.util.List;
      import javax.faces.context.FacesContext;
      import javax.faces.model.SelectItem;
      import org.ebsinc.admin.entity.Employee;
      import org.ebsinc.admin.entity.EmployeeTimesheet;
      import org.ebsinc.admin.entity.Timesheet;
      import org.ebsinc.admin.entity.TimesheetView;
      import org.ebsinc.admin.session.TimesheetManager;
      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;
      public class TimesheetAction implements Serializable{
           private static final long serialVersionUID = 1l;
           @In(value = "TimesheetManager", create = true)
           TimesheetManager tsMgr;
           FacesContext facesContext;
           private Integer tsYear;
           private Timesheet ts;
           private TimesheetView timesheetView;
           private EmployeeTimesheet employeeTimesheet;
           Employee currentEmployee;
           private Boolean viewable;
           public TimesheetAction() {
                if (1==1) { }
           public void loadTimesheetView() {
                if (employeeTimesheet == null) {
                     employeeTimesheet = tsMgr.getTimesheet(currentEmployee, ts);
                timesheetView = tsMgr.getTimesheetView(employeeTimesheet);
           public String loadEmployeeTimesheetView() {
                return null;
           public EmployeeTimesheet getEmployeeTimesheet() {
                return employeeTimesheet;
           public void setEmployeeTimesheet(EmployeeTimesheet employeeTimesheet) {
                this.employeeTimesheet = employeeTimesheet;
           @In(required = false, scope = SESSION)
           @Out(scope = SESSION)
           private List<SelectItem> timesheetYears;
           public void getTimesheetYears() {
                List<SelectItem> l = new ArrayList<SelectItem>(10);
                List<Integer> yrs = tsMgr.getTimeSheetYears();
                for (Integer y : yrs) {
                     SelectItem si = new SelectItem(y.intValue(), y.toString());
                timesheetYears = l;
           @In(required = false, scope = SESSION)
           @Out(required = false, scope = SESSION)
           private List<SelectItem> timesheets;
           public String loadTimesheetsForYear() {
                List<SelectItem> l = new ArrayList<SelectItem>(26);
                if (tsYear == null) {
                     timesheets = l;
                     return null;
                List<Timesheet> timesheetsList = tsMgr.getTimesheets(tsYear);
                for (Timesheet ts : timesheetsList) {
                     SelectItem si = new SelectItem(ts, getTimesheetDateRange(ts));
                timesheets = l;
                return null;
           private String getTimesheetDateRange(Timesheet ts) {
                StringBuffer sb = new StringBuffer();
                SimpleDateFormat sdf = new SimpleDateFormat("d MMM");
                sb.append(" - ");
                sdf = new SimpleDateFormat("d MMM yyyy");
                return sb.toString();
           public Integer getTsYear() {
                return tsYear;
           public void setTsYear(Integer tsYear) {
                this.tsYear = tsYear;
           public Timesheet getTs() {
                return ts;
           public void setTs(Timesheet ts) {
                this.ts = ts;
                if (ts != null) {
                     viewable = true;
           public Boolean getViewable() {
                return viewable;
           public void setViewable(Boolean viewable) {
                this.viewable = viewable;

      I have stepped through the code and tsYear has a value in the action and seam.debug shows a value for tsYear in the session scope but it does not display on the page and the areas that are conditionally rendered based on it are not displayed.

      I have spent a day trying to figure this out and I am hoping another set of eyes will quickly see what I have overlooked.

      Thanks in advance for any and all help!