Re: Override Input Form / JSP when Errors Are Encountered

2001-05-09 Thread William Jaynes



Use 'validate="false"' as an action attribute to 
prevent a return to the input page after a failed validate. Struts will continue 
on to the action, and you'll need to decide what to do there.

  - Original Message - 
  From: 
  Jeff 
  Trent 
  To: [EMAIL PROTECTED] 
  
  Sent: Tuesday, May 08, 2001 3:16 PM
  Subject: Override Input Form / JSP when 
  Errors Are Encountered
  
  When validate() returns an error collection, the 
  framework takes me back to the input page (page1). How do I override 
  this? I have a multi-page input wizard as shown below. I'd like to 
  stay on the page that resulted in the error instead of going back to page 
  1.
  
   action 
  path="/someWizard" 
  type="com.x.WizardAction" 
  name="wizardForm" 
  scope="session" 
  input="/page1.jsp" 
  forward 
  name="page2" 
  path="/page2.jsp"/ 
  forward name="page3" 
  path="/page3.jsp"/ /action


Re: Override Input Form / JSP when Errors Are Encountered

2001-05-09 Thread Jeff Trent



Ah, okay. So I should call validate() within 
the action class directly then? I'll play around with this 
approach.

  - Original Message - 
  From: 
  William 
  Jaynes 
  To: [EMAIL PROTECTED] 
  Sent: Wednesday, May 09, 2001 6:58 
  AM
  Subject: Re: Override Input Form / JSP 
  when Errors Are Encountered
  
  Use 'validate="false"' as an action attribute to 
  prevent a return to the input page after a failed validate. Struts will 
  continue on to the action, and you'll need to decide what to do 
  there.
  
- Original Message - 
From: 
Jeff 
Trent 
To: [EMAIL PROTECTED] 

Sent: Tuesday, May 08, 2001 3:16 
PM
Subject: Override Input Form / JSP when 
Errors Are Encountered

When validate() returns an error collection, 
the framework takes me back to the input page (page1). How do I 
override this? I have a multi-page input wizard as shown below. 
I'd like to stay on the page that resulted in the error instead of going 
back to page 1.

 action 
path="/someWizard" 
type="com.x.WizardAction" 
name="wizardForm" 
scope="session" 
input="/page1.jsp" 
forward 
name="page2" 
path="/page2.jsp"/ 
forward 
name="page3" 
path="/page3.jsp"/ /action


RE: Override Input Form / JSP when Errors Are Encountered

2001-05-09 Thread Nanduri, Amarnath



In 
that case try to move your validation into the Action class. 


  -Original Message-From: Jeff Trent 
  [mailto:[EMAIL PROTECTED]]Sent: Tuesday, May 08, 2001 5:13 
  PMTo: [EMAIL PROTECTED]Subject: Re: 
  Override Input Form / JSP when Errors Are Encountered
  That doesn't work - that is my problem. I 
  don't have a chance to do this in my Action class since the presence of errors 
  generated in form.validate() triggers an immediate response by the framework 
  and redirection occurs automagically to the input form (page 1), not the page 
  which caused the error (eg page 2).
  
  
- Original Message - 
From: 
Nanduri, Amarnath 
To: '[EMAIL PROTECTED]' 

Sent: Tuesday, May 08, 2001 3:56 
PM
Subject: RE: Override Input Form / JSP 
when Errors Are Encountered


instead of mapping.findForward(mapping.getInput() ) 
use mapping.findForward("page2 or page3") 
;

  -Original Message-From: Jeff Trent [mailto:[EMAIL PROTECTED]]Sent: 
  Tuesday, May 08, 2001 3:17 PMTo: [EMAIL PROTECTED]Subject: 
  Override Input Form / JSP when Errors Are Encountered
  When validate() returns an error collection, 
  the framework takes me back to the input page (page1). How do I 
  override this? I have a multi-page input wizard as shown 
  below. I'd like to stay on the page that resulted in the error 
  instead of going back to page 1.
  
   
  action 
  path="/someWizard" 
  type="com.x.WizardAction" 
  name="wizardForm" 
  scope="session" 
  input="/page1.jsp" 
  forward 
  name="page2" 
  path="/page2.jsp"/ 
  forward 
  name="page3" 
  path="/page3.jsp"/ 
  /action


RE: Override Input Form / JSP when Errors Are Encountered

2001-05-09 Thread Hicks, James



exactly

