Note that there are some explanatory texts on larger screens.

plurals
  1. POJSF sessionbean value not persisted after redirect
    text
    copied!<p>I am using IceFaces 2.0. </p> <p>When I click on a datatable entry to edit, I pass the serial number and fetch the data for that serial number from DB and set the value to a object in a session.</p> <pre><code>&lt;ice:column&gt; &lt;h:panelGroup&gt; &lt;span style="margin-right: 5px"&gt;&lt;h:commandLink action="#{person.getPersonDetail}" value="Edit" &gt; &lt;f:param id="serialNo" name="serialNo" value="#{person.serialNo}"&gt;&lt;/f:param&gt; &lt;/h:commandLink&gt;&lt;/span&gt; &lt;/h:panelGroup&gt; &lt;/ice:column&gt; &lt;/ice:dataTable&gt; </code></pre> <p>Bean :</p> <pre><code>@ManagedBean(name="personBean") @SessionScoped public class PersonBean implements Serializable{ private long serialNo; private String firstName; private String middleName; private String lastName; private Date dob; private java.sql.Date dateB; private String gender; private String emailId; private PersonService personSerivce; private List&lt;PersonBean&gt; personList; private PersonBean person; //Getter - Setter for all the properties public PersonBean getPerson(){ System.out.println("PersonBean.getPerson()"); if(this.person==null) { PersonBean personB= (PersonBean)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("personBean"); this.person=personB.person; } return this.person; } public String getPersonDetail(){ try { System.out.println("Serial No: "+getSerialNo()); //setPerson(getPersonSerivce().getPerson(getSerialNo())) if(this.person==null) this.person=getPersonSerivce().getPerson(getSerialNo()); System.out.println("First Name: "+this.person.firstName); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return "getUser"; } </code></pre> <p>faces-config entry:</p> <pre><code>&lt;navigation-rule&gt; &lt;from-view-id&gt;*&lt;/from-view-id&gt; &lt;navigation-case&gt; &lt;from-outcome&gt;getUser&lt;/from-outcome&gt; &lt;to-view-id&gt;/editUser.xhtml&lt;/to-view-id&gt; &lt;redirect/&gt; &lt;/navigation-case&gt; </code></pre> <p>On EditUser.xhtml</p> <pre><code>&lt;h:panelGroup&gt; &lt;h:panelGroup&gt; &lt;h:outputLabel value="First Name" /&gt; &lt;/h:panelGroup&gt; &lt;h:panelGroup&gt; &lt;h:inputText value="#{personBean.person.firstName}" id="fName"/&gt; &lt;/h:panelGroup&gt; &lt;/h:panelGroup&gt; </code></pre> <p>After redirection, the value in personBean.person and all other variables is null while, the value for personList is persisted in the bean resided in session.</p> <p>Can not find the reason.</p> <ol> <li>Any other better way to achieve this task? </li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload