You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ray Clough <ra...@allthisisthat.com> on 2007/04/17 19:48:19 UTC

JSTL and the Value Stack

Is it possible to use JSTL to access the value stack?   If so, what is 
the syntax.  If that doesn't work, what is the syntax for accessing it 
with a scriptlet?  That must be possible, because that is what the tags do.

Thanks very much,
Ray Clough


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSTL and the Value Stack

Posted by Guillaume Carré <gu...@gmail.com>.
2007/4/18, Ray Clough <ra...@allthisisthat.com>:
> This page perfectly illustrates my point on the difficulty of the JSTL tags
> working nicely with S2.  The page works perfectly if the object is
> explicitly placed into the HttpRequest.  If the 'getExporter()' is the way
> in which the Exporter is exposed, then it doesn't work for jstl.

I have filed an issue in JIRA about problems using JSTL on the value stack:
https://issues.apache.org/struts/browse/WW-1798

And as I commented the issue, "Adding the filter
org.apache.struts2.dispatcher.ActionContextCleanUp before the
FilterDispatcher solved the problem", it is a workaround, but the
whole thing used to work perfectly in WebWork, even without the
ActionContextCleanUp filter.
-- 
Guillaume Carré

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSTL and the Value Stack

Posted by Dave Newton <ne...@yahoo.com>.
--- Ray Clough <ra...@allthisisthat.com> wrote:
> I'm using the S2 tags for the "NameValuePairs", and
> it works fine.  I'm trying to use JSTL for the
> "DataMatrices", and it doesn't work.

I'll examine this further when I get home.

> Of course, I REALLY don't want to implement
> ServletRequestAware, because I want to test my 
> Actions easily.

You don't need to; use RequestAware.

http://struts.apache.org/2.x/struts2-core/apidocs/org/apache/struts2/interceptor/RequestAware.html

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSTL and the Value Stack

Posted by Ray Clough <ra...@allthisisthat.com>.
The Exporter class is designed to make the data in my "Model" class available
for use in jsp.  It has a method "getDataMatrices()" and another
"getNameValuePairs()".  I'm using the S2 tags for the "NameValuePairs", and
it works fine.  I'm trying to use JSTL for the "DataMatrices", and it
doesn't work.

I've tried 2 methods of exposing the Exporter to the JSP:  (1) using a
method "getExporter()" in the Action, (2) having the Action implement
ServletRequestAware, and explicitly saving the Exporter into the Request. 
That is how I'd do in S1.

For either method, the S2 iterator tag works properly for the
"NameValuePairs" data.  However the JSTL tags display the "DataMatrices"
only If I put the Exporter into the HttpRequest.  The JSP page does not
change at all between the 2 methods.  Only the Action class changes.

Of course, I REALLY don't want to implement ServletRequestAware, because I
want to test my Actions easily.  Therefore I really need to make the
"getExporter()" method work with JSTL.

This page perfectly illustrates my point on the difficulty of the JSTL tags
working nicely with S2.  The page works perfectly if the object is
explicitly placed into the HttpRequest.  If the 'getExporter()' is the way
in which the Exporter is exposed, then it doesn't work for jstl.

- Ray Clough



Dave Newton-4 wrote:
> 
> --- Ray Clough <ra...@allthisisthat.com> wrote:
>> My Action has a method "public Exporter
>> getExporter()".  If I use the struts2 
>> tags I can access the "exporter" with 
>> <s:iterator value="exporter.nameValuePairs" >, 
>> and it works fine.  If I use the jstl syntax 
>> <c:forEach items="${exporter.dataMatrices}"
>> var="matrix" >, nothing is found.  How do 
>> I get the jstl tag to work here? 
> 
> Without knowing what an Exporter is, I don't really
> know. 
> 
> You're using two different property names; did you
> mean to? 
> 
> Does Exporter follow JavaBean naming conventions for
> both of the properties you're accessing?
> 
> Use <s:iterator.../> but handle the inner loop with
> JSTL/JSP EL?
> 
> d.
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/JSTL-and-the-Value-Stack-tf3595148.html#a10050445
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSTL and the Value Stack

