Note that there are some explanatory texts on larger screens.

plurals
  1. POSession attribute returns null when returning from view
    primarykey
    data
    text
    <p>I'm currently trying to save search criteria attributes to the session between two pages: search page and edit page. The goal is to save the three variables: sYear, submission, collectionPeriod. I'm adding these to the session here below in the Search screen controller:</p> <p><code>request.getSession().setAttribute("sYearSave", sYear); request.getSession().setAttribute("submissionSave", submission); request.getSession().setAttribute("collectionPeriodSave", collectionPeriod);</code></p> <p>In the edit screen controller, I set a Boolean<code>isFromEditScreen</code> to <code>true.</code> This is so I know that I'm coming from the edit screen. I do print out the variables and I do get the values correctly here in the edit controller screen.</p> <pre><code>request.getSession().setAttribute("isFromEditScreen", new Boolean(true)); sYearSave = (String)request.getSession().getAttribute("sYearSave"); collectionPeriodSave = (String)request.getSession().getAttribute("collectionPeriodSave"); submissionSave = (String)request.getSession().getAttribute("submissionSave"); </code></pre> <p>But the problem is when I use a back button to go back to the Search screen, the search criteria <code>sYearSave, collectionPeriodSave, and submissionSave</code> values return <code>NULL.</code> For some reason, the <code>isFromEditScreen</code> boolean works just fine and returns <code>true.</code> It actually enters the statement but the search criteria return <code>null.</code> The Search controller code is below:</p> <pre><code>if (isFromEditScreen != null &amp;&amp; isFromEditScreen == true) { System.out.println("Inside isFromEditScreen ==== true"); sYear = (String)request.getSession().getAttribute("sYearSave"); collectionPeriod = (String)request.getSession().getAttribute("collectionPeriodSave"); submission = (String)request.getSession().getAttribute("submissionSave"); sYearSave = (String)request.getSession().getAttribute("sYearSave"); collectionPeriodSave = (String)request.getSession().getAttribute("collectionPeriodSave"); submissionSave = (String)request.getSession().getAttribute("submissionSave"); System.out.println("sYearSave ==== " + sYearSave); System.out.println("submissionSave ==== " + submissionSave); System.out.println("collectionPeriodSave ==== " + collectionPeriodSave); System.out.println("isFromEditScreen set in else ==== " + isFromEditScreen); } </code></pre> <p>Any help would be greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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