I do this to pass parameters, using prototype js:

<s:set name="foo" value="%{'door' + door.id}"/>
        <s:set name="form_name" value="%{'form_door' + door.id}"/>

        <s:set name="door_description" value="getText(#foo)"/>
        <s:if test="door.state == 1">
                <s:url id="door_url" action="unlock"><s:param name="door.id"
value="door.id"/></s:url>
                <s:form method="POST" action="unlock" id="%{#form_name}"
onsubmit="return false;">
                        <s:hidden name="door.id"/>
                        <s:hidden name="door.state"/>
                        <s:url var="locked_image"
value="/pages/door-control/images/locked.png" />
                        <s:submit type="image" alt="Locked"
src="%{locked_image}" onclick="%{'new Ajax.Updater(\\'' + #foo +'\\', \\'' +
#door_url + '\\', {evalScripts: true}); return false;'}"/>
                </s:form>

</s:if>

>-----Original Message-----
>From: Struts Two [mailto:struts...@yahoo.ca]
>Sent: Tuesday, October 27, 2009 9:24 AM
>To: Struts Users Mailing List
>Subject: Re: Adding Json to existing action
>
>You can either use Json plugin or write your own customized result type
>that return JSON.
>
>--- On Tue, 10/27/09, Michael Varlik <m.var...@gmx.de> wrote:
>
>> From: Michael Varlik <m.var...@gmx.de>
>> Subject: Adding Json to existing action
>> To: user@struts.apache.org
>> Received: Tuesday, October 27, 2009, 1:07 PM
>> Hi,
>>
>> I need to call an existing struts action within my
>> application from a
>> JavaScript function. I thought it might be possible to
>> create an additional entry in the struts mapping file like
>> this:
>>
>> <action name="getDataJson"
>> class="com.mypackage.MyAction" method="getData">
>> <result type="json" />
>> </action>
>>
>> and then call the action with "getDataJson.action".
>> Unfortunately, when I try this a NullPointerException
>> occurs in the action code. It seems, some parameters are not
>> properly initialized.
>>
>> What I'd like to know is: what is the recommendet way of
>> calling an existing action to get JSON results? Is it a good
>> idea to do this at all?
>>
>> Cheers,
>> Markus
>> --
>> Neu: GMX DSL bis 50.000 kBit/s und 200,- Euro
>> Startguthaben!
>> http://portal.gmx.net/de/go/dsl02
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>>
>
>
>      __________________________________________________________________
>Looking for the perfect gift? Give the gift of Flickr!
>
>http://www.flickr.com/gift/
>
>---------------------------------------------------------------------
>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

Reply via email to