Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

[s2] Passing parameters to an action

Petr Blahos

2007-02-22

Replies:

Hi all,
I was wondering how I could possibly solve this: I have an action in which
I construct quite a complex data structure. From that data structure I display
some tables and create some charts. Now, I have got this one big-ass java
class - extending ActionSupport, in which I do all the stuff - create data and
have functions for painting charts in temporary files. In JSP I do the obvious:
   <s:iterator ...>
   ...... paint table
   </s:iterator>
then the graphs:
 <s:iterator value="%{getCharts(top)}">
   <img src="<%=request.getContextPath()%>/servlet/DisplayChart?filename=<s:property />" border=0">
 </s:iterator>
where getCharts(top) is a function that constructs the charts and saves it in files
and returns a list of filenames, and servlet/DisplayChart simply converts the
filename to full path and filename.

Now, the thing is, I would like to separate the code for painting the charts in a different
file, and do something like this:
    <s:iterator value="%{getChartsData(top)}">
          <s:action namespace="charts" name="ErrorStat" executeResult="true"/>
         <%--       ^^^^^^^^^^^^^^^^^^^^^^^^^^^   --%>
    </s:iterator>
But I need to pass current "top" to the action (or set a property in this action) but I
have no idea how. I gather that I should be able to get to the "top" in my java class
but it seems to be quite far fetched. I would rather set a property in this action.
I have tried playing with <s:property, <s:push, <s:param without any success.

Am I missing something or is my idea totally wrong?

Thanks a million,
Petr Blahoš

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.