You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mansour <ma...@yahoo.com> on 2007/06/24 05:54:27 UTC

Submitting a form with ajax submit inside the form

 From the documentation 
http://struts.apache.org/2.0.8/docs/ajax-tags.html#AjaxTags-submitTag

If the submit button is used inside a form (href is not required on this 
case), the form will be submitted asynchronously:

This is note true. It can never submit from inside a form. This will 
never anything. It will never make any thing. I am using 2.0.6

<s:iterator value="taskList" status="stat" id="row">

<s:form action="updateTask" id="form_${id}">
    <s:if test="#stat.odd == true">
        <tr class="odd">
    </s:if>
    <s:else>
        <tr class="even">
    </s:else>

    <div id="DIV_${id}">
    <td>
        <s:textfield value="${id}" name="task.id" />
    </td>

    <td>
        <s:submit theme="ajax"  />
    </td>
   
    </div>
    </tr>
</s:form>
 </s:iterator>






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


Re: Submitting a form with ajax submit inside the form

Posted by Musachy Barroso <mu...@gmail.com>.
Sometimes it helps to just ask "what is wrong with my setup?" instead of
stating "this does not work" (which might be true, but not on this case).
Consider looking at the examples in showcase.

regards
musachy

On 6/23/07, Mansour <ma...@yahoo.com> wrote:
>
> From the documentation
> http://struts.apache.org/2.0.8/docs/ajax-tags.html#AjaxTags-submitTag
>
> If the submit button is used inside a form (href is not required on this
> case), the form will be submitted asynchronously:
>
> This is note true. It can never submit from inside a form. This will
> never anything. It will never make any thing. I am using 2.0.6
>
> <s:iterator value="taskList" status="stat" id="row">
>
> <s:form action="updateTask" id="form_${id}">
>     <s:if test="#stat.odd == true">
>         <tr class="odd">
>     </s:if>
>     <s:else>
>         <tr class="even">
>     </s:else>
>
>     <div id="DIV_${id}">
>     <td>
>         <s:textfield value="${id}" name="task.id" />
>     </td>
>
>     <td>
>         <s:submit theme="ajax"  />
>     </td>
>
>     </div>
>     </tr>
> </s:form>
> </s:iterator>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


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

Re: Submitting a form with ajax submit inside the form

Posted by Mansour <ma...@yahoo.com>.
Now this wont make any sense.  I added the theme attr to the form, and 
it's working on all the buttons except the first one in the list!

Here' my code:

<table id="row">
    <thead>
        <tr>
            <th>Task Id</th>
            <th>Service Name</th>
            <th>Unit Count</th>
            <th>Rate/Unit</th>
            <th>cost</th>
            <th>Edit</th>
            <th>Save</th>
        </tr>
    </thead>
    <tbody>
        <s:iterator value="taskList" status="stat" id="row">
            <s:form action="updateTask" id="form_${id}"
                method="post"  theme="ajax">
                <s:if test="#stat.odd == true">
                    <tr class="odd">
                </s:if>
                <s:else>
                    <tr class="even">
                </s:else>
                <div id="DIV_${id}">
                <td><s:textfield value="${id}" name="task.id" /></td>
                <td><s:submit theme="ajax" /></td>
                </div>
                </tr>
            </s:form>
        </s:iterator>
    </tbody>
</table>

I have three in my testing list that I would like to update and save 
through an action. The second and third items are firing a request but 
not the first one. They are all generated in a loop and have the same code !






Mansour wrote:
> Dave Newton wrote:
>> --- Mansour <ma...@yahoo.com> wrote:
>>  
>>> How do I know if there is traffic on the wire?
>>>     
>>
>> Use Live HTTP Headers, Firebug, Ethereal, etc.
>>   
> I used Live HTTP Headers, and there's nothing on the wire. There's no 
> request.
>> Did you say that the action worked in a non-Ajaxily?
>>   
>
> Yes if I remove the ajax theme, it works fine. This will work:
>                <td><s:submit type="button"  /></td>
> This will never work:
>                <td><s:submit type="button"  theme="ajax"/></td>
>
>> d.
>>
>>
>>       
>> ____________________________________________________________________________________ 
>>
>> Shape Yahoo! in your own image.  Join our Network Research Panel 
>> today!   http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>   
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


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


Re: Submitting a form with ajax submit inside the form

Posted by Mansour <ma...@yahoo.com>.
Dave Newton wrote:
> --- Mansour <ma...@yahoo.com> wrote:
>   
>> How do I know if there is traffic on the wire?
>>     
>
> Use Live HTTP Headers, Firebug, Ethereal, etc.
>   
I used Live HTTP Headers, and there's nothing on the wire. There's no 
request.
> Did you say that the action worked in a non-Ajaxily?
>   

Yes if I remove the ajax theme, it works fine. This will work:
                <td><s:submit type="button"  /></td>
This will never work:
                <td><s:submit type="button"  theme="ajax"/></td>

