you can try the following.
change:
<div id=\'two\' style=\"border: 1px solid yellow;\">initial content</div>
to
<s:div id=\"two\" theme=\"ajax\"> (close this tag after your </s:form>
tag, so that the whole form will be inside the div tag. )

also change:
<s:submit value=\"GO2\" theme=\"ajax\" targets=\"theForm2\"/>
to
>     <s:submit value=\"GO2\" theme=\"ajax\" targets=\"two\"/>

also nowhere in your page (where users enter data) do i see how you
would be displaying the information to the user...even if data wasnt
being submitted to a new page. you can try the following somewhere
inside the <s:div> tag:
<s:actionmessage/>

ofcourse then in your action you will have to do:
addActionMessage(\"Put w/e data you want in here\");

Hopefully it works out for your..



On 2/19/08, xianwinwin <[EMAIL PROTECTED]> wrote:

> Hi all,
> I\'m trying to return a result to DIV in a form (in the example id=\'two\')
>
> this is my form:
>
> <div id=\'two\' style=\"border: 1px solid yellow;\">initial content</div>
> <s:form
>         id=\'theForm2\'
>         cssStyle=\"border: 1px solid green;\"
>         action=\'testing_AjaxRemoteForm\'
>         method=\'post\'
>         theme=\"ajax\">
>
>     <input type=\'text\' name=\'data\' value=\'Struts User\'>
>
>     <s:submit value=\"GO2\" theme=\"ajax\" targets=\"theForm2\"/>
>
> </s:form>
>
> when the user clicks the GO2 --> the action, AjaxRemoteForm,  is \'activated\'
> (showing the \'data\' the user has input)
>
>         public String AjaxRemoteForm()
>         {
>                 System.out.println(\"active ajax test 1 with data: \"+data);
>                 return \"test.ajax.2\";
>         }
>
> and routed to AjaxResult3.jsp:
>
>         <action name=\"testing_*\"  method=\"{1}\"
> class=\"com.struts.user.account.TestingAction\">
>                         <result name=\"test.1\"                   
> type=\"tiles\">test_1</result>
>                         <result 
> name=\"test.ajax.2\">/pages/welcome/AjaxResult3.jsp</result>
>             <interceptor-ref name=\"user\"/>
>         </action>
>
>
>
> The result comes in a NEW page with the \'data\' value the user has input
>
>
>
> \"AjaxResult3.jsp\"
> -----------------
> <%@ taglib prefix=\"s\" uri=\"/struts-tags\" %>
>
> <%
>     request.setAttribute(\"decorator\", \"none\");
>     response.setHeader(\"Cache-Control\",\"no-cache\"); //HTTP 1.1
>     response.setHeader(\"Pragma\",\"no-cache\"); //HTTP 1.0
>     response.setDateHeader (\"Expires\", 0); //prevents caching at the proxy
> server
> %>
>
> The value you entered was: <s:property value=\"data\"/><br/>
>
>
>
>
> Q: How can I incorporate the \'data\' value in the DIV and not in a new page?
> --
> View this message in context: 
> http://www.nabble.com/struts2%3A-simple-ajax-form---returns-value-to-a-new-page-%28not-to-a-DIV%29-tp15562626p15562626.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to