Posted by Dave Newton <ne...@yahoo.com>.
--- Ray Clough <ra...@allthisisthat.com> wrote:
> My Action has a method "public Exporter
> getExporter()".  If I use the struts2 
> tags I can access the "exporter" with 
> <s:iterator value="exporter.nameValuePairs" >, 
> and it works fine.  If I use the jstl syntax 
> <c:forEach items="${exporter.dataMatrices}"
> var="matrix" >, nothing is found.  How do 
> I get the jstl tag to work here? 

Without knowing what an Exporter is, I don't really
know. 

You're using two different property names; did you
mean to? 

Does Exporter follow JavaBean naming conventions for
both of the properties you're accessing?

Use <s:iterator.../> but handle the inner loop with
JSTL/JSP EL?

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSTL and the Value Stack

Posted by Ray Clough <ra...@allthisisthat.com>.
My Action has a method "public Exporter getExporter()".  If I use the struts2
tags I can access the "exporter" with <s:iterator
value="exporter.nameValuePairs" >, and it works fine.  If I use the jstl
syntax <c:forEach items="${exporter.dataMatrices}" var="matrix" >, nothing
is found.  How do I get the jstl tag to work here?  Thanks a million.

- Ray Clough



Musachy Barroso wrote:
> 
> http://cwiki.apache.org/confluence/display/WW/Can+we+use+JSTL+with+the+framework
> 
> I shouldn't be linking to the wiki but the main doc has an error (fixed on
> wiki already).
> 
> regards
> musachy
> 
> On 4/17/07, Ray Clough <ra...@allthisisthat.com> wrote:
>>
>> Is it possible to use JSTL to access the value stack?   If so, what is
>> the syntax.  If that doesn't work, what is the syntax for accessing it
>> with a scriptlet?  That must be possible, because that is what the tags
>> do.
>>
>> Thanks very much,
>> Ray Clough
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 
> -- 
> "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> 

-- 
View this message in context: http://www.nabble.com/JSTL-and-the-Value-Stack-tf3595148.html#a10050015
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSTL and the Value Stack

Posted by Musachy Barroso <mu...@gmail.com>.
http://cwiki.apache.org/confluence/display/WW/Can+we+use+JSTL+with+the+framework

I shouldn't be linking to the wiki but the main doc has an error (fixed on
wiki already).

regards
musachy

On 4/17/07, Ray Clough <ra...@allthisisthat.com> wrote:
>
> Is it possible to use JSTL to access the value stack?   If so, what is
> the syntax.  If that doesn't work, what is the syntax for accessing it
> with a scriptlet?  That must be possible, because that is what the tags
> do.
>
> Thanks very much,
> Ray Clough
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: JSTL and the Value Stack

Posted by Musachy Barroso <mu...@gmail.com>.
In  ${expression}, "expression" will be evaluated against the Value Stack.
An Dave is right, the "variable publishing" name is probably not the best
description for it :)

musachy