> d.
>
>
>       ____________________________________________________________________________________
> Shape Yahoo! in your own image.  Join our Network Research Panel today!   http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   


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


Re: Submitting a form with ajax submit inside the form

Posted by Dave Newton <ne...@yahoo.com>.
--- Mansour <ma...@yahoo.com> wrote:
> How do I know if there is traffic on the wire?

Use Live HTTP Headers, Firebug, Ethereal, etc.

Did you say that the action worked in a non-Ajaxily?

d.


      ____________________________________________________________________________________
Shape Yahoo! in your own image.  Join our Network Research Panel today!   http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 



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


Re: Submitting a form with ajax submit inside the form

Posted by Mansour <ma...@yahoo.com>.
Dave, the generated IDs are correct. There's the resulting HTML , I dont 
see what's wrong with this.

<table id="row">

	<thead>
		<tr>
			<th>Task Id</th>
			<th>Service Name</th>
			<th>Unit Count</th>
			<th>Rate/Unit</th>
			<th>cost</th>

			<th>Edit</th>
			<th>Save</th>
		</tr>
	</thead>
	<tbody>
		
			<form namespace="/" id="form_3" name="updateTask" action="/fe/updateTask.action" method="post" 
>
<table class="wwFormTable">
				
					<tr class="odd">

				
				
				<div id="DIV_3">
				<td><tr>
    <td class="tdLabel"></td>
    <td
><input type="text" name="task.id" value="3" id="form_3_task_id"/>
</td>
</tr>
</td>
				<td><tr>
    <td colspan="2"><div align="right">    <input type="submit" dojoType="struts:Bind" event="onclick"     value="Submit"  
  	id="form_3_0"  />

</div></td>
</tr>
</td>
				</div>
				</tr>
			

<!-- javascript that is needed for tooltips -->
<script type="text/javascript">dojo.require("dojo.widget.Tooltip");dojo.require("dojo.fx.html");</script>

</table>
</form>

		
			<form namespace="/" id="form_1" name="updateTask" action="/fe/updateTask.action" method="post" 
>

<table class="wwFormTable">
				
				
					<tr class="even">
				
				<div id="DIV_1">
				<td><tr>
    <td class="tdLabel"></td>
    <td
><input type="text" name="task.id" value="1" id="form_1_task_id"/>
</td>
</tr>
</td>
				<td><tr>
    <td colspan="2"><div align="right">    <input type="submit" dojoType="struts:Bind" event="onclick"     value="Submit"  
  	id="form_1_0"  />

</div></td>
</tr>
</td>
				</div>
				</tr>
			

<!-- javascript that is needed for tooltips -->
<script type="text/javascript">dojo.require("dojo.widget.Tooltip");dojo.require("dojo.fx.html");</script>

</table>
</form>

		
			<form namespace="/" id="form_2" name="updateTask" action="/fe/updateTask.action" method="post" 
>

<table class="wwFormTable">
				
					<tr class="odd">
				
				
				<div id="DIV_2">
				<td><tr>
    <td class="tdLabel"></td>
    <td
><input type="text" name="task.id" value="2" id="form_2_task_id"/>
</td>
</tr>
</td>
				<td><tr>
    <td colspan="2"><div align="right">    <input type="submit" dojoType="struts:Bind" event="onclick"     value="Submit"  
  	id="form_2_0"  />

</div></td>
</tr>
</td>
				</div>
				</tr>
			

<!-- javascript that is needed for tooltips -->
<script type="text/javascript">dojo.require("dojo.widget.Tooltip");dojo.require("dojo.fx.html");</script>

</table>
</form>

		


	</tbody>

</table>




Dave Newton wrote:
> --- Dave Newton <ne...@yahoo.com> wrote:
>   
>> This should cause a form ID collision, which shows a
>> debug msg, since you'll have multiple forms with the
>> same ID.
>>     
>
> Whoops, didn't see you were iterating over tasks,
> which presumably have an ID, so I assume the form IDs
> are being generated properly?
>
> d.
>
>
>
>  
> ____________________________________________________________________________________
> Be a PS3 game guru.
> Get your game face on with the latest PS3 news and previews at Yahoo! Games.
> http://videogames.yahoo.com/platform?platform=120121
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   


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


Re: Submitting a form with ajax submit inside the form

