Can not get error message to display on the same page

2003-11-13 Thread Kam Lung Leung
Hi,

I am trying to write a logon page as discribed on the struts-example, but finding
some problem with my logon.jsp when  ActionLogon.java trys to return ActionErrors
or ActionMessages back to the original page, the logon.jsp. I am using Struts1.1
+ jboss-3.2.1_tomcat-4.1.24. I tried two ways to display the errors by using the 
htlm:errors/ tag and without the tag. Can someone tell me what is going on.

Thank you in advance,
Kam Lung Leung


Below is the tested condictions for both situations:
  
The first part which is without the html:errors/ on the logon page and I only
had the code listed
below in the logon.jsp.

logic:messagesPresent
There were errors
font color='red' 
html:messages id=validatorMsgs  message=true 
 bean:write name=validatorMsgs/ 
/html:messages
/font
/logic:messagesPresent

I tested the following conditions:
1) userName == empty string, and password == empty string (invalid format case)
  I got the popup window saying that User Name is required and Password is
required.

2) userName == hohoho and password == empty string (invalid format case)
  I got the popup window saying that Password is required.

3) userName == hohoho, and password == ho (invalid format case)
  I got no popup window, but instead the error massage was on the same logon page
saying There were errors. I am expecting a popup window with an error message
saying that password can not be less then 6 characters.

4) userName == hohoho, and password == hohoho (valid format case, but wrong
password)
  I got either popup window nor error message on the logon page. I am especting  
an error message as Invalid Password for this user on the logon page.

The second part which is with the html:errors/ on the logon page and I had the
code listed
below in the logon.jsp.
html:errors/
logic:messagesPresent
There were errors
font color='red' 
html:messages id=validatorMsgs  message=true 
 bean:write name=validatorMsgs/ 
/html:messages
/font
/logic:messagesPresent

I tested the following conditions:
1) userName == empty string, and password == empty string (invalid format case)
  I got the popup windown saying that User Name is required and Password is
required.
  
2) userName == hohoho and password == empty string (invalid format case)   
 
  I got the popup windown saying that Password is required.

3) userName == hohoho, and password == ho (invalid format case)
  I got these messages on the logon page. 
Password can not be less than 6 characters.
There were errors
  I am expecting to see the Password can not be less than 6 characters. on the
popup windown at least.

4) userName == hohoho, and password == hohoho (valid format case, but wrong
password)
   I got either popup windown nor error message on the logon page. I am especting
  an error message as Invalid Password for this user on the logon page.

 application.property 
adminLogonForm.userName=User Name
adminLogonForm.userName.maskmsg=The First Character Of The User Name Must Be A
Letter.
adminLogonForm.password=Password
adminLogonForm.password.maskmsg=The First Character Of The Password Must Be A
Letter.
adminLogonForm.error.password=Invalid Password for this user.


 Here is the validation.xml file 
global
constant
constant-namepasswordMask/constant-name
constant-value^[a-zA-Z]{1}[a-zA-Z0-9_]*$/constant-value
/constant
/global
formset
 form  name=adminLogonForm
   .
   .
   field property=password
 depends=required,minlength,maxlength,mask
 msg name=mask key=adminLogonForm.password.maskmsg/
 arg0 key=adminLogonForm.password/
 arg1 name=minlength key=${var:minlength} resource=false/
 arg1 name=maxlength key=${var:maxlength} resource=false/
 var
  var-nameminlength/var-name
  var-value6/var-value
 /var
 var
  var-namemaxlength/var-name
  var-value12/var-value
 /var
 var
  var-namemask/var-name
  var-value${passwordMask}/var-value
 /var
  /field
/form
/formset


struts-config.xml 
   form-bean   name=adminLogonForm
   type=com.wlwa.Infra.WebComponemt.Dispatcher.Forms.AdminLogonForm /
   /form-beans
 
   global-forwards
forward   name=logoff path=/adminLogoff.do/
forward   name=logon 
   path=/Infra/WebComponemt/Presentation/AdminLogon.jsp/
   /global-forwards
 
   action   path=/adminLogonSubmit
  type=com.wlwa.Infra.WebComponemt.Dispatcher.Actions.AdminLogonAction
  name=adminLogonForm
  scope=session
  validate=true
  input=logon
  forward name=success 
   path=/Infra/WebComponemt/Presentation/index.jsp

Re: Fwd: Please Help !! Can't Display ActionMessages

2003-11-10 Thread Kam Lung Leung
Hi Adam,


Thank you for replying to my message. There are two parts stories on this
problem. 
The first part which is without the html:errors/ on the logon page. 
logic:messagesPresent
There were errors
font color='red' 
html:messages id=validatorMsgs  message=true 
 bean:write name=validatorMsgs/ 
