Thank you. That helped but still can not submit a form using an anchor out side that form. The fields are not populated in the action.

The code on the Site :

Using the anchor tag to submit a form:

<s:form id="form1">
 <input type="textbox" name="data">   
</s:form>

<s:url id="ajaxTest" value="/AjaxTest.action" />

<s:a theme="ajax" href="%{ajaxTest}" formId="form1">Submit form</s:a>




My code:

<s:head theme="ajax"></s:head>

<table>
        <tr>

                <td>
                        <s:a href="javascript://" 
onclick="changeState(true);">edit</s:a>
                <td>
                        <s:url id="ajaxSubmit" 
value="/updateAccount.action"></s:url>
                        <s:a theme="ajax" href="%{ajaxSubmit}" formId="MyData" 
onclick="changeState(false);"> save </s:a>
                </td>
        </tr>
</table>



<table id="data_table">
        <s:form id="MyData">
                <tr>
                        <td><s:label value="AccId:" /></td>
                        <td><s:property value="acc.id" /> <s:hidden 
name="acc.id"
                                value="%{acc.id}" id="acc.id" /></td>
                </tr>

                <tr>
                        <td><s:label value="First Name" /></td>
                        <td><s:textfield name="acc.firstName" disabled="true" 
value="${acc.firstName}" /></td>
                </tr>

</s:form>
</table>


That's not a big deal as I can move the anchors inside the form, but may be I am missing something here.




Jeromy Evans wrote:
Ensure you've included <s:head theme="ajax"> to include the required javascript and try turning on ajax debugging (<s:head theme="ajax" debug="true">). Ensure the javascript exists in your html.
See the top of http://struts.apache.org/2.x/docs/ajax-tags.html

Mansour wrote:
I am populating some fields that can be edited and saved. Trying to do this using ajax. The action is getting called but the form is never submitted, and the updated data is lost.


<table id="data_table" >
<s:form id="MyData" action="updateAccount" >
   <tr>
       <td>
           <s:label value="AccId:"  />
       </td>
       <td>
           <s:property value="acc.id"    />
           <s:hidden name="acc.id" value="%{acc.id}" id="acc.id" />
       </td>
   </tr>

   <tr>
       <td><s:label value="First Name"  /></td>
<td><s:textfield name="acc.firstName" value="${acc.firstName}" /></td>
   </tr>
</td>

</table>

<s:url id="ajaxSubmit" value="/updateAccount.action" />
<s:a theme="ajax" href="%{ajaxSubmit}" formId="MyData"> save </s:a>



Am I missing something ?





---------------------------------------------------------------------
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]




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

Reply via email to