You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Raghuveer Kumarakrishnan <kr...@yahoo.com> on 2008/04/09 00:12:17 UTC

Request scoped data in Struts2

This doc seems to  suggest that even request scoped data needs to explicitly set using 
  <s:set....> to be used by tag libraries like jsp taglib or displaytag
   
  http://struts.apache.org/2.x/docs/exposing-framework-objects-to-jstl-with-a-jstl-and-displaytag-example.html
   
   
  But for request scoped data you do not need to explicitly set it as a request attribute,just getters on the action will do ,so a tag library like displaytag  will work out of the box
   
    <display:table name="someName" ....>
  ...
  .. 

    </display:table>
   
  where there is a getSomeName( )  method in the Struts2 Action class 

   
  Am I missing something or does the doc need to be updated?
   
  --Raghu


A Goal .......... Is a Dream with a Deadline
       
---------------------------------
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.

Re: Request scoped data in Struts2

Posted by Dave Newton <ne...@yahoo.com>.
--- Raghuveer Kumarakrishnan <kr...@yahoo.com> wrote:
> My point is just having getters for an Action property should suffice for
> it to be accessed in the view by any tag library.

I don't know as this is correct for *any* tag library.

It works for S2 tags that use OGNL, because S2 tags evalue OGNL.

It works for tag libraries that choose to interpret attribute values as JSP
EL and do the EL processing "by hand", because S2 provides a request wrapper
that maps EL expressions to the value stack (or the programmer uses a JSP EL
expression as the attribute value).

If an EL expression isn't used and the tag library doesn't assume EL or OGNL,
though, the tag library will just get a string, AFAIK (and whatever type
conversions are available to tags these days).

Dave

> Chris Pratt <th...@gmail.com> wrote:
>   You are correct. In that case,
> 
> 
> 
> is equivalent to calling
> 
> request.put("someName",action.getSomeName());
> 
> in an Action that implements RequestAware. So when Display Tag processes
> 
> 
> 
> The "someName" attribute is available when the JSP Tag Library
> (DisplayTag in this instance) calls
> pageContext.findAttribute("someName");
> 
> But you have to use the (or put the value in the request from
> the action) for DisplayTag to see it.
> 
> (*Chris*)
> 
> On Tue, Apr 8, 2008 at 3:12 PM, Raghuveer Kumarakrishnan
> wrote:
> > This doc seems to suggest that even request scoped data needs to
> explicitly set using
> > to be used by tag libraries like jsp taglib or displaytag
> >
> >
>
http://struts.apache.org/2.x/docs/exposing-framework-objects-to-jstl-with-a-jstl-and-displaytag-example.html
> >
> >
> > But for request scoped data you do not need to explicitly set it as a
> request attribute,just getters on the action will do ,so a tag library like
> displaytag will work out of the box
> >
> > 
> > ...
> > ..
> >
> > 
> >
> > where there is a getSomeName( ) method in the Struts2 Action class
> >
> >
> > Am I missing something or does the doc need to be updated?
> >
> > --Raghu
> >
> >
> > A Goal .......... Is a Dream with a Deadline
> >
> > ---------------------------------
> > You rock. That's why Blockbuster's offering you one month of Blockbuster
> Total Access, No Cost.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> 
> A Goal .......... Is a Dream with a Deadline
>        
> ---------------------------------
> You rock. That's why Blockbuster's offering you one month of Blockbuster
> Total Access, No Cost.


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


Re: Request scoped data in Struts2

Posted by Raghuveer Kumarakrishnan <kr...@yahoo.com>.
My point is just having getters for an Action property should suffice for it to be accessed in the view by any tag library.
  
Chris Pratt <th...@gmail.com> wrote:
  You are correct. In that case,



is equivalent to calling

request.put("someName",action.getSomeName());

in an Action that implements RequestAware. So when Display Tag processes



The "someName" attribute is available when the JSP Tag Library
(DisplayTag in this instance) calls
pageContext.findAttribute("someName");

But you have to use the (or put the value in the request from
the action) for DisplayTag to see it.

(*Chris*)

On Tue, Apr 8, 2008 at 3:12 PM, Raghuveer Kumarakrishnan
wrote:
> This doc seems to suggest that even request scoped data needs to explicitly set using
> to be used by tag libraries like jsp taglib or displaytag
>
> http://struts.apache.org/2.x/docs/exposing-framework-objects-to-jstl-with-a-jstl-and-displaytag-example.html
>
>
> But for request scoped data you do not need to explicitly set it as a request attribute,just getters on the action will do ,so a tag library like displaytag will work out of the box
>
> 
> ...
> ..
>
> 
>
> where there is a getSomeName( ) method in the Struts2 Action class
>
>
> Am I missing something or does the doc need to be updated?
>
> --Raghu
>
>
> A Goal .......... Is a Dream with a Deadline
>
> ---------------------------------
> You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.

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




A Goal .......... Is a Dream with a Deadline
       
---------------------------------
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.

Re: Request scoped data in Struts2

Posted by Chris Pratt <th...@gmail.com>.
You are correct.  In that case,

<s:set name="someName" value="someName" scope="request"/>

is equivalent to calling

request.put("someName",action.getSomeName());

in an Action that implements RequestAware.  So when Display Tag processes

<display:table name="someName" ...>

The "someName" attribute is available when the JSP Tag Library
(DisplayTag in this instance) calls
pageContext.findAttribute("someName");

But you have to use the <s:set> (or put the value in the request from
the action) for DisplayTag to see it.

  (*Chris*)

On Tue, Apr 8, 2008 at 3:12 PM, Raghuveer Kumarakrishnan
<kr...@yahoo.com> wrote:
> This doc seems to  suggest that even request scoped data needs to explicitly set using
>   <s:set....> to be used by tag libraries like jsp taglib or displaytag
>
>   http://struts.apache.org/2.x/docs/exposing-framework-objects-to-jstl-with-a-jstl-and-displaytag-example.html
>
>
>   But for request scoped data you do not need to explicitly set it as a request attribute,just getters on the action will do ,so a tag library like displaytag  will work out of the box
>
>     <display:table name="someName" ....>
>   ...
>   ..
>
>     </display:table>
>
>   where there is a getSomeName( )  method in the Struts2 Action class
>
>
>   Am I missing something or does the doc need to be updated?
>
>   --Raghu
>
>
>  A Goal .......... Is a Dream with a Deadline
>
>  ---------------------------------
>  You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.

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