Re: Disable validate in actionForm

2004-08-18 Thread Rick Reumann
Sebastian Ho wrote:
I suppose this is how I do it?
 html:submit property=action value=Create Experiment
  bean:message key=button.createexperiment/
  html:hidden property=selection
value=createexperiment /
/html:submit
Why don't you just use a cancel button and then validate won't be 
called? You can still label the cancel button as Back and it will 
submit to your action.

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


Disable validate in actionForm

2004-08-17 Thread Sebastian Ho
hi

I have an validate method in my actionform and everything works fine. I
added a 'Back' button in my webpage, and therefore validation is not
necessary if the 'Back' button is clicked. Validation should occurs only
if 'Next' is selected.

How do I stop struts from calling validate() is 'Back' is selected?

Note : Both buttons are in the same form.

Thanks

Sebastian


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



RE: Disable validate in actionForm

2004-08-17 Thread Aru
Sebestian,
Where does control go when u click Back button? If this has to do 'browser
like' back action, just call javascript. Why do u call struts action? Any
specific reason?



-Original Message-
From: Sebastian Ho [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 17, 2004 3:44 PM
To: Struts Users Mailing List
Subject: Disable validate in actionForm

hi

I have an validate method in my actionform and everything works fine. I
added a 'Back' button in my webpage, and therefore validation is not
necessary if the 'Back' button is clicked. Validation should occurs only
if 'Next' is selected.

How do I stop struts from calling validate() is 'Back' is selected?

Note : Both buttons are in the same form.

Thanks

Sebastian


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



RE: Disable validate in actionForm

2004-08-17 Thread Sebastian Ho
Hi

I think my situtation is kinda unique..
I have three buttons in a single form and my Action extends
LookupDispatchAction.

In my ExperimentForm (actionform), how do I disable validate if 'back'
is clicked?


struts-config.xml
--
action name=experimentForm path=/NewExperiment
input=CreateExperiment.jsp parameter=action scope=request
type=sg.edu.astar.flamingo.web.proteomics.view.NewExperimentAction
  forward name=addexperiment path=/CreateExperiment.do/
  forward name=next path=/CreateProjectSummary.do/
  forward name=back path=/CreateProject.do/
/action

CreateExperiment.jsp
-
html:submit property=action value=Back
  bean:message key=button.back/
/html:submit
/html:submit

html:submit property=action value=Create Experiment
  bean:message key=button.createexperiment/
/html:submit

html:submit property=action value=Next
  bean:message key=button.next/
/html:submit

applicationresources.properties

button.createexperiment=Create Experiment
button.next=Next
button.back=Back

NewExperimentAction.java
---
public class NewExperimentAction extends LookupDispatchAction 
{
  /**
   * This is the main action called from the Struts framework.
   * @param mapping The ActionMapping used to select this instance.
   * @param form The optional ActionForm bean for this request.
   * @param request The HTTP Request we are processing.
   * @param response The HTTP Response we are processing.
   * @return 
   * @throws java.io.IOException
   * @throws javax.servlet.ServletException
   */
 // public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException
  //{
   // return mapping.findForward(success);
 // }
 
 protected Map getKeyMethodMap() 
 {
  Map map = new HashMap();
 map.put(button.createexperiment, createExperiment);
 map.put(button.next, next);
 map.put(button.back, back);
 return map;
 }
 
 public ActionForward next(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException
 {
 System.out.println(next());
 return mapping.findForward(next);
 }
 
 public ActionForward back(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException
 {
 System.out.println(back());
 return mapping.findForward(back);
 }
 
  public ActionForward createExperiment(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse
response) throws IOException, ServletException
  {
  
  ExperimentForm experiment = (ExperimentForm) form;
  HttpSession session = request.getSession();
   Vector experiments =  (Vector) session.getAttribute(experiments);
  experiments.add(experiment);
  
return mapping.findForward(addexperiment);
  }
 
}







On Tue, 2004-08-17 at 15:47, Kataria, Satish wrote:
 Map it to a different actionMapping and set validate=fasle;
 ie the submit and back button should have a different actionmapping
 
 Satish
 
 -Original Message-
 From: Sebastian Ho [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, August 17, 2004 1:14 PM
 To: Struts Users Mailing List
 Subject: Disable validate in actionForm
 
 
 hi
 
 I have an validate method in my actionform and everything works fine. I
 added a 'Back' button in my webpage, and therefore validation is not
 necessary if the 'Back' button is clicked. Validation should occurs only
 if 'Next' is selected.
 
 How do I stop struts from calling validate() is 'Back' is selected?
 
 Note : Both buttons are in the same form.
 
 Thanks
 
 Sebastian
 
 
 -
 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]



RE: Disable validate in actionForm

2004-08-17 Thread Sebastian Ho
Tried javascript and it works fine. The reasons I try not to use
javascript :

1. since struts is used, i thought all control should be visible in the
controller and not as javascripts in the JSP.

2. User might turn off javascript.

sebastian ho


On Tue, 2004-08-17 at 15:57, Aru wrote:
 Sebestian,
   Where does control go when u click Back button? If this has to do 'browser
 like' back action, just call javascript. Why do u call struts action? Any
 specific reason?
 
 
 
 -Original Message-
 From: Sebastian Ho [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, August 17, 2004 3:44 PM
 To: Struts Users Mailing List
 Subject: Disable validate in actionForm
 
 hi
 
 I have an validate method in my actionform and everything works fine. I
 added a 'Back' button in my webpage, and therefore validation is not
 necessary if the 'Back' button is clicked. Validation should occurs only
 if 'Next' is selected.
 
 How do I stop struts from calling validate() is 'Back' is selected?
 
 Note : Both buttons are in the same form.
 
 Thanks
 
 Sebastian
 
 
 -
 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]



RE: Disable validate in actionForm

2004-08-17 Thread Richard Aukland
Sebastien,

I use this technique, it works but i dont know if it is 'good
practice'

1. Change your 'back' button from a submit to a cancel button
(thereby avoiding validation)
2. Set the action of the button to 'previous' using javascript .
3. pick up the 'previous' in a DispatchAction class and forward to
appropriate place.

Note that if you use LookUpDispatchAction i think you may be able to
avoid the javascript.

regards

Richard
Richard Aukland
49 Ravensmere, Beccles, 
Suffolk, UK. NR34 9BE
Tel/Fax. +44(0)1502 470162
Cell.+44(0)7906 094578
mailto:  [EMAIL PROTECTED]
http://www.aukinfo.com



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



RE: Disable validate in actionForm

2004-08-17 Thread Sebastian Ho
Thanks Richard

I fixed the Back problem using javascript (using javascript
history.back()). Although it is resolved, I am still very much
interested in the struts solution without using javascript.

sebastian


On Tue, 2004-08-17 at 18:46, Richard Aukland wrote:
 Sebastien,
 
 I use this technique, it works but i dont know if it is 'good
 practice'
 
 1. Change your 'back' button from a submit to a cancel button
 (thereby avoiding validation)
 2. Set the action of the button to 'previous' using javascript .
 3. pick up the 'previous' in a DispatchAction class and forward to
 appropriate place.
 
 Note that if you use LookUpDispatchAction i think you may be able to
 avoid the javascript.
 
 regards
 
 Richard
 Richard Aukland
 49 Ravensmere, Beccles, 
 Suffolk, UK. NR34 9BE
 Tel/Fax. +44(0)1502 470162
 Cell.+44(0)7906 094578
 mailto:  [EMAIL PROTECTED]
 http://www.aukinfo.com
 
 
 
 -
 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]



RE: Disable validate in actionForm

2004-08-17 Thread Pavel Kolesnikov
On Tue, 17 Aug 2004, Sebastian Ho wrote:

 I fixed the Back problem using javascript (using javascript
 history.back()). Although it is resolved, I am still very much
 interested in the struts solution without using javascript.

what about checking for the back property in your
validate method (as i wrote few mails ago)?

according to your description of CreateExperiment.jsp just
change the proposed code to:

8 snip -
public ActionErrors validate ( ... ) {
if (! back.equals (getAction ()) ) {
super.validate ( ... );
// another validations if needed
}
}
8 snip -

i still suppose you have defined property action 
in your form bean.

pavel


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



RE: Disable validate in actionForm

2004-08-17 Thread Sebastian Ho
I suppose this is how I do it?

 html:submit property=action value=Create Experiment
  bean:message key=button.createexperiment/
  html:hidden property=selection
value=createexperiment /
/html:submit

And in my ActionForm :

if(getSelection().equals(createexperiment)) {
//validate
}

But getSelection returns me a null and I don't know why..

Sebastian


On Tue, 2004-08-17 at 20:44, Pavel Kolesnikov wrote:
 On Tue, 17 Aug 2004, Sebastian Ho wrote:
 
  I fixed the Back problem using javascript (using javascript
  history.back()). Although it is resolved, I am still very much
  interested in the struts solution without using javascript.
 
 what about checking for the back property in your
 validate method (as i wrote few mails ago)?
 
 according to your description of CreateExperiment.jsp just
 change the proposed code to:
 
 8 snip -
 public ActionErrors validate ( ... ) {
   if (! back.equals (getAction ()) ) {
   super.validate ( ... );
   // another validations if needed
   }
 }
 8 snip -
 
 i still suppose you have defined property action 
 in your form bean.
 
 pavel
 
 
 -
 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]