This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes intermediate submit and validation of a form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "intermediate submit and validation of a form" Watch "intermediate submit and validation of a form" New topic
Author

intermediate submit and validation of a form

Padmini Nagarajan
Greenhorn

Joined: May 26, 2005
Posts: 5
Hi,

I have a jsp page with some fields say AA,XX , YY, ZZ
and 2 buttons say Submit and validate.
On click of submit button All fields AA,XX,YY and ZZ are mandatory
And on click of validate button only AA and ZZ are mandatory..
I know tht we can set different actions like this
document.forms[0].action='DDD.do'; and submit the form

I have enabled javascript validation for my form.. and need to trigger client side validation ..
With this senario, How do I define my validation.xml such tht user is prompted to fill the required fields on click of the respective buttons..
Steve Ziegler
Greenhorn

Joined: Jun 27, 2005
Posts: 2
Hi Padmini,

Have you looked into using a LookupDispatchAction to split up your Actions? All relevant code would look like this:

-----

public class YourDispatchAction extends LookupDispatchAction{
protected Map getKeyMethodMap() {
Map map = new HashMap();
map.put("appProperty.submit","submit");
map.put("appProperty.validate","validate");
return map;
}
public ActionForward submit
(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
return mapping.findForward("submit");
}
public ActionForward validate
(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
return mapping.findForward("validate");
}
}

-----

In struts-config:

<action path="/YourDispatchAction" name="yourBeanName" parameter="method" type="packageName.YourDispatchAction">
<forward name="submit" path="/SubmitAction.do"/>
<forward name="validate" path="/ValidateAction.do"/>
</action>

-----
In jsp:

<html:form action="/YourDispatchAction">
...
<html:submit styleClass="submit" property="method">
<fmt:message key="appProperty.submit" />
</html:submit>
<html:submit styleClass="submit" property="method">
<fmt:message key="appProperty.validate" />
</html:submit>
...
</html:form>

-----
In ApplicationResources.properties:

appProperty.validate=Validate
appProperty.submit=Submit

-----

This way, you can use the LookupDispatchAction to branch to two other actions, SubmitAction and ValidateAction. Once you have that, you can just create different validations for those two seperate actions. Good luck!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: intermediate submit and validation of a form
 
Similar Threads
Cancel button and bypassing JavaScript validation
Bypass client-side struts validation
struts 2 validation problem
LookupDispatchAction + html:cancel
problem using validator framework with DispatchAction