On 4/17/07, Musachy Barroso <mu...@gmail.com> wrote:
>
> The do publish a variable, if they have to, as Dave mentioned, in the case
> of the iterator, even if you don't specify and id, the current value will be
> on top of the stack which you access using %{#top}. Other tags publish
> values, like the url tag, etc.
>
> musachy
>
> On 4/17/07, Dave Newton <ne...@yahoo.com> wrote:
> >
> > --- Ray Clough <ra...@allthisisthat.com> wrote:
> > > The "why" is because I just really don't like the
> > > Struts-2 tags.  I especially don't like the fact
> > that
> > > they don't expose a variable on the page - for
> > > example the s:iterator tag does not explicitly
> > expose
> > > a variable which I can work with, or format using
> > > jstl.
> >
> > ...but I'm telling you they do, or at least
> > <s:iterator.../> does.
> >
> > <s:iterator value="dates" id="d">
> >   <fmt:formatDate value="${d}" pattern="MM/dd/yyyy"/>
> >   <br/>
> > </s:iterator>
> >
> > d.
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: JSTL and the Value Stack

Posted by Musachy Barroso <mu...@gmail.com>.
The do publish a variable, if they have to, as Dave mentioned, in the case
of the iterator, even if you don't specify and id, the current value will be
on top of the stack which you access using %{#top}. Other tags publish
values, like the url tag, etc.

musachy

On 4/17/07, Dave Newton <ne...@yahoo.com> wrote:
>
> --- Ray Clough <ra...@allthisisthat.com> wrote:
> > The "why" is because I just really don't like the
> > Struts-2 tags.  I especially don't like the fact
> that
> > they don't expose a variable on the page - for
> > example the s:iterator tag does not explicitly
> expose
> > a variable which I can work with, or format using
> > jstl.
>
> ...but I'm telling you they do, or at least
> <s:iterator.../> does.
>
> <s:iterator value="dates" id="d">
>   <fmt:formatDate value="${d}" pattern="MM/dd/yyyy"/>
>   <br/>
> </s:iterator>
>
> d.
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: JSTL and the Value Stack

Posted by Dave Newton <ne...@yahoo.com>.
--- Dave Newton <ne...@yahoo.com> wrote:
> ...but I'm telling you they do [expose variables to 
> JSTL], or at least <s:iterator.../> does.

Let me re-phrase that... it's not so much that they
"expose" variables, but that the StrutsRequestWrappers
will pass variable requests (not sure what to call
this, somebody hep me, hep me) to the OGNL stack.

My terminology is undoubtedly wrong, but the previous
JSP fragment was right :)

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSTL and the Value Stack

Posted by Dave Newton <ne...@yahoo.com>.
--- Ray Clough <ra...@allthisisthat.com> wrote:
> The "why" is because I just really don't like the
> Struts-2 tags.  I especially don't like the fact
that
> they don't expose a variable on the page - for 
> example the s:iterator tag does not explicitly
expose
> a variable which I can work with, or format using
> jstl.  

...but I'm telling you they do, or at least
<s:iterator.../> does.

<s:iterator value="dates" id="d">
  <fmt:formatDate value="${d}" pattern="MM/dd/yyyy"/>
  <br/>
</s:iterator>

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSTL and the Value Stack

Posted by Ray Clough <ra...@allthisisthat.com>.
The "why" is because I just really don't like the Struts-2 tags.  I 
especially don't like the fact that they don't expose a variable on the 
page - for example the s:iterator tag does not explicitly expose a 
variable which I can work with, or format using jstl.  They "don't play 
nicely with the other children", as my grade school teacher once 
reported.  Maybe I'm wrong, but that is my experience so far.

- Ray Clough


Dave Newton wrote:
> --- Ray Clough <ra...@allthisisthat.com> wrote:
>   
>> Is it possible to use JSTL to access the value
>>     
> stack?  
>
> The StrutsRequestWrapper (?) will forward...
> "unfulfilled" attribute requests to the OGNL stack. I
> wouldn't be sure of the exact syntax; it may depend on
> what, exactly, you're trying to access (and why?)
>
> For instance, you can access Action properties via JSP
> EL, the scoped attributes (obviously), etc.
>
>   
>> If that doesn't work, what is the syntax for 
>> accessing it with a scriptlet?
>>     
>
> Now you're just scaring me.
>
> d.
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSTL and the Value Stack

Posted by Dave Newton <ne...@yahoo.com>.
--- Ray Clough <ra...@allthisisthat.com> wrote:
> Is it possible to use JSTL to access the value
stack?  

The StrutsRequestWrapper (?) will forward...
"unfulfilled" attribute requests to the OGNL stack. I
wouldn't be sure of the exact syntax; it may depend on
what, exactly, you're trying to access (and why?)

For instance, you can access Action properties via JSP
EL, the scoped attributes (obviously), etc.

> If that doesn't work, what is the syntax for 
> accessing it with a scriptlet?

Now you're just scaring me.

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org