/html:messages
/font
/logic:messagesPresent

I tested the following conditions:
1) userName == empty string, and password == empty string (invalid format case)
  I got the popup window saying that User Name is required and Password is
required.

2) userName == hohoho and password == empty string (invalid format case)
  I got the popup window saying that Password is required.

3) userName == hohoho, and password == ho (invalid format case)
  I got no popup window, but instead the error massage was on the same logon page
saying There were errors. I am expecting a popup window with an error message
saying that password can not be less then 6 characters.

4) userName == hohoho, and password == hohoho (valid format case, but wrong
password)
  I got either popup window nor error message on the logon page. I am especting  
an error message as Invalid Password for this user on the logon page.

The second part which is with the html:errors/ on the logon page. 
html:errors/
logic:messagesPresent
There were errors
font color='red' 
html:messages id=validatorMsgs  message=true 
 bean:write name=validatorMsgs/ 
/html:messages
/font
/logic:messagesPresent

I tested the following conditions:
1) userName == empty string, and password == empty string (invalid format case)
  I got the popup windown saying that User Name is required and Password is
required.
  
2) userName == hohoho and password == empty string (invalid format case)   
 
  I got the popup windown saying that Password is required.

3) userName == hohoho, and password == ho (invalid format case)
  I got these messages on the logon page. 
Password can not be less than 6 characters.
There were errors
  I am expecting to see the Password can not be less than 6 characters. on the
popup windown at least.

4) userName == hohoho, and password == hohoho (valid format case, but wrong
password)
   I got either popup windown nor error message on the logon page. I am especting
  an error message as Invalid Password for this user on the logon page.
   
Thank again,

Kam

   application.property 
adminLogonForm.userName=User Name
adminLogonForm.userName.maskmsg=The First Character Of The User Name Must Be A
Letter.
adminLogonForm.password=Password
adminLogonForm.password.maskmsg=The First Character Of The Password Must Be A
Letter.
adminLogonForm.error.password=Invalid Password for this user.


 Here is the validation.xml file 

global
constant
constant-namepasswordMask/constant-name
constant-value^[a-zA-Z]{1}[a-zA-Z0-9_]*$/constant-value
/constant
/global
formset
 form  name=adminLogonForm
   .
   .
   .
   field property=password
 depends=required,minlength,maxlength,mask
 msg name=mask key=adminLogonForm.password.maskmsg/
 arg0 key=adminLogonForm.password/
 arg1 name=minlength key=${var:minlength} resource=false/
 arg1 name=maxlength key=${var:maxlength} resource=false/
 var
  var-nameminlength/var-name
  var-value6/var-value
 /var
 var
  var-namemaxlength/var-name
  var-value12/var-value
 /var
 var
  var-namemask/var-name
  var-value${nameMask}/var-value
 /var
  /field
/form
/formset

On Sun, 09 Nov 2003 11:39:26 +0100, Adam Hardy wrote:

 
 Hi Kam,
 it's not obvious what is going wrong. What error message are you 
 expecting? Do you see the There were errors text?
 
 
 Adam
 
 On 11/09/2003 08:55 AM Kam Lung Leung wrote:
  --- Start of forwarded message ---
  
  Subject: Please Help !! Can't Display ActionMessages
  From: Kam Lung Leung [EMAIL PROTECTED]
  Date: Sat, 08 Nov 2003 18:22:07 -0700 (MST)
  To: [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  
  Hi,
  
  I am trying to follow the logon example of the struts-example.war. However, I
 can
  not see the error messages print on the logon.jsp. Any suggestion is greatly
  appreciated.
  
 here is the part that display the errors on my logon.jsp 
  logic:messagesPresent
  There were errors
  ul
  font color='red' 
  html:messages id=validatorMsgs  message=true 
  li bean:write name=validatorMsgs/ /li
  /html:messages
  /font
  /ul
  /logic:messagesPresent
  
  struts

Fwd: Please Help !! Can't Display ActionMessages

2003-11-09 Thread Kam Lung Leung
--- Start of forwarded message ---

Subject: Please Help !! Can't Display ActionMessages
From: Kam Lung Leung [EMAIL PROTECTED]
Date: Sat, 08 Nov 2003 18:22:07 -0700 (MST)
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]

Hi,

I am trying to follow the logon example of the struts-example.war. However, I can
not see the error messages print on the logon.jsp. Any suggestion is greatly
appreciated.

   here is the part that display the errors on my logon.jsp 
logic:messagesPresent
There were errors
ul
font color='red' 
html:messages id=validatorMsgs  message=true 
li bean:write name=validatorMsgs/ /li
/html:messages
/font
/ul
/logic:messagesPresent

