You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Joris Kimpe <jo...@get.be> on 2008/10/17 14:59:10 UTC

How to handle different div's and 1 or more ActionForms

Hello,

I have an application with 2 buttons.  Each button hides/shows a div.  In
each div I want to use the same ActionForm, but different Actions.  Maybe
this can't be done, but I also have problems using a different ActionForm
for each div.

A short overview:
- my initial jsp looks like this:
        ...
        <script language="javascript" type="text/javascript">
        //<![CDATA[
        function startCompleteOrder() {
          	setVisible('completeOrderPopup'); 
               runAjax(<url>, 'completeOrderPopup');
        }
        function startChangeStatus() {
          	setVisible('changeStatusPopup'); 
               runAjax(<url>, 'changeStatusPopup');
        }
        //]]>
        </script>
        ...
	<div id="completeOrderPopup" class="popup">
		<%@include file="completeOrder.jsp"%>
	</div>

	<div id="changeStatusPopup" class="popup">
		<%@include file="changeStatus.jsp"%>
	</div>

	<input class="dataButton" id="changeStatusBtn" type="button" value="Change
status" onclick="startChangeStatus();" />

	<input class="dataButton" id="completeOrderBtn" type="button"
value="Complete order" onclick="startCompleteOrder();" />
        ...



- completeOrder.jsp looks like this:
         <jsp:include page="heading.jsp" flush="true" />
         <%@ taglib uri="struts-bean" prefix="bean" %>
         <%@ taglib uri="struts-html" prefix="html" %>
         <%@ taglib uri="struts-logic" prefix="logic" %>
         <%@ taglib uri="taglib" prefix="tag" %>

	<html:form styleId="statusForm" action="saveCompleteOrder.do">
		<html:hidden name="statusForm" property="barCode" styleId="barCode" />
		...
	</html:form>


- changeStatus.jsp looks like this:
         <jsp:include page="heading.jsp" flush="true" />
         <%@ taglib uri="struts-bean" prefix="bean" %>
         <%@ taglib uri="struts-html" prefix="html" %>
         <%@ taglib uri="struts-logic" prefix="logic" %>
         <%@ taglib uri="taglib" prefix="tag" %>

	<html:form styleId="statusForm" action="saveStatusChange.do">
		<html:hidden name="P080576_changeStatusForm" property="barCode"
styleId="changeStatusBarCode" />
		...
	</html:form>



If I run my application, it sometimes works for changeStatus, sometimes for
completeOrder and sometimes for both.  But I want it to work always...  How
can I use the same ActionForm (or different ActionForms) in multiple divs?

Thanks!
-- 
View this message in context: http://www.nabble.com/How-to-handle-different-div%27s-and-1-or-more-ActionForms-tp20032791p20032791.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to handle different div's and 1 or more ActionForms

Posted by Joris Kimpe <jo...@get.be>.
Thanks Lukasz,

I just found the cause...  I was using the same form id in the different
divs.  I had a jsp included in both divs, and it contained the form bean
(which needs to be different for both divs).




Lukasz Lenart wrote:
> 
> There is some problem with div's inside form, when you want to return
> a content from Ajax call, I think it's only on IE, check that.
> The second though can be duplicated id's for div's or other tags
> 
> 
> Regards
> -- 
> Lukasz
> http://www.lenart.org.pl/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-handle-different-div%27s-and-1-or-more-ActionForms-tp20032791p20085329.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to handle different div's and 1 or more ActionForms

Posted by Lukasz Lenart <lu...@googlemail.com>.
There is some problem with div's inside form, when you want to return
a content from Ajax call, I think it's only on IE, check that.
The second though can be duplicated id's for div's or other tags


Regards
-- 
Lukasz
http://www.lenart.org.pl/

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


Re: How to handle different div's and 1 or more ActionForms

Posted by Joris Kimpe <jo...@get.be>.
Seems like it has something to do with this part of the code:

				<logic:iterate name="statusList" id="status"
type="be.get.xtremis.web.base.util.SelectOption">
					<input type=radio name="statusGroup" value="<%= status.getId()%>"
onchange="changeCostItemState(this);" ><bean:write name="status"
property="description"/>
					&nbsp;&nbsp;
				</logic:iterate>


If I remove this, the code works...  What is wrong here?  It is inside the
form in one of my divs.

Joris



