File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Calling action with two nested forms Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Calling action with two nested forms" Watch "Calling action with two nested forms" New topic
Author

Calling action with two nested forms

Mike Payton
Greenhorn

Joined: Aug 06, 2012
Posts: 5
Can we have two nested froms calling the same action?

Is it possible ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

No. That would not be valid HTML markup.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mike Payton
Greenhorn

Joined: Aug 06, 2012
Posts: 5
What possible option I can have to obtain this
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

That very much depends on what you are trying to accomplish. What's your actual goal?
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

and Welcome to JavaRanch Mike Payton :)
Mike Payton
Greenhorn

Joined: Aug 06, 2012
Posts: 5
I have an if condition, Based on that I need to generate a popup for printing some PDFs.

Here is the code

<HTML:form action="action.do" >
<% if(condition()) {%>
<span>
<input type="button" onclick="javascript:cancel1()" property="" Class = "bSwan" tabindex="7" value="Cancel" />
<input type="button" id="submit" property="" Class = "bSwan" tabindex="7" value="save" />
<div id="pay_dialog" title="Dialog Title">

<form id="auth_form">
<input type="button" value="Print Authorization Form" id="printpdf" property="" Class = "bSwan" tabindex="7" />
<input type="submit" value="Submit" id="submit_form" property="" Class = "bSwan" tabindex="7" />
</form>
</div>
</span>
<%}else{%>
<span>
<input type="button" onclick="javascript:cancel1()" property="" Class = "bSwan" tabindex="7" value="Cancel" />


<html:submit property="" styleClass = "bSwan" onclick="" tabindex="7">
<bean:message key="global.button.Save" />
</html:submit>
</span>
<% } %>

</HTML:form>


Can I have <form id="auth_form" action="action.do"> ?

I mean in both the condition I need the same value on form to be submitted to the same action.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

AH, you are using Struts. I'll move this over to he Struts forum.

You can have as many forms as you want, you just cannot nest them.
Mike Payton
Greenhorn

Joined: Aug 06, 2012
Posts: 5
So I should take out the inside form and can call the same action ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

Any form can have any action. The contents of the form will be submitted to the form's action. It doesn't matter if multiple forms have the same action; they are independent submissions.
Mike Payton
Greenhorn

Joined: Aug 06, 2012
Posts: 5
Thank you.Bear Bibeault
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling action with two nested forms