struts-config.xml 

  form-beanname=adminLogonForm
  type=com.wlwa.Infra.WebComponemt.Dispatcher.Forms.AdminLogonForm /
  /form-beans

  global-forwards
   forward   name=logoff path=/adminLogoff.do/
   forward   name=logon
path=/Infra/WebComponemt/Presentation/AdminLogon.jsp/
  /global-forwards

  action   path=/adminLogonSubmit
 type=com.wlwa.Infra.WebComponemt.Dispatcher.Actions.AdminLogonAction
 name=adminLogonForm
 scope=session
 validate=true
 input=logon
 forward name=success path=/Infra/WebComponemt/Presentation/index.jsp /
   /action

   Here is may ActionLogon.java 

ActionMessages actionsMsgs = new ActionMessages();
// Validate the request parameters specified by the user
String username = (String) PropertyUtils.getSimpleProperty(form, userName);
String password = (String) PropertyUtils.getSimpleProperty(form, password);

try {
  if (lookUpUser(password, username) == false) {
actionsMsgs.add(ActionMessages.GLOBAL_MESSAGE, 
  new ActionMessage(adminLogonForm.error.password));
   }
} catch (Exception ex) {
  // Report any actionsMsgs we have discovered back to the original form
  actionsMsgs.add(ActionMessages.GLOBAL_MESSAGE, 
  new ActionMessage(adminLogonForm.error.password, ex.toString()));
  saveMessages(request,actionsMsgs);
  if (log.isDebugEnabled()) {
   log.debug(validation of user passwword failed for username: +username );
 
   log.debug(End of execute );
  }
  return (mapping.getInputForward());
} //end try-catch 

if (log.isDebugEnabled()) {
log.debug(execute : password validation ended for user :  + username );
}

// Report any actionsMsgs we have discovered back to the original form
if (!actionsMsgs.isEmpty()) {
 saveMessages(request, actionsMsgs);
 if (log.isDebugEnabled()) {
  log.debug(validation of user passwword failed for username: + username );
  log.debug(End of execute );
 }
 return (mapping.getInputForward());
}

   server.log 
DEBUG [org.apache.commons.beanutils.ConvertUtils] Convert string 'kamhoho' to
class 'java.lang.String'
DEBUG [org.apache.commons.beanutils.ConvertUtils]   Using converter
[EMAIL PROTECTED]
DEBUG [org.apache.commons.beanutils.BeanUtils]  
setProperty([EMAIL PROTECTED],
userName, [tytyty])
DEBUG [org.apache.commons.beanutils.ConvertUtils] Convert string 'tytyty' to
class 'java.lang.String'
DEBUG [org.apache.commons.beanutils.ConvertUtils]   Using converter
[EMAIL PROTECTED]
DEBUG [org.apache.struts.action.RequestProcessor]  Validating input form
properties
DEBUG [org.apache.struts.action.RequestProcessor]   No errors detected, accepting
input
DEBUG [org.apache.struts.action.RequestProcessor]  Looking for Action instance
for class com.wlwa.Infra.WebComponemt.Dispatcher.Actions.AdminLogonAction
DEBUG [org.apache.struts.action.RequestProcessor]   Returning existing Action
instance
DEBUG [com.wlwa.Infra.WebComponemt.Dispatcher.Action.AdminLogonAction] Begin of
execute 
DEBUG [com.wlwa.Infra.WebComponemt.Dispatcher.Action.AdminLogonAction] execute :
password validation ended for user : tytyty
DEBUG [com.wlwa.Infra.WebComponemt.Dispatcher.Action.AdminLogonAction] End of
execute 
DEBUG [org.apache.struts.tiles.TilesRequestProcessor]
processForwardConfig(/Infra/WebComponemt/Presentation/index.jsp, false)
DEBUG [org.apache.struts.tiles.TilesRequestProcessor]  
'/Infra/WebComponemt/Presentation/index.jsp' - processed as uri
DEBUG [org.apache.struts.action.RequestProcessor]
processForwardConfig(ForwardConfig[name=success,path=/Infra/WebComponemt/Presentation/index.jsp,redirect=false,contextRelative=false])

Kam Lung Leung
System Architect
Wireless Web Access Inc.
(303) 627-9684

--- End of forwarded message ---

Kam Lung Leung
System Architect
Wireless Web Access Inc.
(303) 627-9684

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



Please Help !! Can't Display ActionMessages

2003-11-08 Thread Kam Lung Leung
Hi,

I am trying to follow the logon example of the struts-example.war. However, I can
not see the error messages print on the logon.jsp. Any suggestion is greatly
appreciated.

   here is the part that display the errors on my logon.jsp 
logic:messagesPresent
There were errors
ul
font color='red' 
html:messages id=validatorMsgs  message=true 
li bean:write name=validatorMsgs/ /li
/html:messages
/font
/ul
/logic:messagesPresent