James 
Hicks

  -Original Message-From: Jeff Trent 
  [mailto:[EMAIL PROTECTED]]Sent: Tuesday, May 08, 2001 7:28 
  PMTo: [EMAIL PROTECTED]Subject: Re: 
  Override Input Form / JSP when Errors Are Encountered
  Interesting approach. Let me see if I can 
  explain this back to you to make sure I understand what you are 
  saying:
  
  Does your Wizard.jsp look something like 
  this:
  
  template:insert 
  template='/template.jsp' template:put name='header' 
  content='/header.html' / template:put name='sidebar' 
  content='/sidebar.jsp' /logic:equalproperty='page' 
  value='1'
template:put 
  name='content' content='/wizardPage1.jsp'/
  /logic:equal...
  logic:equalproperty='page' 
  value='N'
template:put 
  name='content' content='/wizardPageN.jsp'/
  /logic:equal 
  template:put name='footer' content='/footer.html' 
  //template:insert
  
  And somewhere at the top you have some logic to 
  determine which page your on based on direction and error 
  conditions?
  
  *** I'm starting to feel like I'm at battle with 
  struts! There must be a way I can hook the error checking logic to 
  circumvent the redirect to the base input form. I guess its time to dig 
  thru the source code. What bothers me the most is that I feel like I'm 
  not doing anything outrageous here.
  
  - jeff
  
  
- Original Message - 
From: 
Hicks, James 
To: '[EMAIL PROTECTED]' 

Sent: Tuesday, May 08, 2001 5:56 
PM
Subject: RE: Override Input Form / JSP 
when Errors Are Encountered

Here is the way I did it:

I 
am using the template approach for the jsp files.
template.jsp is the template file
wizard.jsp has has the template tags
wizardpageX.jsp (where X is a number and corresponds to the number of 
screens in your wizard) contains thepresentation.

Inside of the wizardpageX.jsp there are 2 hidden fields (page and 
direction). pageholds the number of the page we are viewing 
anddirection holds the action we want to take ( next, previous, 
finish, cancel).I useJavaScript to update the direction 
tag when one of the buttons are pushed. The ActionForm can validate 
the input for the page we are viewing based on the direction we want to 
go. If there are any errors, we forward back towizard.jsp ( the 
input file ). wizard.jsp will look at the page property and decide 
which wizardpageX.jsp file to display as the body of the 
template.jsp. If there 
aren't any errors, my Action object will update the page property to the 
page we want to go and forward control back to 
wizard.jsp.

James Hicks

  -Original Message-From: Jeff Trent 
  [mailto:[EMAIL PROTECTED]]Sent: Tuesday, May 08, 2001 4:13 
  PMTo: [EMAIL PROTECTED]Subject: Re: 
  Override Input Form / JSP when Errors Are Encountered
  That doesn't work - that is my problem. 
  I don't have a chance to do this in my Action class since the presence of 
  errors generated in form.validate() triggers an immediate response by the 
  framework and redirection occurs automagically to the input form (page 1), 
  not the page which caused the error (eg page 2).
  
  
- Original Message - 
From: 
Nanduri, Amarnath 

To: '[EMAIL PROTECTED]' 

Sent: Tuesday, May 08, 2001 3:56 
PM
Subject: RE: Override Input Form / 
JSP when Errors Are Encountered


instead of mapping.findForward(mapping.getInput() 
) use mapping.findForward("page2 or page3") 
;

  -Original Message-From: Jeff Trent [mailto:[EMAIL PROTECTED]]Sent: 
  Tuesday, May 08, 2001 3:17 PMTo: [EMAIL PROTECTED]Subject: 
  Override Input Form / JSP when Errors Are 
  Encountered
  When validate() returns an error 
  collection, the framework takes me back to the input page 
  (page1). How do I override this? I have a multi-page input 
  wizard as shown below. I'd like to stay on the page that 
  resulted in the error instead of going back to page 1.
  
   
  action 
  path="/someWizard" 
  type="com.x.WizardAction" 
  name="wizardForm" 
  scope="session" 
  input="/page1.jsp" 
  forward 
  name="page2" 
  path="/page2.jsp"/ 
  forward 
  name="page3" 
  path="/page3.jsp"/ 
  /action


RE: Override Input Form / JSP when Errors Are Encountered

2001-05-08 Thread Nanduri, Amarnath




