title: Primefaces DataTable not updating after passing parameters between Managed Beans
body: <p>I'm currently working with Primefaces datatable with simple CRUD operations. This Datatable shows tasks of a work list that's selected previously in another datatable that show worklists of projects. To get the selected worklist, i inject the WorkListManagedBean into the TaskManagedBean. When i create or delete a task from the selected work list, it was done successfully in the database but the datatable is not updation :(. Here is my Task Managed Bean:</p>
  
  <pre><code>@ManagedBean(name = "taskMBean")
  @ViewScoped
  public class TaksMBean implements Serializable {
  
     @ManagedProperty("#{workListMBean}")
     private WorkListMBean workListMBean;
     @Inject
     private TaskBusinessLocal taskBusinessLocal;
     @Inject
     private ResourceBusinessLocal resourceBusinessLocal;
     private String description, code;
     private Date startDate, endDate;
     private Status status;
     private List&lt;Resource&gt; resources, resourceslist;
     private List&lt;Task&gt; filteredTasks, tasks;
     private Task selectedTask;
     private WorkList selectedWorkList;
  
     @PostConstruct
     public void init() {
       selectedTask = new Task();
       selectedWorkList = workListMBean.getSelectedWorkList();
      }
  
     public List&lt;Task&gt; getTasks() {
       return tasks=workListMBean.getTasksList();
      }
  
     public void setTasks(List&lt;Task&gt; tasks) {
       this.workListMBean.setTasks(tasks) ;
      }
  
      public List&lt;Resource&gt; getAllResources() {
       return resourceBusinessLocal.allResources();
      }
  
      public Status[] getAllStatus() {
       return Status.values();
      }
  
      public String addTask() {
        taskBusinessLocal.addTask(description, code, startDate,  
           endDate,status,    
         selectedWorkList, resources);
         return "index";
       }
  
      public String upDateTask() {
        taskBusinessLocal.updateTask(selectedTask);
        return "index";
       }
  
      public String deleteTask() {
        taskBusinessLocal.deleteTask(selectedTask);
        return "index";
       }
  
      public Status getStatus() {
        return status;
       }
  
      public void setStatus(Status status) {
        this.status = status;
       }
  
      public String getDescription() {
       return description;
       }
  
      public void setDescription(String description) {
        this.description = description;
       }
  
      public Date getStartDate() {
         return startDate;
       }
  
      public void setStartDate(Date startDate) {
          this.startDate = startDate;
       }
  
      public Date getEndDate() {
          return endDate;
       }
  
      public void setEndDate(Date endDate) {
         this.endDate = endDate;
       }
  
      public String getCode() {
       return code;
       }
  
      public void setCode(String code) {
       this.code = code;
       }
  
      public List&lt;Resource&gt; getResources() {
        return resources;
       }
  
      public void setResources(List&lt;Resource&gt; resources) {
        this.resources = resources;
       }
  
      public List&lt;Resource&gt; getResourceslist() {
        return resourceslist;
       }
  
      public void setResourceslist(List&lt;Resource&gt; resourceslist) {
        this.resourceslist = resourceslist;
       }
  
      public List&lt;Task&gt; getFilteredTasks() {
        return filteredTasks;
       }
  
      public void setFilteredTasks(List&lt;Task&gt; filteredTasks) {
       this.filteredTasks = filteredTasks;
       }
  
      public Task getSelectedTask() {
       return selectedTask;
       }
  
      public void setSelectedTask(Task selectedTask) {
        this.selectedTask = selectedTask;
       }
  
      public WorkListMBean getWorkListMBean() {
        return workListMBean;
       }
  
      public void setWorkListMBean(WorkListMBean workListMBean) {
       this.workListMBean = workListMBean;
       }
  
      public WorkList getSelectedWorkList() {
        return workListMBean.getSelectedWorkList();
      }
      }
  </code></pre>
  
  <p>and here is my JSF page:</p>
  
  <pre><code> &lt;ui:composition template="/templates/layout.xhtml"
              xmlns="http://www.w3.org/1999/xhtml"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:ui="http://java.sun.com/jsf/facelets"
              xmlns:p="http://primefaces.org/ui"
              xmlns:c="http://java.sun.com/jsp/jstl/core"&gt;
  
   &lt;ui:define name="content"&gt;
  
      &lt;h:form id="form"&gt;
          &lt;p:contextMenu for="tasks"&gt;  
              &lt;p:menuitem value="View" update="taskView" 
                          icon="ui-icon-search"   oncomplete="taskDialogView.show()"/&gt;  
              &lt;p:menuitem value="Update" update="taskUpdate"
                          icon="ui-icon-arrowrefresh-1-w"  
                          oncomplete="taskDialogUpdate.show()"/&gt;  
              &lt;p:menuitem value="Delete" update="tasks"
                          icon="ui-icon-close"  onclick="confirmation.show();"/&gt;  
          &lt;/p:contextMenu&gt;
          &lt;p:dataTable id="tasks" value="#{taskMBean.tasks}" 
                       var="item"  rowsPerPageTemplate="5,10,15,20,25,30" 
                       paginator="true" rows="10" 
                       filteredValue="#{taskMBean.filteredTasks}"
                       selection="#{taskMBean.selectedTask}" 
                       rowKey="#{item.id}" selectionMode="single"&gt;
          &lt;p:ajax event="rowSelect" update=":form:tasks, :form:taskView , 
                      :form:taskUpdate , :form:confirmDelete"/&gt; 
          &lt;f:facet name="header" &gt;  
          &lt;p:outputLabel value="List of WorkList (# 
                       {taskMBean.selectedWorkList.code}) tasks"/&gt;
          &lt;/f:facet&gt; 
          &lt;p:column sortBy="#{item.description}" filterBy="#{item.description}"&gt;
                  &lt;f:facet name="header"&gt;
                      &lt;p:outputLabel value="Description"/&gt;
                  &lt;/f:facet&gt;
                  &lt;p:outputLabel value="#{item.description}"&gt;
                  &lt;/p:outputLabel&gt;
              &lt;/p:column&gt;
              &lt;p:column sortBy="#{item.code}" filterBy="#{item.code}"&gt;
                  &lt;f:facet name="header"&gt;
                      &lt;p:outputLabel value="Code"/&gt;
                  &lt;/f:facet&gt;
                  &lt;p:outputLabel value="#{item.code}"&gt;
                  &lt;/p:outputLabel&gt;
              &lt;/p:column&gt;
              &lt;p:column sortBy="#{item.startDate}" filterBy="#{item.startDate}"&gt;
                  &lt;f:facet name="header"&gt;
                      &lt;p:outputLabel value="Start Date"/&gt;
  
                  &lt;/f:facet&gt;
                  &lt;h:outputText value="#{item.startDate}"&gt;
                      &lt;f:convertDateTime pattern="MM/dd/yyyy" /&gt;
                  &lt;/h:outputText&gt;
              &lt;/p:column&gt;
              &lt;p:column sortBy="#{item.endDate}" filterBy="#{item.endDate}"&gt;
                  &lt;f:facet name="header"&gt;
                      &lt;p:outputLabel value="End Date"/&gt;
  
                  &lt;/f:facet&gt;
                  &lt;h:outputText value="#{item.endDate}"&gt;
                      &lt;f:convertDateTime pattern="MM/dd/yyyy" /&gt;
                  &lt;/h:outputText&gt;
              &lt;/p:column&gt;
              &lt;f:facet name="footer"&gt;
                  &lt;p:commandButton value="New Task" oncomplete="TaskDialogNew.show()" 
                     icon="ui-icon-star" title="New Task"/&gt;
                  &lt;p:commandButton value="Delete Task"  actionListener="#
                    {taskMBean.deleteTask()}" update="tasks" icon="ui-icon-trash" 
                     style="margin-left: 5px"/&gt;
                  &lt;p:button value="Back"  outcome="WorkLists.xhtml" icon="ui-icon-
                     arrowthick-1-w" style="margin-left: 900px"/&gt;
              &lt;/f:facet&gt;
          &lt;/p:dataTable&gt;
          &lt;p:dialog header="Task Detail" widgetVar="taskDialogView" resizable="false"  
                    showEffect="clip" hideEffect="fold" style="position: absolute ;"  
                    id="dialogView"&gt;  
              &lt;p:panelGrid id="taskView" columns="2" &gt;  
                  &lt;f:facet name="header"&gt;  
                      &lt;p:graphicImage value="/images/task.png"/&gt;  
                  &lt;/f:facet&gt;
                  &lt;p:outputLabel value="Code:" /&gt;
                  &lt;p:outputLabel value="#{taskMBean.selectedTask.code}" title="Code" /&gt;
                  &lt;p:outputLabel value="Description:" /&gt;
                  &lt;p:outputLabel  value="#{taskMBean.selectedTask.description}" /&gt;
                  &lt;p:outputLabel value="Resources"/&gt;
                  &lt;p:dataList value="#{taskMBean.selectedTask.resources}" var="item" 
                              itemType="square"&gt;
                              #{item.name} (#{item.code})
                  &lt;/p:dataList&gt;
                  &lt;p:outputLabel value="Start Date"/&gt;
                  &lt;p:outputLabel value="#{taskMBean.selectedTask.startDate}" &gt;
                      &lt;f:convertDateTime pattern="MM/dd/yyyy" /&gt;
                  &lt;/p:outputLabel&gt;
                  &lt;p:outputLabel value="End Date"/&gt;
                  &lt;h:outputText value="#{taskMBean.selectedTask.endDate}" title="EndDate"&gt;
                      &lt;f:convertDateTime pattern="MM/dd/yyyy" /&gt;
                  &lt;/h:outputText&gt; 
                  &lt;p:outputLabel value="Status"/&gt;
                  &lt;p:outputLabel value="#{taskMBean.selectedTask.status}"/&gt;
              &lt;/p:panelGrid&gt;  
          &lt;/p:dialog&gt;  
          &lt;p:dialog header="task Update" widgetVar="taskDialogUpdate" resizable="false"  
                    showEffect="clip" hideEffect="fold" style="position: absolute ;" 
                    id="dialogUpdate"&gt;  
              &lt;p:panelGrid id="taskUpdate" columns="2" &gt;  
                  &lt;f:facet name="header"&gt;  
                      &lt;p:graphicImage value="/images/task.png"/&gt;  
                  &lt;/f:facet&gt; 
                  &lt;p:outputLabel value="Code:" for="code" style="width: 242px"/&gt;
                  &lt;p:inputText id="code" value="#{taskMBean.selectedTask.code}" 
                     style="width: 236px" required="true" requiredMessage="The Code field 
                      is required."/&gt;
                  &lt;p:outputLabel value="Description:" for="description" /&gt;
                  &lt;p:inputTextarea id="description" 
                     value="# {taskMBean.selectedTask.description}"  required="true" 
                     requiredMessage="The Description 
                 field is required."/&gt;
                  &lt;p:outputLabel value="Resources" for="resources"/&gt;
                  &lt;p:selectCheckboxMenu id="resources" value="#
                    {taskMBean.selectedTask.resources}" style="width: 241px" 
                    label="Select Resources" required="true" requiredMessage="The List of 
                    Resources field is required."&gt;
                      &lt;f:selectItems value="#{taskMBean.allResources}" var="item"  
                    itemLabel="#{item.name}" itemValue="#{selectedTask.resources}"  /&gt;
                      &lt;f:converter 
                       converterId="com.gis.plannerplus.converters.ObjectConverterResource
                        " /&gt;
        &lt;/p:selectCheckboxMenu&gt;
                      &lt;p:outputLabel value="Status" for="status"/&gt;
                  &lt;p:selectOneMenu id="status" value="#{taskMBean.selectedTask.status}" 
                    style="width: 241px" required="true" requiredMessage="The customer 
                    field is required."&gt;
                      &lt;f:selectItems value="#{taskMBean.allStatus}" var="s" itemLabel="#
                  {s.status}"/&gt;
                  &lt;/p:selectOneMenu&gt;
  
                  &lt;p:outputLabel for="startdate" value="Start "  /&gt;  
                  &lt;p:calendar  id="startdate" required="true" label="StartDate" 
                   style="width: 240px" binding="#{startdate}"
                               effect="fold"   value="#
                  {taskMBean.selectedTask.startDate}" pattern="dd/MM/yy" &gt;
                      &lt;p:ajax process="startdate finishDate" update="toDateMsg" /&gt;
                  &lt;/p:calendar&gt;
                  &lt;p:outputLabel for="finishDate" value="End " /&gt;  
                  &lt;p:calendar  id="finishDate" label="FinishDate"  style="width: 240px" 
                   pattern="dd/MM/yy"
                               effect="fold"  value="#{taskMBean.selectedTask.endDate}" &gt;
                      &lt;f:attribute name="startDate" value="#{startdate.value}" /&gt;
                      &lt;f:validator validatorId="validator.dateRangeValidator" /&gt;
                      &lt;p:ajax process="startdate  finishDate" update="toDateMsg" /&gt;
                      &lt;p:message for="finishDate" id="toDateMsg" &gt;
                      &lt;/p:message&gt;
                  &lt;/p:calendar&gt;
              &lt;/p:panelGrid&gt; 
              &lt;p:commandButton value="Clear" type="reset" icon="ui-icon-arrowrefresh-1-n"
              styleClass="ui-priority-primary"/&gt;  
              &lt;p:commandButton value="Save" ajax="false" icon="ui-icon-circle-check" 
              styleClass="ui-priority-primary" action="#{taskMBean.upDateTask()}" /&gt;  
          &lt;/p:dialog&gt;  
          &lt;p:confirmDialog id="confirmDelete" message="Are you sure ?"  appendTo="@(body)"
                           header="Delete Task?" severity="alert" 
            widgetVar="confirmation" style="width: auto"&gt;  
              &lt;p:commandButton id="confirm" value="Yes" ajax="false"   /&gt;  
              &lt;p:commandButton id="decline" value="No" onclick="confirmation.hide();" 
             type="button" /&gt;   
          &lt;/p:confirmDialog&gt; 
      &lt;/h:form&gt;
  
  
      &lt;h:form id="newTaskForm"&gt;
          &lt;p:dialog header="New Task" widgetVar="TaskDialogNew" resizable="false"  
                    showEffect="clip" hideEffect="fold" style="position: absolute ;" 
       id="dialogNewTask"&gt;  
              &lt;p:panel id="panel"&gt;   
                  &lt;p:messages id="messages" /&gt;
                  &lt;p:panelGrid id="newTask" columns="2" style="margin-bottom:10px" &gt;  
                      &lt;f:facet name="header"&gt;  
                          &lt;p:graphicImage value="/images/task.png"/&gt;  
                      &lt;/f:facet&gt;
                      &lt;p:outputLabel value="Code:" for="code" /&gt;
                      &lt;p:inputText  id="code" value="#{taskMBean.code}" style="width: 
         236px"  required="true" requiredMessage="The Code field is required."/&gt;
                      &lt;p:outputLabel value="Description:" for="description" /&gt;
                      &lt;p:inputTextarea id="description" value="#{taskMBean.description}" 
         style="width: 236px" required="true" requiredMessage="The Description field is
             required."/&gt;
  
  
                      &lt;p:outputLabel value="Resources" for="resources"/&gt;
                      &lt;p:selectCheckboxMenu id="resources" value="#{taskMBean.resources}"
         style="width: 241px" label="Select Resources"  &gt;
                          &lt;f:selectItems value="#{taskMBean.allResources}" var="item" 
          itemLabel="#{item.name}" itemValue="#{resources}"   /&gt;
                          &lt;f:converter 
         converterId="com.gis.plannerplus.converters.ObjectConverterResource" /&gt;
                      &lt;/p:selectCheckboxMenu&gt;
                         &lt;p:outputLabel value="Status" for="status"/&gt;
                      &lt;p:selectOneMenu id="status" value="#{taskMBean.status}" 
          style="width: 241px" required="true" requiredMessage="The customer field is 
          required."&gt;
                          &lt;f:selectItems value="#{taskMBean.allStatus}" var="s" 
          itemLabel="#{s.status}"/&gt;
                      &lt;/p:selectOneMenu&gt;
                      &lt;p:outputLabel for="startDate" value="Start "  /&gt;  
                      &lt;p:calendar  id="startDate" required="true" label="StartDate" 
          style="width: 260px" binding="#{startDate}"
                                   effect="fold"   value="#{taskMBean.startDate}" 
            pattern="dd/MM/yy" &gt;
                          &lt;p:ajax process="startDate finishDate" update="toDateMsg" /&gt;
                      &lt;/p:calendar&gt;
                      &lt;p:outputLabel for="finishDate" value="End " /&gt;  
                      &lt;p:calendar  id="finishDate" label="FinishDate"  style="width: 
            240px"
                                   effect="fold" required="true"  value="# 
                                {taskMBean.endDate}" &gt;
                          &lt;f:attribute name="startDate" value="#{startDate.value}" /&gt;
                          &lt;f:validator validatorId="validator.dateRangeValidator" /&gt;
                          &lt;p:ajax process="startDate  finishDate" update="toDateMsg" /&gt;
                          &lt;p:message for="finishDate" id="toDateMsg" &gt;
                          &lt;/p:message&gt;
                      &lt;/p:calendar&gt;
                  &lt;/p:panelGrid&gt; 
                  &lt;p:commandButton type="reset" value="Clear" icon="ui-icon-
              arrowrefresh-1-n" styleClass="ui-priority-primary"/&gt;
                  &lt;p:commandButton value="Submit" ajax="false" process="@form" 
              update=":form:tasks, :growl"  oncomplete=" handleSubmitRequest(xhr, status, 
              args, 'TaskDialogNew','newTaskForm');" actionListener="#{taskMBean.addTask
             ()}"/&gt; 
              &lt;/p:panel&gt;
          &lt;/p:dialog&gt;  
      &lt;/h:form&gt;
  
      &lt;p:growl id="growl" showDetail="true" life="5000" /&gt;
      &lt;script&gt;
                  function handleSubmitRequest(xhr, status, args, dialogName, formName) {
                      dialog = jQuery('#' + dialogName);
                      if (args.validationFailed) {
                          dialog.effect("shake", {times: 3}, 100);
                      } else {
                          clearForm(formName);
                          TaskDialogNew.hide();
                          taskDialogUpdate.hide();
  
                      }
                  }
                  function clearForm(formName) {
                      jQuery('#' + formName).each(function() {
                          this.reset();
                      });
                  }
  
      &lt;/script&gt;
      &lt;/ui:define&gt;
       &lt;/ui:composition&gt;
  </code></pre>