There are a lots of different ways of doing that. What I would do is:

1. add a field for the first action wit getters and setters for the params
2. in the jsp do something like:
<script>
var param1 = "<s:property value=''param1'  escapeJavaScript='true'/>";
var param2 = "<s:property value=''param2'  escapeJavaScript='true'/>";
</script>
3. Call the second action passing the params to Dojo like:
{ 'param1': param1, 'param2' : param2"}

Dojo accepts  a map that it serializes into a query string (if it is
GET request). I forgot the dojo method signatures, google it up :).
This way you can avoid building the query string yourself, which is
always error prone.

musachy


On Mon, Feb 9, 2009 at 3:15 PM, Christer Gjerstad
<christer.gjers...@gmail.com> wrote:
>
> Yes, correct. :-)
>
> So my question is; is that the way to do it? With the Dojo script that is,
> passing the data into the action? Will not the params interceptor handle
> this?
>
> What I've done so far is to make another action class implementing the
> ParameterAware interface so that I will get the incoming parameters. I then
> create and return a querystring and get this from the value stack in the
> page containing the Dojo script. I can then (hopefully) pass the information
> retrieved into the action returning the JSON result. This I will do with
> dojo.xhrPost and set the optional postData. Not solved this at the moment,
> but working on it.
>
> Seems like my solution is not that trivial so I would appreciate any help in
> this matter! :-)
>
> Cheers!
>
> -Christer!
>
>
> -----Opprinnelig melding-----
> Fra: Musachy Barroso [mailto:musa...@gmail.com]
> Sendt: 9. februar 2009 20:59
> Til: Struts Users Mailing List
> Emne: Re: Problem with JSON Result and Form Submit
>
> Ok, so the Dojo script needs to pass some data to the action, and that data
> is the one that comes from the first request right?
>
> musachy
>
> On Mon, Feb 9, 2009 at 2:54 PM, Christer Gjerstad
> <christer.gjers...@gmail.com> wrote:
>>
>> Almost. I have a page that has a form, and that submits (Post method)
>> to a an action that has JSP page as result containing a DOJO script
>> calling an action that returns a JSON result.
>>
>> It is a search form where the user provides information and the result
>> shall be presented on another page. But I want JSON result back so
>> that I can handle the search result with Ajax using Dojo. E.g.
>> removing results based on filtering done by the user.
>>
>> Cheers!
>>
>> -Christer!
>>
>>
>>
>> -----Opprinnelig melding-----
>> Fra: Musachy Barroso [mailto:musa...@gmail.com]
>> Sendt: 9. februar 2009 20:44
>> Til: Struts Users Mailing List
>> Emne: Re: Problem with JSON Result and Form Submit
>>
>> So you have a page that has a form, and that submits to an action that
>> returns JSON? What is the message that you are talking about? Posting
>> a section of the JSP would also help.
>>
>> musachy
>>
>> On Mon, Feb 9, 2009 at 2:31 PM, Christer Gjerstad
>> <christer.gjers...@gmail.com> wrote:
>>>
>>> Hello everyone,
>>>
>>> Anyone know how to pass post message information from an action
>>> containing a form to an action returning JSON result via an JSP page
>>> with a DOJO script calling the JSON result action? Please see example
>>> below. I am loosing the post message on the way. One solution could
>>> be to get the post message parameters from the value stack and then
>>> pass them into the DOJO script, but this sounds like a non-Struts way to
> me.
>>>
>>> In the book "Practical Apache Struts2 Web 2.0 projects" written by
>>> Ian Roughley (Great book by the way!), chapter 10, there is an
>>> example without passing information into the action. I have based my
>>> solution on this example but cannot get it to work properly.
>>>
>>>
>>> <package name="products" namespace="/products"
>>> extends="struts-default">
>>>
>>>        <!-- ProductSearch Action -->
>>>        <action name="productSearch"
>>> class="com.demand.product.ProductSearch">
>>>                <result>/jsp/product/productSearch.jsp</result>
>>>        </action>
>>>
>>>        <!-- ProductSearchResult Action -->
>>>        <action name="productSearchResult"
>>> class="com.demand.product.BaseProductAction">
>>>                <result
>>> name="input">/jsp/product/productSearch.jsp</result>
>>>
>>>                <result>/jsp/product/productSearchJsonResult.jsp</result>
>>>        </action>
>>>
>>> </package>
>>>
>>> <package name="jsonProducts" namespace="/json/products"
>>> extends="json-default">
>>>        <default-interceptor-ref name="json"/>
>>>        <action name="productsJsonResult"
>>> class="com.demand.product.ProductSearchResults">
>>>                <result type="json">
>>>                        <param name="root">products</param>
>>>                </result>
>>>        </action>
>>>
>>> </package>
>>>
>>>
>>> Cheers!
>>>
>>> - Christer Gjerstad
>>>
>>>
>>>
>>
>>
>>
>> --
>> "Hey you! Would you help me to carry the stone?" Pink Floyd
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>>
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>



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

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

Reply via email to