struts-config.xml 

  form-beanname=adminLogonForm
  type=com.wlwa.Infra.WebComponemt.Dispatcher.Forms.AdminLogonForm /
  /form-beans

  global-forwards
   forward   name=logoff path=/adminLogoff.do/
   forward   name=logon
path=/Infra/WebComponemt/Presentation/AdminLogon.jsp/
  /global-forwards

  action   path=/adminLogonSubmit
 type=com.wlwa.Infra.WebComponemt.Dispatcher.Actions.AdminLogonAction
 name=adminLogonForm
 scope=session
 validate=true
 input=logon
 forward name=success path=/Infra/WebComponemt/Presentation/index.jsp /
   /action

   Here is may ActionLogon.java 

ActionMessages actionsMsgs = new ActionMessages();
// Validate the request parameters specified by the user
String username = (String) PropertyUtils.getSimpleProperty(form, userName);
String password = (String) PropertyUtils.getSimpleProperty(form, password);

try {
  if (lookUpUser(password, username) == false) {
actionsMsgs.add(ActionMessages.GLOBAL_MESSAGE, 
  new ActionMessage(adminLogonForm.error.password));
   }
} catch (Exception ex) {
  // Report any actionsMsgs we have discovered back to the original form
  actionsMsgs.add(ActionMessages.GLOBAL_MESSAGE, 
  new ActionMessage(adminLogonForm.error.password, ex.toString()));
  saveMessages(request,actionsMsgs);
  if (log.isDebugEnabled()) {
   log.debug(validation of user passwword failed for username: +username );
 
   log.debug(End of execute );
  }
  return (mapping.getInputForward());
} //end try-catch 

if (log.isDebugEnabled()) {
log.debug(execute : password validation ended for user :  + username );
}

// Report any actionsMsgs we have discovered back to the original form
if (!actionsMsgs.isEmpty()) {
 saveMessages(request, actionsMsgs);
 if (log.isDebugEnabled()) {
  log.debug(validation of user passwword failed for username: + username );
  log.debug(End of execute );
 }
 return (mapping.getInputForward());
}

   server.log 
DEBUG [org.apache.commons.beanutils.ConvertUtils] Convert string 'kamhoho' to
class 'java.lang.String'
DEBUG [org.apache.commons.beanutils.ConvertUtils]   Using converter
[EMAIL PROTECTED]
DEBUG [org.apache.commons.beanutils.BeanUtils]  
setProperty([EMAIL PROTECTED],
userName, [tytyty])
DEBUG [org.apache.commons.beanutils.ConvertUtils] Convert string 'tytyty' to
class 'java.lang.String'
DEBUG [org.apache.commons.beanutils.ConvertUtils]   Using converter
[EMAIL PROTECTED]
DEBUG [org.apache.struts.action.RequestProcessor]  Validating input form
properties
DEBUG [org.apache.struts.action.RequestProcessor]   No errors detected, accepting
input
DEBUG [org.apache.struts.action.RequestProcessor]  Looking for Action instance
for class com.wlwa.Infra.WebComponemt.Dispatcher.Actions.AdminLogonAction
DEBUG [org.apache.struts.action.RequestProcessor]   Returning existing Action
instance
DEBUG [com.wlwa.Infra.WebComponemt.Dispatcher.Action.AdminLogonAction] Begin of
execute 
DEBUG [com.wlwa.Infra.WebComponemt.Dispatcher.Action.AdminLogonAction] execute :
password validation ended for user : tytyty
DEBUG [com.wlwa.Infra.WebComponemt.Dispatcher.Action.AdminLogonAction] End of
execute 
DEBUG [org.apache.struts.tiles.TilesRequestProcessor]
processForwardConfig(/Infra/WebComponemt/Presentation/index.jsp, false)
DEBUG [org.apache.struts.tiles.TilesRequestProcessor]  
'/Infra/WebComponemt/Presentation/index.jsp' - processed as uri
DEBUG [org.apache.struts.action.RequestProcessor]
processForwardConfig(ForwardConfig[name=success,path=/Infra/WebComponemt/Presentation/index.jsp,redirect=false,contextRelative=false])

Kam Lung Leung
System Architect
Wireless Web Access Inc.
(303) 627-9684

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



how to retrieve property values from previous forms/jsp pages

2003-11-03 Thread Kam Lung Leung
Hi,

I need to retrieve property values from previous pages that were inputted by the
user. For example;
I have the following pages, actions and forms.
firstPage.jsp firstAction.java firstForm.java
secondPage.jsp secondAction.java secondForm.java
finalPage.jsp finalAction.java finalForm.java