Posted by Mansour <ma...@yahoo.com>.
Dave Newton wrote:
> --- Dave Newton <ne...@yahoo.com> wrote:
>   
>> This should cause a form ID collision, which shows a
>> debug msg, since you'll have multiple forms with the
>> same ID.
>>     
>
> Whoops, didn't see you were iterating over tasks,
> which presumably have an ID, so I assume the form IDs
> are being generated properly?
>
> d.
>
>
>
>  
> ____________________________________________________________________________________
> Be a PS3 game guru.
> Get your game face on with the latest PS3 news and previews at Yahoo! Games.
> http://videogames.yahoo.com/platform?platform=120121
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   
These are the debug msgs I just got:
DEBUG: DEPRECATED: dojo.style replaced by dojo.html.style -- will be 
removed in version: 0.5
DEBUG: DEPRECATED: dojo.animation.AnimationEvent is slated for removal 
in 0.5; use dojo.lfx.* instead. 0.5
DEBUG: DEPRECATED: dojo.animation.Animation is slated for removal in 
0.5; use dojo.lfx.* instead. 0.5
DEBUG: DEPRECATED: dojo.animation.AnimationSequence is slated for 
removal in 0.5; use dojo.lfx.* instead. 0.5
DEBUG: DEPRECATED: dojo.Animation.* is slated for removal in 0.5; use 
dojo.lfx.* instead. 0.5
DEBUG: DEPRECATED: dojo.graphics.color.Color is now 
dojo.gfx.color.Color. 0.5




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


Re: Submitting a form with ajax submit inside the form

Posted by Dave Newton <ne...@yahoo.com>.
--- Dave Newton <ne...@yahoo.com> wrote:
> This should cause a form ID collision, which shows a
> debug msg, since you'll have multiple forms with the
> same ID.

Whoops, didn't see you were iterating over tasks,
which presumably have an ID, so I assume the form IDs
are being generated properly?

d.



 
____________________________________________________________________________________
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121

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


Re: Submitting a form with ajax submit inside the form

Posted by Dave Newton <ne...@yahoo.com>.
--- Mansour <ma...@yahoo.com> wrote:
> No, there are no msgs in the debug mode.

None?

> <s:iterator value="taskList" status="stat" id="row">
>   <s:form action="updateTask" id="form_${id}">

This should cause a form ID collision, which shows a
debug msg, since you'll have multiple forms with the
same ID.

My test form still works, though.

> <td><s:submit theme="ajax" /></td>

Is this using the original <s:submit.../> template, or
the one you've been trying to create?

What does the generated HTML look like? I can't even
come close to duplicating this issue.

d.



       
____________________________________________________________________________________
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more. 
http://mobile.yahoo.com/go?refer=1GNXIC

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


Re: Submitting a form with ajax submit inside the form

Posted by Mansour <ma...@yahoo.com>.
Dave Newton wrote:
> --- Mansour <ma...@yahoo.com> wrote:
>   
>> If the submit button is used inside a form (href is
>> not required on this case), the form will be 
>> submitted asynchronously:
>>
>> This is note true. It can never submit from inside a
>> form. This will  never anything. It will never make 
>> any thing. I am using 2.0.6
>>     
>
> I'm pretty sure it *is* true, as I have several Ajax
> forms built precisely in this way.
>
> You have your <s:head.../>? Any msgs if in debug mode?
>   
No, there are no msgs in the debug mode. And yes I have this : <s:head 
theme="ajax" debug="true" />

> Any traffic on the wire when you hit submit? 
I dont see anything changing. I set a break point in the action but 
nothing happens.
How do I know if there is traffic on the wire?

> Why not move to 2.0.8?
>   
I didn't want to because I started already with 2.0.6 and was thinking 
of migrating after I finnish this project. However, I did it already and 
I am using 2.0.8 hopefully it fixes my problem. BUT NO LUCK.

Here's as part of my code:

<table id="row">
    <thead>
        <tr>
            <th>Task Id</th>
            <th>Service Name</th>
            <th>Unit Count</th>
            <th>Rate/Unit</th>
            <th>cost</th>
            <th>Edit</th>
            <th>Save</th>
        </tr>
    </thead>
    <tbody>
        <s:iterator value="taskList" status="stat" id="row">
            <s:form action="updateTask" id="form_${id}">
                <s:if test="#stat.odd == true">
                    <tr class="odd">
                </s:if>
                <s:else>
                    <tr class="even">
                </s:else>
                <div id="DIV_${id}">
                <td><s:textfield value="${id}" name="task.id" /></td>
...
...
                <td><s:submit theme="ajax" /></td>
                </div>
                </tr>
            </s:form>
        </s:iterator>
    </tbody>
</table>


> d.
>
>
>
>        
> ____________________________________________________________________________________
> Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online.
> http://smallbusiness.yahoo.com/webhosting 
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   


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


Re: Submitting a form with ajax submit inside the form

Posted by Dave Newton <ne...@yahoo.com>.
--- Mansour <ma...@yahoo.com> wrote:
> If the submit button is used inside a form (href is
> not required on this case), the form will be 
> submitted asynchronously:
> 
> This is note true. It can never submit from inside a
> form. This will  never anything. It will never make 
> any thing. I am using 2.0.6

I'm pretty sure it *is* true, as I have several Ajax
forms built precisely in this way.

You have your <s:head.../>? Any msgs if in debug mode?
Any traffic on the wire when you hit submit? Why not
move to 2.0.8?

d.



       
____________________________________________________________________________________
Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online.
http://smallbusiness.yahoo.com/webhosting 

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