Note that there are some explanatory texts on larger screens.

plurals
  1. POAccess FlowScope from JSP without JSTL
    primarykey
    data
    text
    <p>I'm using Spring Web Flow (v. 1.0.5) and I have a JSP page that makes an AJAX call to a flow and needs to read in the XML results. That flow successfully sets an object into the FlowScope, then calls a JSP page to render the results. In the JSP page, I'd like to test whether the object has a property (say, .firstName) and if so, do something. I can access the variable in the FlowScope using JSTL expression language (by saying ${userObj}), but that just lets me spit it out. I've tried the methods below to get at it and put logic around it, with varying success.</p> <p><strong>Update: The remaining question is: How do I get the context and flow scope in the scriptlet (&lt;% %>) section?</strong></p> <pre><code>&lt;rootnode&gt; &lt;!-- Attempt 1: c:if isn't being interpreted (though ${userObj.firstName} is), it's just displaying the tags on the page. --&gt; &lt;!-- Update, I didn't have the &lt;%@ taglib directive for jstl/core. Now I do, and they're being interpreted, but it says "According to TLD or attribute directive in tag file, attribute test does not accept any expressions" How can the if/@test not accept expressions? Isn't that its whole purpose in life? --&gt; &lt;!-- Update 2, I also forgot the taglib for the rt language, which is separate, I guess (jstl/core_rt). &lt;c:if test now works properly. --&gt; &lt;c:if test="${!empty(userObj.firstName)}"&gt; &lt;test&gt;not empty&lt;/test&gt; &lt;/c:if&gt; &lt;% /* Attempt 2: This throws an error, can't resolve "context". How do I get the context? */ if (context.getFlowScope().userObj != null) { out.write("not null"); } else { out.write("not not null"); } %&gt; &lt;!-- Attempt 3: This works, I get the reference to the Object and it spits out the correct firstName, gives me no control other than spitting out the value. --&gt; &lt;userReference&gt;${userObj}&lt;/userReference&gt; &lt;userReference_firstName&gt;${userObj.firstName}&lt;/userReference_firstName&gt; &lt;/rootnode&gt; </code></pre>
    singulars
    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.
    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