You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Christer Gjerstad <ch...@idemand.no> on 2009/02/07 14:04:19 UTC
VS: Form Submit & Passing Post Data to Action with JSON Plugin
> Hi,
>
> I have a page with some seach criteria for the user to specify. The result
> of the search will be displayed on another page which will be rendered
> using Dojo script and Json result, using the JSON plugin.
>
> In the book "Practical Apache Struts2 Web 2.0 projects" written by Ian
> Roughley (Great book by the way!). There is an example, chapter 10, for
> handling JSON results from actions with a Dojo script which does not pass
> any input data to the action, which is the case I am trying to do.
>
> So, I have one seach page with a form submitting this with post method to
> a pass-throug action in the same package(defined in struts.xml). The
> pass-through action has a result to the a jsonResult.jsp page where a Dojo
> script is calling the action doing the seach to the business layer and
> returning a JSON result. Please see below for more info. My problem is
> that the post data is not passed into the action class calling the
> business layer and returning the JSON result.
>
> I have search the Web for any ideas or solutions but cannot find anything.
>
>
> How can I get the post data from the search form to the productsJsonResult
> action? Do I have to capture the post data from the request and handle
> that in the Dojo script? Should't the param interceptor handle this?
>
> I would appreciate any help in this matter! :-)
>
>
> Here are the packages and actions.
>
>
> Flow: Submit Search -> productSearchResult action invoked ->
> productSearchJsonResult.jsp called -> Dojo script calling
> productsJsonResult action and handling html rendering.
>
>
>
> <package name="flights" 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>
>
>
>
>
> With kind regards
>
> Christer Gjerstad
>
>
>