instead of mapping.findForward(mapping.getInput() ) 
use mapping.findForward("page2 or page3") 
;

  -Original Message-From: Jeff Trent 
  [mailto:[EMAIL PROTECTED]]Sent: Tuesday, May 08, 2001 3:17 
  PMTo: [EMAIL PROTECTED]Subject: Override 
  Input Form / JSP when Errors Are Encountered
  When validate() returns an error collection, the 
  framework takes me back to the input page (page1). How do I override 
  this? I have a multi-page input wizard as shown below. I'd like to 
  stay on the page that resulted in the error instead of going back to page 
  1.
  
   action 
  path="/someWizard" 
  type="com.x.WizardAction" 
  name="wizardForm" 
  scope="session" 
  input="/page1.jsp" 
  forward 
  name="page2" 
  path="/page2.jsp"/ 
  forward name="page3" 
  path="/page3.jsp"/ /action


Re: Override Input Form / JSP when Errors Are Encountered

2001-05-08 Thread Jonathan



String referrer = 
request.getHeader(Referrer);
requestDispatcher requestDispatcher = 
request.getRequestDispatcher
requestDispatcher. forward(referrer);

  - Original Message - 
  From: 
  Jeff 
  Trent 
  To: [EMAIL PROTECTED] 
  Sent: Tuesday, May 08, 2001 5:12 PM
  Subject: Re: Override Input Form / JSP 
  when Errors Are Encountered
  
  That doesn't work - that is my problem. I 
  don't have a chance to do this in my Action class since the presence of errors 
  generated in form.validate() triggers an immediate response by the framework 
  and redirection occurs automagically to the input form (page 1), not the page 
  which caused the error (eg page 2).
  
  
- Original Message - 
From: 
Nanduri, Amarnath 
To: '[EMAIL PROTECTED]' 

Sent: Tuesday, May 08, 2001 3:56 
PM
Subject: RE: Override Input Form / JSP 
when Errors Are Encountered


instead of mapping.findForward(mapping.getInput() ) 
use mapping.findForward("page2 or page3") 
;

  -Original Message-From: Jeff Trent [mailto:[EMAIL PROTECTED]]Sent: 
  Tuesday, May 08, 2001 3:17 PMTo: [EMAIL PROTECTED]Subject: 
  Override Input Form / JSP when Errors Are Encountered
  When validate() returns an error collection, 
  the framework takes me back to the input page (page1). How do I 
  override this? I have a multi-page input wizard as shown 
  below. I'd like to stay on the page that resulted in the error 
  instead of going back to page 1.
  
   
  action 
  path="/someWizard" 
  type="com.x.WizardAction" 
  name="wizardForm" 
  scope="session" 
  input="/page1.jsp" 
  forward 
  name="page2" 
  path="/page2.jsp"/ 
  forward 
  name="page3" 
  path="/page3.jsp"/ 
  /action


Re: Override Input Form / JSP when Errors Are Encountered

2001-05-08 Thread Jeff Trent



Interesting approach. Let me see if I can 
explain this back to you to make sure I understand what you are 
saying:

Does your Wizard.jsp look something like 
this:

template:insert 
template='/template.jsp' template:put name='header' 
content='/header.html' / template:put name='sidebar' 
content='/sidebar.jsp' /logic:equalproperty='page' 
value='1'
  template:put 
name='content' content='/wizardPage1.jsp'/
/logic:equal...
logic:equalproperty='page' 
value='N'
  template:put 
name='content' content='/wizardPageN.jsp'/
/logic:equal 
template:put name='footer' content='/footer.html' 
//template:insert

And somewhere at the top you have some logic to 
determine which page your on based on direction and error 
conditions?

*** I'm starting to feel like I'm at battle with 
struts! There must be a way I can hook the error checking logic to 
circumvent the redirect to the base input form. I guess its time to dig 
thru the source code. What bothers me the most is that I feel like I'm not 
doing anything outrageous here.

- jeff


  - Original Message - 
  From: 
  Hicks, 
  James 
  To: '[EMAIL PROTECTED]' 
  
  Sent: Tuesday, May 08, 2001 5:56 PM
  Subject: RE: Override Input Form / JSP 
  when Errors Are Encountered
  
  Here 
  is the way I did it:
  
  I am 
  using the template approach for the jsp files.
  template.jsp is the template file
  wizard.jsp has has the template tags
  wizardpageX.jsp (where X is a number and corresponds to the number of 
  screens in your wizard) contains thepresentation.
  
  Inside of the wizardpageX.jsp there are 2 hidden fields (page and 
  direction). pageholds the number of the page we are viewing 
  anddirection holds the action we want to take ( next, previous, finish, 
  cancel).I useJavaScript to update the direction tag when one 
  of the buttons are pushed. The ActionForm can validate the input for the 
  page we are viewing based on the direction we want to go. If there are 
  any errors, we forward back towizard.jsp ( the input file ). 
  wizard.jsp will look at the page property and decide which wizardpageX.jsp 
  file to display as the body of the template.jsp. If there aren't any errors, my Action object 
  will update the page property to the page we want to go and forward control 
  back to wizard.jsp.
  
  James Hicks
  
