RE: Lost form data after form.validate() and issuing error messages

2003-07-30 Thread Pankaj Borgaonkar

In the input of second mapping try this /showy.do. Because after
validate, you have to populate the form values again 

Let me know this works 
 
-Original Message-
From: Tuna Vardar [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 30, 2003 6:58 PM
To: [EMAIL PROTECTED]
Subject: Lost form data after form.validate() and issuing error messages


Hello,

I lose all form data  if validate returns error for the form input. If
action goes through validation without creating of any errors, 
XAction works fine.
ShowXAction is used to display jsp and jsp posts to XAction. Any
comments? You can see the code below.

cheers,
tuna

*

ShowXAction.java looks like follows:

public final class ShowXAction extends Action {

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

// Update form data
if (form == null) {
form = new XForm();
if ("request".equals(mapping.getScope()))
request.setAttribute(mapping.getAttribute(), form);
else
session.setAttribute(mapping.getAttribute(), form);
}
   
XForm f = (XForm)form;
   
f.setA("...");
f.setB("...");
 
//ensure, that form is submited only once
saveToken(request);   
   
return mapping.findForward("success");

}

XAction.java looks like:

public final class XAction extends Action {

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

XBean b = new XBean(f.getA(), f.getB());
b.store();
   
//ensure, that form is submited only once
saveToken(request);   
   
return mapping.findForward("success");
}


and struts-config.xml is like follows:



  




  



and finally XForm is like follows:

public final class XForm extends ActionForm {

private String a = null;
   
private String b = null;
   
public String getA() {
return this.a;
}

public void setA(String a) {
this.a = a;
}
   
public String getB() {
return this.b;
}
   
public void setB(String b) {
this.b = b;
}
   
public void reset(ActionMapping mapping, HttpServletRequest request)
{
   
this.a = null;
this.b = null;

}

public ActionErrors validate(ActionMapping mapping,
 HttpServletRequest request) {

ActionErrors errors = new ActionErrors();
   
if ((this.a == null) || (this.a.trim().length() == 0)) {
errors.add(ActionErrors.GLOBAL_ERROR, new 
ActionError("form.a.missing"));
}
   
if ((this.b == null) || (this.b.trim().length() == 0)) {
errors.add(ActionErrors.GLOBAL_ERROR, new 
ActionError("form.b.missing"));
}
return errors;
   
}

public String toString() {
StringBuffer sb = new StringBuffer("XForm[");
sb.append("a=").append(this.a);
sb.append(",b=").append(this.b);
return sb.toString();
}
  
}


-
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: Validate method going in infinite Loop

2003-07-10 Thread Pankaj Borgaonkar

Thanks Nagendra
 
But on the JSP page I want to show both the errors as well as the data (
form bean variable which are populated in the performAction() method of
action class. )
i.e. in validate method if email address is invalid then I am adding the
errors and forwarding to JSP page, this page will show the errors only
but not the formbean values 
as it has not gone into the performAction(). So I need to show the
errors also and the data also from database. This data is not used for
validating the email address but it is used for showing some  suggested
email addresses.
 
Please reply 
Pankaj 
 

-Original Message-
From: Nagendra Kumar O V S [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 10, 2003 12:43 PM
To: [EMAIL PROTECTED]
Subject: Re: Validate method going in infinite Loop



hi pankaj,
 
 


 
** this action mapping goes into a infinite loop , becos, if u find an
error ur calling emailcreation.mo(input parameter). that is it is
calling itself. and hence infinte loop. everytime u call
emailcreation.mo , validate method will be called.
 
 





** this seems to be ok , becos ur forwarding the controll to
/jsp/virtualadvisor/emailcreation/va_pr_emailsetup_main.jsp(input
parameter) and the jsp page should display ur error. and if u want to
get data from db(for validation) , get it from validate method only. ur
control will never go action class unless all the validations are
success..
 
--nagi
 
 
---Original Message---
 
From: Struts Users Mailing  <mailto:[EMAIL PROTECTED]> List
Date: Thursday, July 10, 2003 12:11:05 PM
To: [EMAIL PROTECTED]
Subject: Validate method going in infinite Loop
 
Hi All,

I am validating email address entered by user, using in validate method
of formBean. If the email address is invalid I am adding the errors. 

Struts Config entries:






OR

 



Second one is going into the loop and first one is not getting the
values from database as the request is going to JSP not to action class
i.e the formbean values are not populate.

How can I overcome this problem.

Thanks in Advance 

Regards
Pankaj Borgaonkar
Wipro Technologies


**Disclaimer

Information contained in this E-MAIL being proprietary to Wipro Limited
is 
'privileged' and 'confidential' and intended for use only by the
individual
or entity to which it is addressed. You are notified that any use,
copying 
or dissemination of the information contained in the E-MAIL in any
manner 
whatsoever is strictly prohibited.


***





 <http://www.incredimail.com/redir.asp?ad_id=309&lang=9>   IncrediMail -
Email has finally evolved -
<http://www.incredimail.com/redir.asp?ad_id=309&lang=9> Click Here 


**Disclaimer

Information contained in this E-MAIL being proprietary to Wipro Limited is 
'privileged' and 'confidential' and intended for use only by the individual
 or entity to which it is addressed. You are notified that any use, copying 
or dissemination of the information contained in the E-MAIL in any manner 
whatsoever is strictly prohibited.

***


Validate method going in infinite Loop

2003-07-09 Thread Pankaj Borgaonkar

Hi All,
 
I am validating email address entered by user, using in  validate method
of formBean. If the email address is invalid I am adding the errors. 
 
Struts Config entries:
 


  

 
OR
 
 
  

 
Second one is going into the loop and first one is not getting the
values from database as the request is going to JSP not to action  class
i.e the formbean values are not populate.
 
How can I overcome this problem.
 
Thanks in Advance  
 
Regards
Pankaj Borgaonkar
Wipro Technologies
 

**Disclaimer

Information contained in this E-MAIL being proprietary to Wipro Limited is 
'privileged' and 'confidential' and intended for use only by the individual
 or entity to which it is addressed. You are notified that any use, copying 
or dissemination of the information contained in the E-MAIL in any manner 
whatsoever is strictly prohibited.

***