struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dale Newfield <d...@newfield.org>
Subject Re: Managing code between Action Class and JSP.
Date Thu, 09 Sep 2010 20:53:06 GMT
On 9/9/10 4:12 PM, anjibman wrote:
> What I am really struggling in is I have processing result in the form of
> List of objects.

> What would be the best practice to send such list to JSP ready to grab.

Best practice is to store it inside the action, and add a getter to your 
action that returns the list:

public List<Foo> getResultObjects()

Then in the jsp use tags like these:

<ul>
   <s:iterator value="%{resultObjects}" var="aFoo">
     <li><s:property value="%{#aFoo.propertyName}" /></li>
   </s:iterator>
</ul>

The language used inside those %{} is called OGNL (Object Graph 
Navigation Language).  It can access data held either in a named map 
(aFoo for example, addressed with a #) or by searching the "value stack" 
(which typically has the action as the top item, so resultObjects winds 
up calling your action's getResultObjects() method).

http://struts.apache.org/2.2.1/docs/ognl.html
http://www.opensymphony.com/ognl/html/LanguageGuide/index.html

-Dale

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


Mime
View raw message