In the finalAction class I need to retrieve property values that were filled in
from the firstPage.jsp and the secondPage.jsp. Beside setting the scope of each
form to session in the action mapping what else do I need to do so that I may
retrieve those values?

Any suggestion?
Thank you in advance.
Kam Lung Leung

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



RE: how to retrieve property values from previous forms/jsp pages

2003-11-03 Thread Kam Lung Leung
Thank David,

The second option may not work for me because the secondPage.jsp will be further
extends to hotel.secondPage.jsp, car.secondPage.jsp and so on. The purpose of the
finalPage.jsp is to echo all values that were inputted from either the hotel
group(firstpage.jsp and the hotel.secondPage.jsp), or the card group
(firstpage.jsp and the car.secondPage.jsp). Then the user have the option to
either submitted or goes back to the firstPage.jsp.  Thus I should not combine
the hotel.secondPageForm.java and car.secondPageForm.java into the
firstPageForm.java (that becomes combinedPagesForm.java). This will make the
combinedPagesForm.java too difficult to maintains in the future. The third option
looks more fit into my situation?  How do i put the action's bean in the session
scope? Do you mean setting the scope to session in the action mapping. I thought
the scope setting was for the form bean. Can you give a simple code example? 
How do I retrieve the property values of firstForms in my execute method of the
hotel.secondAction.java?

   public ActionForward execute(ActionMapping mapping,
  ActionForm form,
  HttpServletRequest request,
  HttpServletResponse response)
throws Exception {

  hotel.secondForm inputForm = (hotel.secondForm) form;
  // retrieve all property values



  //Now what to do to get the firstForm from here??
   } //end execute

May be I need to use the request.setAttribute to setup a DAO object in the
firstAction.java and retrieve the DAO object from within the execute method of
the hotel.secondAction.java by using the request.getAttribute method? Can this be
done?

Thank you in advance,
Kam Lung Leung
 