-Original Message-From: Jeff Trent 
[mailto:[EMAIL PROTECTED]]Sent: Tuesday, May 08, 2001 4:13 
PMTo: [EMAIL PROTECTED]Subject: Re: 
Override Input Form / JSP when Errors Are Encountered
That doesn't work - that is my problem. I 
don't have a chance to do this in my Action class since the presence of 
errors generated in form.validate() triggers an immediate response by the 
framework and redirection occurs automagically to the input form (page 1), 
not the page which caused the error (eg page 2).


  - Original Message - 
  From: 
  Nanduri, Amarnath 
  To: '[EMAIL PROTECTED]' 
  
  Sent: Tuesday, May 08, 2001 3:56 
  PM
  Subject: RE: Override Input Form / 
  JSP when Errors Are Encountered
  
  
  instead of mapping.findForward(mapping.getInput() 
  ) use mapping.findForward("page2 or page3") 
  ;
  
-Original Message-From: Jeff Trent [mailto:[EMAIL PROTECTED]]Sent: 
Tuesday, May 08, 2001 3:17 PMTo: [EMAIL PROTECTED]Subject: 
Override Input Form / JSP when Errors Are 
Encountered
When validate() returns an error 
collection, the framework takes me back to the input page (page1). 
How do I override this? I have a multi-page input wizard as shown 
below. I'd like to stay on the page that resulted in the error 
instead of going back to page 1.

 
action 
path="/someWizard" 
type="com.x.WizardAction" 
name="wizardForm" 
scope="session" 
input="/page1.jsp" 
forward 
name="page2" 
path="/page2.jsp"/ 
forward 
name="page3" 
path="/page3.jsp"/ 
/action


Re: Override Input Form / JSP when Errors Are Encountered

2001-05-08 Thread Jeff Trent



Are you suggesting that I put the redirect in my 
base input jsp on the condition that errors exist? No offense, but this 
seems to be a hacky approach.

Are we saying here that there is no suggested 
struts method to handle this situation?


  - Original Message - 
  From: 
  Jonathan 
  
  To: [EMAIL PROTECTED] 
  Sent: Tuesday, May 08, 2001 5:43 PM
  Subject: Re: Override Input Form / JSP 
  when Errors Are Encountered
  
  String referrer = 
  request.getHeader(Referrer);
  requestDispatcher requestDispatcher = 
  request.getRequestDispatcher
  requestDispatcher. 
forward(referrer);
  
- Original Message - 
From: 
Jeff 
Trent 
To: [EMAIL PROTECTED] 

Sent: Tuesday, May 08, 2001 5:12 
PM
Subject: Re: Override Input Form / JSP 
when Errors Are Encountered

That doesn't work - that is my problem. I 
don't have a chance to do this in my Action class since the presence of 
errors generated in form.validate() triggers an immediate response by the 
framework and redirection occurs automagically to the input form (page 1), 
not the page which caused the error (eg page 2).


  - Original Message - 
  From: 
  Nanduri, Amarnath 
  To: '[EMAIL PROTECTED]' 
  
  Sent: Tuesday, May 08, 2001 3:56 
  PM
  Subject: RE: Override Input Form / 
  JSP when Errors Are Encountered
  
  
  instead of mapping.findForward(mapping.getInput() 
  ) use mapping.findForward("page2 or page3") 
  ;
  
-Original Message-From: Jeff Trent [mailto:[EMAIL PROTECTED]]Sent: 
Tuesday, May 08, 2001 3:17 PMTo: [EMAIL PROTECTED]Subject: 
Override Input Form / JSP when Errors Are 
Encountered
When validate() returns an error 
collection, the framework takes me back to the input page (page1). 
How do I override this? I have a multi-page input wizard as shown 
below. I'd like to stay on the page that resulted in the error 
instead of going back to page 1.

 
action 
path="/someWizard" 
type="com.x.WizardAction" 
name="wizardForm" 
scope="session" 
input="/page1.jsp" 
forward 
name="page2" 
path="/page2.jsp"/ 
forward 
name="page3" 
path="/page3.jsp"/ 
/action