Joris Kimpe wrote:
> 
> The submit action is present...  However, I don't use a submit button, I
> use a button which performs the action using an Ajax call.  I overruled
> the submit, by using onsubmit="return false;" as an form attribute.  Is
> this the reason?
> 
> You are sure it has nothing to do with a div containing the form, and
> inside this form, there are some more divs?
> 
> Thanks!
> 
> 
> Lukasz Lenart wrote:
>> 
>> 2008/10/20 Joris Kimpe <jo...@get.be>:
>>> I know I can use the same form for different actions.  That's what I was
>>> trying to do.  But I'm afraid it has something to do with the different
>>> div
>>> sections.
>> 
>> No, it shouldn't, div's are used only for display and are not
>> submitted to the actions. So check if you defined to separated action,
>> with the same form, also did you created jsp page with two separated
>> html forms with submit inside each
>> 
>> <html:form action="/firstAction">
>>   <html:submit/>
>> </html:form>
>> 
>> <html:form action="/secondAction">
>>   <html:submit/>
>> </html:form>
>> 
>> 
>> Regards
>> -- 
>> Lukasz
>> http://www.lenart.org.pl/
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-handle-different-div%27s-and-1-or-more-ActionForms-tp20032791p20067496.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to handle different div's and 1 or more ActionForms

Posted by Joris Kimpe <jo...@get.be>.
The submit action is present...  However, I don't use a submit button, I use
a button which performs the action using an Ajax call.  I overruled the
submit, by using onsubmit="return false;" as an form attribute.  Is this the
reason?

You are sure it has nothing to do with a div containing the form, and inside
this form, there are some more divs?

Thanks!


Lukasz Lenart wrote:
> 
> 2008/10/20 Joris Kimpe <jo...@get.be>:
>> I know I can use the same form for different actions.  That's what I was
>> trying to do.  But I'm afraid it has something to do with the different
>> div
>> sections.
> 
> No, it shouldn't, div's are used only for display and are not
> submitted to the actions. So check if you defined to separated action,
> with the same form, also did you created jsp page with two separated
> html forms with submit inside each
> 
> <html:form action="/firstAction">
>   <html:submit/>
> </html:form>
> 
> <html:form action="/secondAction">
>   <html:submit/>
> </html:form>
> 
> 
> Regards
> -- 
> Lukasz
> http://www.lenart.org.pl/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-handle-different-div%27s-and-1-or-more-ActionForms-tp20032791p20066715.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to handle different div's and 1 or more ActionForms

Posted by Lukasz Lenart <lu...@googlemail.com>.
2008/10/20 Joris Kimpe <jo...@get.be>:
> I know I can use the same form for different actions.  That's what I was
> trying to do.  But I'm afraid it has something to do with the different div
> sections.

No, it shouldn't, div's are used only for display and are not
submitted to the actions. So check if you defined to separated action,
with the same form, also did you created jsp page with two separated
html forms with submit inside each

<html:form action="/firstAction">
  <html:submit/>
</html:form>

<html:form action="/secondAction">
  <html:submit/>
</html:form>


Regards
-- 
Lukasz
http://www.lenart.org.pl/

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


Re: How to handle different div's and 1 or more ActionForms

Posted by Joris Kimpe <jo...@get.be>.
I know I can use the same form for different actions.  That's what I was
trying to do.  But I'm afraid it has something to do with the different div
sections.

Do you know whether this can be done?  If not, what's the best way to create
the application I want?

Joris



Lukasz Lenart wrote:
> 
> Hi,
> 
> I'm not sure where you have problem, you can define the same form for
> different actions in struts-config.xml
> Each html form has to have input with type submit, that's all.
> I only noticed that you are using action path (saveStatusChange.do)
> instead of action name (/saveStatusChange)
> 
> 
> Regards
> -- 
> Lukasz
> http://www.lenart.org.pl/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-handle-different-div%27s-and-1-or-more-ActionForms-tp20032791p20065673.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to handle different div's and 1 or more ActionForms

Posted by Lukasz Lenart <lu...@googlemail.com>.
Hi,

I'm not sure where you have problem, you can define the same form for
different actions in struts-config.xml
Each html form has to have input with type submit, that's all.
I only noticed that you are using action path (saveStatusChange.do)
instead of action name (/saveStatusChange)


Regards
-- 
Lukasz
http://www.lenart.org.pl/

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