On Mon, 3 Nov 2003 14:23:27 -0500, David Friedman wrote:

 
 Kam,
 
 One approach is to use hidden variables to ensure all fields are in every
 page.
 
 Another approach is to have each action use the same form in session scope
 so all fields are retained between POSTs (just remember to
 getSession().removeAttribute(NAME) when you're done with it to free up
 memory.
 
 A third approach is to put each action's bean in the session scope similar
 to the previous paragraph.  Again, remember to remove the session beans when
 you're finished with them to keep your memory usage down.
 
 I prefer the 2nd approach: one bean in session scoped shared by multiple
 actions.
 
 Regards,
 David
 
 -Original Message-
 From: Kam Lung Leung [mailto:[EMAIL PROTECTED]
 Sent: Monday, November 03, 2003 2:18 PM
 To: [EMAIL PROTECTED]
 Subject: how to retrieve property values from previous forms/jsp pages
 
 
 Hi,
 
 I need to retrieve property values from previous pages that were inputted by
 the
 user. For example;
 I have the following pages, actions and forms.
 firstPage.jsp firstAction.java firstForm.java
 secondPage.jsp secondAction.java secondForm.java
 finalPage.jsp finalAction.java finalForm.java
 
 In the finalAction class I need to retrieve property values that were filled
 in
 from the firstPage.jsp and the secondPage.jsp. Beside setting the scope of
 each
 form to session in the action mapping what else do I need to do so that I
 may
 retrieve those values?
 
 Any suggestion?
 Thank you in advance.
 Kam Lung Leung
 
 -
 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: how to retrieve property values from previous forms/jsp pages

2003-11-03 Thread Kam Lung Leung
Thank again David,

 HotelBean hotel = (HotelBean) request.getSession().getAttribute(hotel);

Is the string hotel the name of the form that was declared in the
struts-config.xml? 

 form-beans
!-- CreateUserAccountForm form bean --
form-bean  name=hotel type=com.wlwa.Forms.HotelSecondForm/
  /form-beans

Many Thanks,
Kam Lung Leung

On Mon, 3 Nov 2003 15:58:24 -0500, David Friedman wrote:

 
 Kam,
 
 You can force a bean into the session scope by setting 'scope=session' in
 the action mapping action.../ (or action.../action).  To retrieve it,
 you can do something like this:
 
 HotelBean hotel = (HotelBean) request.getSession().getAttribute(hotel);
 CarBean auto = (CarBean) request.getSession().getAttribute(car);
 
 Then, when you're done with them in the final page, you can remove them (or
 let  them expire with the session, but I recommend removing beans when they
 are no longer needed)
 
 request.getSession().removeAttribute(car);
 request.getSession().removeAttribute(hotel);
 
 More details can be found on the Java ServLet Spec available on the net such
 as on the Tomcat 4.1 site:
 
 http://jakarta.apache.org/tomcat/tomcat-4.1-doc/servletapi/javax/servlet/htt
 p/HttpSession.html
 
 You can also set the cookie to last longer (see the interval set/get
 functions) so sessions last longer than 30 minutes (Tomcat a default, I
 think).
 
 Regards,
 David
 
 -Original Message-
 From: Kam Lung Leung [mailto:[EMAIL PROTECTED]
 Sent: Monday, November 03, 2003 3:44 PM
 To: [EMAIL PROTECTED]
 Subject: RE: how to retrieve property values from previous forms/jsp
 pages
 
 
 Thank David,
 
 The second option may not work for me because the secondPage.jsp will be
 further
 extends to hotel.secondPage.jsp, car.secondPage.jsp and so on. The purpose
 of the
 finalPage.jsp is to echo all values that were inputted from either the hotel
 group(firstpage.jsp and the hotel.secondPage.jsp), or the card group
 (firstpage.jsp and the car.secondPage.jsp). Then the user have the option to
 either submitted or goes back to the firstPage.jsp.  Thus I should not
 combine
 the hotel.secondPageForm.java and car.secondPageForm.java into the
 firstPageForm.java (that becomes combinedPagesForm.java). This will make the
 combinedPagesForm.java too difficult to maintains in the future. The third
 option
 looks more fit into my situation?  How do i put the action's bean in the
 session
 scope? Do you mean setting the scope to session in the action mapping. I
 thought
 the scope setting was for the form bean. Can you give a simple code example?
 How do I retrieve the property values of firstForms in my execute method of
 the
 hotel.secondAction.java?
 
public ActionForward execute(ActionMapping mapping,
   ActionForm form,
   HttpServletRequest request,
   HttpServletResponse response)
 throws Exception {
 
   hotel.secondForm inputForm = (hotel.secondForm) form;
   // retrieve all property values
 
 
 
   //Now what to do to get the firstForm from here??
} //end execute
 
 May be I need to use the request.setAttribute to setup a DAO object in the
 firstAction.java and retrieve the DAO object from within the execute method
 of
 the hotel.secondAction.java by using the request.getAttribute method? Can
 this be
 done?
 
 Thank you in advance,
 Kam Lung Leung
 
 
 On Mon, 3 Nov 2003 14:23:27 -0500, David Friedman wrote:
 
 
  Kam,
 
  One approach is to use hidden variables to ensure all fields are in every
  page.
 
  Another approach is to have each action use the same form in session
 scope
  so all fields are retained between POSTs (just remember to
  getSession().removeAttribute(NAME) when you're done with it to free up
  memory.
 
  A third approach is to put each action's bean in the session scope
 similar
  to the previous paragraph.  Again, remember to remove the session beans
 when
  you're finished with them to keep your memory usage down.
 
  I prefer the 2nd approach: one bean in session scoped shared by multiple
  actions.
 
  Regards,
  David
 
  -Original Message-
  From: Kam Lung Leung [mailto:[EMAIL PROTECTED]
  Sent: Monday, November 03, 2003 2:18 PM
  To: [EMAIL PROTECTED]
  Subject: how to retrieve property values from previous forms/jsp pages
 
 
  Hi,
 
  I need to retrieve property values from previous pages that were inputted
 by
  the
  user. For example;
  I have the following pages, actions and forms.
  firstPage.jsp firstAction.java firstForm.java
  secondPage.jsp secondAction.java secondForm.java
  finalPage.jsp finalAction.java finalForm.java
 
  In the finalAction class I need to retrieve property values that were
 filled
  in
  from the firstPage.jsp and the secondPage.jsp. Beside setting the scope of
  each
  form to session in the action mapping what else do I need to do so that I
  may
  retrieve those values?
 
  Any suggestion

Re: Please Help!!! A Validation Rule Fail On A Second-Page Causes A Blank Page To Show Up

2003-10-31 Thread Kam Lung Leung
Hi Ted,

Thank you for your time in helping me out. After your email message I 
take a hard look at the jsp file and can not find what was wrong with it.
The secondPage.jsp is almost the same as the firstPage.jsp. When
I move all the code from the secondPage.jsp to the firstPage.jsp the 
validation process went fine. All fields are validated by the validator.
I have given up the hope to create a multipage form for now. And by the way 
I have purchased the Struts In Actions book along with other three books 
on the same subject. But there was not must information on multipage form. 
Do you have any suggestion on book that I may find some complete example 
on multi page form. To answers your your question about why do I reset all 
input fields to its original state when the getPage() is equal to 2 is that 
I only have two pages,firstPage.jsp and secondPage.jsp, each page would set the
page number to 0 and 1 correspondingly. I set the page to 2 in the action
class when the secondPage.jsp was executed. Then I call the form's reset method
to clear all the fields before the control goes back to the firstPage.jsp. I
guest you are right about removing the form bean should be good enough to remove
all attributes in form for both pages.

Thank again.

Kam Lung Leung
On Fri, 24 Oct 2003 17:19:03 -0400, Ted Husted wrote:

 
 Kam Lung Leung wrote:
   Why don't I get a pop up dialog box with error messages?
   Why the secondPage.jsp did not get executed when a validation
   error occurred?
   Why do I get a blank screen?
 
 Are you sure that it's blank? Sometimes the page doesn't render because 
 of errors in the HTML, which might only be exposed when the page is 
 trying to display error messages.
 
 I'm not sure why you would reset everything if getPage() is equal to 2. 
 The usual approach is to allow the properties to accumulate, until the 
 end of the workflow, and then dispose of the (session-scoped ActionForm 
 altogether. Generally, the only thing you ever need to reset is a 
 checkbox to false on a session-scope ActionForm.
 
 -Ted.
 
 
  Hi,
  
  I have been looking at this problem for the last four days and can't
figure
  out. I have an application that required workflow form. I created a
  CreateUserAccountAction class that extends the DispatchAction and a form
  MultiCreateUserAccountForm that extends the ValidatorForm.  The reset method
of
  the MultiCreateUserAccountForm clears all attributes under the current session
  when the getPage() is equal to 2. The CreateUserAccountAction has two methods
  that are similar to the execute method that are named
createUserAccountActionOne
  and createUserAccountActionTwo. I got this concept out of chapter 12 of the
book
  Profession Jakarta Struts by James Goodwill and Richard Hightower.
  
  *** Here are the symptoms  **
  If there is a required field that is missing (leaved out) or does not
 fulfill
  the validation rule on the firstPage.jsp when the submit button is pressed. A
 new
  dialog box popped up on the screen with the validation message(s) from the
  resource property file. When all fields are validated the control is forwarded
 to
  the secondPage.jsp.
  
  If there is a required field that is missing (leaved out) or does not
 fulfill
  the validation rule on the secondPage.jsp when the submit button is pressed. A
  blank page is showed up on the window without a new dialog box shows up on the
  screen. The server.log indicates an error occurred and the control returns to
 the
  same page (secondPage.jsp). To fixing this problem, I pressed the back page
  button of the browser and correctly filled in all missing fields or making
sure
  the input is conforming to the validation rule. When all fields on the second
  page are filled in correctly according to the validation rules then the
control
  is correctly forwarded back to the firstPage.jsp.
  
  **  My questions
  
  
  Any suggestion and how to fix this problem is deeply appriciated.
  
  
  Kam Lung Leung 
  
  
  
  
  *** ***More detail on how the jsp was set up  **
  The createUserAccountActionOne method calls the
  MultiCreateUserAccountForm.validate() method to validate the user input fields
 of
  the firstPage.jsp. Second, it calls the setPage() method with  1 as its
input
  parameter. Finally, it calls the
 MultiCreateUserAccountForm.setMethodToDispatch()
  with createUserAccountActionTwo as the input parameter.
   
  The createUserAccountActionTwo method calls the
  MultiCreateUserAccountForm.validate() method to validate the user input fields
 of
  the secondPage.jsp. Secondly, it remove the obsolete form bean with
  session.removeAttribute(mapping.getAttribute()). Thirdly, it calls the
setPage()
  method with  2 as its input parameter. Finally, it calls the reset() method
to
  clear all attributes under the current session.
  
  ** This are action

Please Help!!! A Validation Rule Fail On A Second-Page Causes A Blank Page To Show Up

2003-10-24 Thread Kam Lung Leung
Hi,

I have been looking at this problem for the last four days and can't figure
out. I have an application that required workflow form. I created a
CreateUserAccountAction class that extends the DispatchAction and a form
MultiCreateUserAccountForm that extends the ValidatorForm.  The reset method of
the MultiCreateUserAccountForm clears all attributes under the current session
when the getPage() is equal to 2. The CreateUserAccountAction has two methods
that are similar to the execute method that are named createUserAccountActionOne
and createUserAccountActionTwo. I got this concept out of chapter 12 of the book
Profession Jakarta Struts by James Goodwill and Richard Hightower.

*** Here are the symptoms  **
If there is a required field that is missing (leaved out) or does not fulfill
the validation rule on the firstPage.jsp when the submit button is pressed. A new
dialog box popped up on the screen with the validation message(s) from the
resource property file. When all fields are validated the control is forwarded to
the secondPage.jsp.

If there is a required field that is missing (leaved out) or does not fulfill
the validation rule on the secondPage.jsp when the submit button is pressed. A
blank page is showed up on the window without a new dialog box shows up on the
screen. The server.log indicates an error occurred and the control returns to the
same page (secondPage.jsp). To fixing this problem, I pressed the back page
button of the browser and correctly filled in all missing fields or making sure
the input is conforming to the validation rule. When all fields on the second
page are filled in correctly according to the validation rules then the control
is correctly forwarded back to the firstPage.jsp.

**  My questions
Why don't I get a pop up dialog box with error messages?
Why the secondPage.jsp did not get executed when a validation error occurred?
Why do I get a blank screen?


Any suggestion and how to fix this problem is deeply appriciated.


Kam Lung Leung 




*** ***More detail on how the jsp was set up  **
The createUserAccountActionOne method calls the
MultiCreateUserAccountForm.validate() method to validate the user input fields of
the firstPage.jsp. Second, it calls the setPage() method with  1 as its input
parameter. Finally, it calls the MultiCreateUserAccountForm.setMethodToDispatch()
with createUserAccountActionTwo as the input parameter.
 
The createUserAccountActionTwo method calls the
MultiCreateUserAccountForm.validate() method to validate the user input fields of
the secondPage.jsp. Secondly, it remove the obsolete form bean with
session.removeAttribute(mapping.getAttribute()). Thirdly, it calls the setPage()
method with  2 as its input parameter. Finally, it calls the reset() method to
clear all attributes under the current session.

** This are action mapping ***
action
path=/multiCreateUserAccountFirstSubmit
type=com.wlwa.CreateUserAccountAction
name=multiCreateUserAccountForm
scope=session
validate=true
parameter=methodToDispatch
input=/CreateUserAccountLink.jsp
 forward name=success path=/CreateUserAccountSecondLink.jsp /
/action

action
path=/multiCreateUserAccountSecondSubmit
type=com.wlwa.CreateUserAccountAction
name=multiCreateUserAccountForm
scope=session
validate=true
parameter=methodToDispatch
input=/CreateUserAccountSecondLink.jsp
 forward name=success path=/CreateUserAccountLink.jsp   /
/action

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



validation errors on multi pages form

2003-10-23 Thread Kam Lung Leung
Hi,

I have an application that required workflow like jsp pages. I created an
action name CreateUserAccountAction that extends the DispatchAction and a form
MultiCreateUserAccountForm that extends the ValidatorForm.  The reset method of
the MultiCreateUserAccountForm will clear all attributes under the current
session  when the getPage() is equal to 2. The  CreateUserAccountAction has two
methods that are similar to the execute method that are named
createUserAccountActionOne and createUserAccountActionTwo.

The createUserAccountActionOne method calls the
MultiCreateUserAccountForm.validate() method to validate the user input fields of
the firstPage.jsp. Second, it calls the setPage() method with  1 as its input
parameter. Finally, it calls the MultiCreateUserAccountForm.setMethodToDispatch()
with createUserAccountActionTwo as the input parameter.
 
The createUserAccountActionTwo method calls the
MultiCreateUserAccountForm.validate() method to validate the user input fields of
the secondPage.jsp. Secondly, it remove the obsolete form bean with
session.removeAttribute(mapping.getAttribute()). Thirdly, it calls the setPage()
method with  2 as its input parameter. Finally, it calls the reset() method to
clear all attributes under the current session.

If there is a required field that is missing (leaved out) on the
firstPage.jsp when the submit button is pressed. A new dialog box poped up on the
screen with the validation message from the resource property file. When every
field is validated the controll is forwarded to the secondPage.jsp.

If there is a required field that is missing (leaved out) on the
secondPage.jsp when the submit button is pressed. A blank page is showed on the
windown  without a new dialog box shows up on the screen. The server.log
indicates an error occurred and returns to the same page (secondPage.jsp). To
fixed this problem, I pressed the back page button of the browser and correctly
filled in all missing fields. When every field on the second page is filled
correctly according to the validation rules then the controll is correctly
forwarded to the firstPage.jsp.

My question is following:
Why don't I get a pop up dialog box with error messages ?
Why the secondPage.jsp did not get executed?
Why do I get a black screen?

** This are action mapping ***
action
path=/multiCreateUserAccountFirstSubmit
type=com.wlwa.CreateUserAccountAction
name=multiCreateUserAccountForm
scope=session
validate=true
parameter=methodToDispatch
input=/CreateUserAccountLink.jsp
 forward name=success path=/CreateUserAccountSecondLink.jsp /
/action

action
path=/multiCreateUserAccountSecondSubmit
type=com.wlwa.CreateUserAccountAction
name=multiCreateUserAccountForm
scope=session
validate=true
parameter=methodToDispatch
input=/CreateUserAccountSecondLink.jsp
 forward name=success path=/CreateUserAccountLink.jsp   /
/action

Kam Lung Leung

Kam Lung Leung
System Architect
Wireless Web Access Inc.
(303) 627-9684

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