title: jsf passing parameters in a method expression failes in ViewScoped bean
body: <p>I have jsf page backed by a ViewScoped bean which lists a bunch of transactions like below</p>
  
  <pre><code>&lt;ui:repeat value="#{transactions_byaccount.pageList}" var="item"&gt;
              &lt;tr class="dataRow"&gt;
                  &lt;td class="dataCell cltdtransactionsdatetransaction"&gt;
                        &lt;h:outputText value="#{item.datetransaction}" &gt;
                          &lt;f:convertDateTime pattern="EEE dd-MMM-yyyy HH:mm" /&gt;
                        &lt;/h:outputText&gt;
                  &lt;/td&gt;
                  ...
                  ...
  
                  &lt;td colspan="2"&gt;
                      &lt;span class="pagerDBspan" style="font-weight: bold;"&gt;
                          &lt;h:commandLink action="#{transactions_byaccount.updateCategory('', item)}" &gt;
                              &lt;h:outputText value="Update"&gt;&lt;/h:outputText&gt;        
                              &lt;f:param name="pageNo" value="#{param.pageNo}" /&gt;
                              &lt;f:param name="accountId" value="#{param.accountId}" /&gt;
                              &lt;f:param name="sortOrder" value="#{param.sortOrder}" /&gt;
                              &lt;f:param name="orderColumn" value="#{param.orderColumn}" /&gt;                                                                         
                          &lt;/h:commandLink&gt;
                      &lt;/span&gt;                                         
                  &lt;/td&gt;
  </code></pre>
  
  <p>when a user navigates to the page, the link has the accountId passed in as a parameter which is mapped to a managed property on the bean like below</p>
  
  <pre><code>@ManagedProperty("#{param.accountId}")
  private int accountId;
  </code></pre>
  
  <p>at this point calls to the method #{transactions_byaccount.updateCategory('', item)} passing 'item' works as expected.</p>
  
  <p>the user is also able to change the account id by selecting a drop down on the page which is bound to the accountId field above and clicking a refresh button which will call the relevant DAO to get a list of transactions of the selected account. However when the user clicks on the button to call #{transactions_byaccount.updateCategory('', item)}  does not list me the item from the new account, it uses the item from the list of the first account.</p>
  
  <p>It appears the problem is at the point of the restore bit of the JSF lifecycle.</p>
  
  <p>Any help would be appreciated. Will add more details if needed.</p>
  
  <p>Thanks
  Mani</p>
  
  <p>Edit: 
  My bean</p>
  
  <pre><code>package applogic.transactions;
  
  import java.sql.Connection;
  import java.util.ArrayList;
  import java.util.List;
  
  import javax.faces.bean.ManagedBean;
  import javax.faces.bean.ManagedProperty;
  import javax.faces.bean.RequestScoped;
  import javax.faces.bean.ViewScoped;
  import javax.faces.model.SelectItem;
  
  import applogic.Conns;
  
  import finance.bean.TransactionsListBean;
  import finance.dao.AccountsDAO;
  import finance.dao.TransactionsDAO;
  import finance.daobase.BusinessDAO;
  import finance.model.Accounts;
  import finance.model.Transactions;
  import java.io.Serializable;
  import javax.annotation.PostConstruct;
  import javax.annotation.PreDestroy;
  
  @ManagedBean(name = "transactions_byaccount")
  @ViewScoped
  public class Transactions_Byaccount extends TransactionsListBean implements Serializable {
      List&lt;Transactions&gt; resultList;
  
      boolean initialized;
  
      @ManagedProperty("#{param.accountId}")
      private int accountId;
  
      public SelectItem[] accountsSelections;
  
      @ManagedProperty("#{param.sortOrder}")
      private int sortOrder;
  
      public SelectItem[] sortOrderSelections;
  
      @ManagedProperty("#{param.orderColumn}")
      private int orderColumn;
  
      public SelectItem[] orderColumnSelections;
  
      public Transactions_Byaccount() {
           Connection cons = Conns.getConFinanceDB();
           List&lt;Accounts&gt; accountsList = AccountsDAO.List(cons);
           List&lt;SelectItem&gt; listOfAccountsSelectItems = new
           ArrayList&lt;SelectItem&gt;();
  
           for( Accounts temp : accountsList ) {
               listOfAccountsSelectItems.add(new SelectItem(temp.getId(), temp.getTitle()));
           }
  
           accountsSelections = listOfAccountsSelectItems.toArray(new SelectItem[listOfAccountsSelectItems.size()]);
  
           List&lt;SelectItem&gt; sortOrderList = new ArrayList&lt;SelectItem&gt;();
           sortOrderList.add(new SelectItem(1, "Asc"));
           sortOrderList.add(new SelectItem(2, "Desc"));       
           sortOrderSelections = sortOrderList.toArray(new SelectItem[sortOrderList.size()]);
  
           List&lt;SelectItem&gt; orderColumnList = new ArrayList&lt;SelectItem&gt;();
           orderColumnList.add(new SelectItem(1, "Transaction Date"));
           orderColumnList.add(new SelectItem(2, "Action Date"));      
           orderColumnList.add(new SelectItem(3, "Reconciled Date"));
           orderColumnSelections = orderColumnList.toArray(new SelectItem[orderColumnList.size()]);
      }
  
      public String updateCategories(String redirectURL) {
          String result = redirectURL;
  
          Connection cons = Conns.getConFinanceDB();
          for( Transactions temp : (List&lt;Transactions&gt;)this.getPageList() )
              TransactionsDAO.Update(cons, temp);
  
          resultList = null;
  
          if( redirectURL != null &amp;&amp; redirectURL.length() == 0 )
              redirectURL = null;
  
          return redirectURL;
      }
  
      public String updateCategory(String redirectURL, Transactions arg) {
          String result = redirectURL;
  
          Connection cons = Conns.getConFinanceDB();
          TransactionsDAO.Update(cons, arg);
  
          resultList = null;
  
          if( redirectURL != null &amp;&amp; redirectURL.length() == 0 )
              redirectURL = null;
  
          return result;
      }
  
      @PostConstruct
      public void refresh() {
          Connection con = Conns.getConFinanceDB();
          resultList = TransactionsDAO.ListByaccount(con, accountId, getCurrentPageNo(), getPageSize(), orderColumn, sortOrder);
          initialized = true;
  
      }
  
      public void reload() {
          Connection con = Conns.getConFinanceDB();
          resultList = TransactionsDAO.ListByaccount(con, accountId, getCurrentPageNo(), getPageSize(), orderColumn, sortOrder);
          initialized = true;
  
      }
  
      public String reload(String returnUrl) {
          Connection con = Conns.getConFinanceDB();
          resultList = TransactionsDAO.ListByaccount(con, accountId, getCurrentPageNo(), getPageSize(), orderColumn, sortOrder);
          initialized = true;     
          return returnUrl;
      }
  
      public Object getPageList() {
  
  
          return resultList;
      }
  
      public int getMaxCount() {
          Connection con = Conns.getConFinanceDB();
          int result = TransactionsDAO.CountByaccount(con, accountId);
          return result;
      }
  
      public int getAccountId() {
          return accountId;
      }
  
      public void setAccountId(int accountId) {
          this.accountId = accountId;
      }
  
      public SelectItem[] getAccountsSelections() {
          return accountsSelections;
      }
  
      public void setAccountsSelections(SelectItem[] accountsSelections) {
          this.accountsSelections = accountsSelections;
      }
  
      public int getSortOrder() {
          return sortOrder;
      }
  
      public void setSortOrder(int sortOrder) {
          this.sortOrder = sortOrder;
      }
  
      public SelectItem[] getSortOrderSelections() {
          return sortOrderSelections;
      }
  
      public void setSortOrderSelections(SelectItem[] sortOrderSelections) {
          this.sortOrderSelections = sortOrderSelections;
      }
  
      public int getOrderColumn() {
          return orderColumn;
      }
  
      public void setOrderColumn(int orderColumn) {
          this.orderColumn = orderColumn;
      }
  
      public SelectItem[] getOrderColumnSelections() {
          return orderColumnSelections;
      }
  
      public void setOrderColumnSelections(SelectItem[] orderColumnSelections) {
          this.orderColumnSelections = orderColumnSelections;
      }   
  
      public boolean isInitialized() {
          return initialized;
      }
  
      public void setInitialized(boolean initialized) {
          this.initialized = initialized;
      }
  
      public List&lt;Transactions&gt; getResultList() {
          return resultList;
      }
  
      public void setResultList(List&lt;Transactions&gt; resultList) {
          this.resultList = resultList;
      }
  }
  </code></pre>
  
  <p>And now my page</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:t="http://myfaces.apache.org/tomahawk"
      xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en"&gt;
  
  
  &lt;ui:composition template="/WEB-INF/templates/template_main.xhtml"&gt;
      &lt;ui:param name="title" value="transactions"&gt;&lt;/ui:param&gt;
  
      &lt;ui:define name="operationalbar"&gt;
          &lt;div&gt;
              &lt;span&gt;
                  &lt;h:selectOneMenu value="#{transactions_byaccount.accountId}" &gt;
                      &lt;f:selectItems value="#{transactions_byaccount.accountsSelections}"/&gt;
                  &lt;/h:selectOneMenu&gt;
              &lt;/span&gt;
              &lt;span&gt;
                  &lt;h:commandLink action="#{transactions_byaccount.reload('')}"&gt;
                      &lt;h:outputText value="Reload"&gt;&lt;/h:outputText&gt;
                      &lt;f:param name="pageNo" value="#{param.pageNo}" /&gt;
                      &lt;f:param name="accountId" value="#{param.accountId}" /&gt;
                      &lt;f:param name="sortOrder" value="#{param.sortOrder}" /&gt;
                      &lt;f:param name="orderColumn" value="#{param.orderColumn}" /&gt;
                  &lt;/h:commandLink&gt;
              &lt;/span&gt;         
              &lt;span&gt;
                  &lt;h:commandLink action="#{transactions_byaccount.updateCategories('')}"&gt;
                      &lt;h:outputText value="Update Categories"&gt;&lt;/h:outputText&gt;
                      &lt;f:param name="pageNo" value="#{param.pageNo}" /&gt;
                      &lt;f:param name="accountId" value="#{param.accountId}" /&gt;
                      &lt;f:param name="sortOrder" value="#{param.sortOrder}" /&gt;
                      &lt;f:param name="orderColumn" value="#{param.orderColumn}" /&gt;
                  &lt;/h:commandLink&gt;        
              &lt;/span&gt;
          &lt;/div&gt;
      &lt;/ui:define&gt;
  
      &lt;ui:define name="pagingbar"&gt;
          &lt;div&gt;
              &lt;span&gt;
                  &lt;h:commandLink title="Go to page first page" &gt;
                      &lt;h:outputText value="first"&gt;&lt;/h:outputText&gt;
                          &lt;f:param name="pageNo" value="#{transactions_byaccount.firstPage}" /&gt;
                          &lt;f:param name="accountId" value="#{param.accountId}" /&gt;
                          &lt;f:param name="sortOrder" value="#{param.sortOrder}" /&gt;
                          &lt;f:param name="orderColumn" value="#{param.orderColumn}" /&gt;             
                  &lt;/h:commandLink&gt;
              &lt;/span&gt;
              &lt;span&gt;
                  &lt;h:commandLink title="Go to page prev page"&gt;
                      &lt;h:outputText value="prev"&gt;&lt;/h:outputText&gt;
                          &lt;f:param name="pageNo" value="#{transactions_byaccount.prevPage}" /&gt;
                          &lt;f:param name="accountId" value="#{param.accountId}" /&gt;
                          &lt;f:param name="sortOrder" value="#{param.sortOrder}" /&gt;
                          &lt;f:param name="orderColumn" value="#{param.orderColumn}" /&gt;
                  &lt;/h:commandLink&gt;
  
              &lt;/span&gt;
                  &lt;ui:repeat value="#{transactions_byaccount.pages}" var="item"&gt;
                      &lt;span style="font-weight: #{item == transactions_byaccount.currentPageNo ? 'bold' : 'lighter' }"&gt;
                          &lt;h:commandLink&gt;
                              &lt;h:outputText value="#{item}"&gt;&lt;/h:outputText&gt;
                              &lt;f:param name="pageNo" value="#{item}" /&gt;
                              &lt;f:param name="accountId" value="#{param.accountId}" /&gt;
                              &lt;f:param name="sortOrder" value="#{param.sortOrder}" /&gt;
                              &lt;f:param name="orderColumn" value="#{param.orderColumn}" /&gt;
  
                          &lt;/h:commandLink&gt;
                      &lt;/span&gt;
                  &lt;/ui:repeat&gt;                
  
              &lt;span&gt;
                  &lt;h:commandLink title="Go to page next page"&gt;
                      &lt;h:outputText value="next"&gt;&lt;/h:outputText&gt;
                          &lt;f:param name="pageNo" value="#{transactions_byaccount.nextPage}" /&gt;
                          &lt;f:param name="accountId" value="#{param.accountId}" /&gt;
                          &lt;f:param name="sortOrder" value="#{param.sortOrder}" /&gt;
                          &lt;f:param name="orderColumn" value="#{param.orderColumn}" /&gt;
                  &lt;/h:commandLink&gt;
              &lt;/span&gt;
              &lt;span&gt;
                  &lt;h:commandLink title="Go to page last page"&gt;
                      &lt;h:outputText value="last"&gt;&lt;/h:outputText&gt;
                          &lt;f:param name="pageNo" value="#{transactions_byaccount.lastPage}" /&gt;
                          &lt;f:param name="accountId" value="#{param.accountId}" /&gt;
                          &lt;f:param name="sortOrder" value="#{param.sortOrder}" /&gt;
                          &lt;f:param name="orderColumn" value="#{param.orderColumn}" /&gt;
  
                  &lt;/h:commandLink&gt;                
              &lt;/span&gt;         
          &lt;/div&gt;
          &lt;div class="currentPagerIndex"&gt;
  
          &lt;/div&gt;
      &lt;/ui:define&gt;
      &lt;ui:define name="maincontent"&gt;
          &lt;table class="datatable"&gt;
              &lt;thead&gt;
                  &lt;tr class="headRow"&gt;
                      &lt;td&gt;datetransaction&lt;/td&gt;
                      &lt;td&gt;description&lt;/td&gt;
                      &lt;td&gt;amount&lt;/td&gt;
                      &lt;td&gt;Edit&lt;/td&gt;
                      &lt;td&gt;Delete&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;ui:repeat value="#{transactions_byaccount.pageList}" var="item"&gt;
                  &lt;tr class="dataRow"&gt;
                      &lt;td class="dataCell cltdtransactionsdatetransaction"&gt;
                            &lt;h:outputText value="#{item.datetransaction}" &gt;
                              &lt;f:convertDateTime pattern="EEE dd-MMM-yyyy HH:mm" /&gt;
                            &lt;/h:outputText&gt;
                      &lt;/td&gt;
                      &lt;td class="dataCell cltdtransactionsdescription"&gt;#{item.description}&lt;/td&gt;
                      &lt;td class="dataCell cltdtransactionsamount"&gt;#{item.amount}&lt;/td&gt;
                      &lt;td style="width: 45px"&gt;
                          &lt;span class="pagerDBspan" style="font-weight: bold;"&gt;                   
                              &lt;h:link outcome="transactions_edit" style="font-weight: bold;"&gt;
                                  &lt;h:outputText value="Edit"&gt;&lt;/h:outputText&gt;
                                  &lt;f:param name="pageNo" value="#{param.pageNo}" /&gt;
                                  &lt;f:param name="itemId" value="#{item.id}" /&gt;
                              &lt;/h:link&gt;
                          &lt;/span&gt;                 
                      &lt;/td&gt;
                      &lt;td style="width: 45px"&gt;
                          &lt;span class="pagerDBspan" style="font-weight: bold;"&gt;
                              &lt;h:link  outcome="transactions_edit" &gt;
                                  &lt;h:outputText value="Delete"&gt;&lt;/h:outputText&gt;
                                  &lt;f:param name="pageNo" value="#{param.pageNo}" /&gt;
                                  &lt;f:param name="itemId" value="#{item.id}" /&gt;
                                  &lt;f:param name="deleteFlag" value="true" /&gt;                                  
                              &lt;/h:link&gt;       
                          &lt;/span&gt;                 
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr class="dataRow"&gt;
                      &lt;td class="dataCell"&gt;&lt;/td&gt;
                      &lt;td class="dataCell" colspan="2"&gt;
                          &lt;h:selectOneMenu value="#{item.fkCategoriesId}" &gt;
                              &lt;f:selectItems value="#{categories_edit.categories}"/&gt;
                          &lt;/h:selectOneMenu&gt;
                      &lt;/td&gt;
                      &lt;td colspan="2"&gt;
                          &lt;span class="pagerDBspan" style="font-weight: bold;"&gt;
                              &lt;h:commandLink action="#{transactions_byaccount.updateCategory('', item)}" &gt;
                                  &lt;h:outputText value="Update"&gt;&lt;/h:outputText&gt;        
                                  &lt;f:param name="pageNo" value="#{param.pageNo}" /&gt;
                                  &lt;f:param name="accountId" value="#{param.accountId}" /&gt;
                                  &lt;f:param name="sortOrder" value="#{param.sortOrder}" /&gt;
                                  &lt;f:param name="orderColumn" value="#{param.orderColumn}" /&gt;                                                                         
                              &lt;/h:commandLink&gt;
                          &lt;/span&gt;                                         
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td class="cssBottomLine" colspan="0"&gt;&lt;/td&gt;
                  &lt;/tr&gt;                   
              &lt;/ui:repeat&gt;
          &lt;/table&gt;
      &lt;/ui:define&gt;
  
      &lt;ui:define name="bottomoperationalbarhost"&gt;
      &lt;/ui:define&gt;
  
  &lt;/ui:composition&gt;
  &lt;/html&gt;
  </code></pre>