Re: Validation problems: again...

2006-07-04 Thread Paul Benedict
You write:
 Can someone explain me this? Both form extend ActionForm and both actions 
 extend a common action.
 
Vinicius, I think you need to refer to my previous email: ActionForm does not 
validate. You need to extend from ValidatorActionForm or ValidatorForm. The 
first valdiates based on URI, the second on the form name.

Paul

Vinicius Carvalho [EMAIL PROTECTED] wrote: Well, I've just quit the 
validation on strtuts (based on
commons-validator). So I've decided to use dumb manual validation.

Well problem is, I still can't get one of my forms to validate!

Here´ my struts-config:


  
type=com.synos.pbh.opdigital.view.form.votacao.CadastrarVotanteForm
  
type=com.synos.pbh.opdigital.view.form.mailing.VisitanteForm



type=com.synos.pbh.opdigital.view.action.votacao.CadastrarVotante
name=cadastrarVotanteForm input=/cadastroVotante.do


   

validate=true
type=com.synos.pbh.opdigital.view.action.mailing.ConfirmarCadastroVisitanteAction
name=cadastrarVisitanteForm input=/cadastroVisitante.do

   

What's really pissing me off is that the first formbean/action mapping
is just ignoring the validate phase, but the second don't. Can someone
explain me this? Both form extend ActionForm and both actions extend a
common action.

How come this be possible? Please, I tried everthing I know and
nothing seems to make it work, I must be missing a spot somewhere,
just can't find it.

Regards

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




-
Do you Yahoo!?
 Everyone is raving about the  all-new Yahoo! Mail Beta.

Re: Validation problems: again...

2006-07-04 Thread Vinicius Carvalho

Hum, how could the one of them being validated them? If both extend
ActionForm? I gave up from validation plugin, I'm writing my own
validate method, isn't validate called even from ActionForm
subclasses?

Regards

On 7/4/06, Paul Benedict [EMAIL PROTECTED] wrote:

You write:
 Can someone explain me this? Both form extend ActionForm and both actions 
extend a common action.

Vinicius, I think you need to refer to my previous email: ActionForm does not 
validate. You need to extend from ValidatorActionForm or ValidatorForm. The 
first valdiates based on URI, the second on the form name.

Paul

Vinicius Carvalho [EMAIL PROTECTED] wrote: Well, I've just quit the 
validation on strtuts (based on
commons-validator). So I've decided to use dumb manual validation.

Well problem is, I still can't get one of my forms to validate!

Here´ my struts-config:



type=com.synos.pbh.opdigital.view.form.votacao.CadastrarVotanteForm

type=com.synos.pbh.opdigital.view.form.mailing.VisitanteForm



type=com.synos.pbh.opdigital.view.action.votacao.CadastrarVotante
name=cadastrarVotanteForm input=/cadastroVotante.do




validate=true
type=com.synos.pbh.opdigital.view.action.mailing.ConfirmarCadastroVisitanteAction
name=cadastrarVisitanteForm input=/cadastroVisitante.do



What's really pissing me off is that the first formbean/action mapping
is just ignoring the validate phase, but the second don't. Can someone
explain me this? Both form extend ActionForm and both actions extend a
common action.

How come this be possible? Please, I tried everthing I know and
nothing seems to make it work, I must be missing a spot somewhere,
just can't find it.

Regards

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




-
Do you Yahoo!?
 Everyone is raving about the  all-new Yahoo! Mail Beta.



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



RE: Validation problems: again...

2006-07-04 Thread David Friedman
Do they both have action mapping with 'validate=true'?

Do they both have the same signature for you personal validate() method in
ActionForm?  (i.e. not in Action but ActionForm).  Remember, the method
signature must match YOUR version of struts.

Are there any errors in your log files that might shed some light on this?

Regards,
David

-Original Message-
From: Vinicius Carvalho [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 04, 2006 12:34 PM
To: Struts Users Mailing List
Subject: Re: Validation problems: again...


Hum, how could the one of them being validated them? If both extend
ActionForm? I gave up from validation plugin, I'm writing my own
validate method, isn't validate called even from ActionForm
subclasses?

Regards

On 7/4/06, Paul Benedict [EMAIL PROTECTED] wrote:
 You write:
  Can someone explain me this? Both form extend ActionForm and both
actions extend a common action.

 Vinicius, I think you need to refer to my previous email: ActionForm does
not validate. You need to extend from ValidatorActionForm or ValidatorForm.
The first valdiates based on URI, the second on the form name.

 Paul

 Vinicius Carvalho [EMAIL PROTECTED] wrote: Well, I've just quit
the validation on strtuts (based on
 commons-validator). So I've decided to use dumb manual validation.

 Well problem is, I still can't get one of my forms to validate!

 Here´ my struts-config:



 type=com.synos.pbh.opdigital.view.form.votacao.CadastrarVotanteForm

 type=com.synos.pbh.opdigital.view.form.mailing.VisitanteForm



 type=com.synos.pbh.opdigital.view.action.votacao.CadastrarVotante
 name=cadastrarVotanteForm input=/cadastroVotante.do




 validate=true

type=com.synos.pbh.opdigital.view.action.mailing.ConfirmarCadastroVisitante
Action
 name=cadastrarVisitanteForm input=/cadastroVisitante.do



 What's really pissing me off is that the first formbean/action mapping
 is just ignoring the validate phase, but the second don't. Can someone
 explain me this? Both form extend ActionForm and both actions extend a
 common action.

 How come this be possible? Please, I tried everthing I know and
 nothing seems to make it work, I must be missing a spot somewhere,
 just can't find it.

 Regards

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




 -
 Do you Yahoo!?
  Everyone is raving about the  all-new Yahoo! Mail Beta.


-
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: Validation problems: again...

2006-07-04 Thread Vinicius Carvalho

yes both of em, I've post a pice of the config file ;)
yes either, both has validate(ActionMapping arg0, HttpServletRequest
arg1) signature.
My struts version is 1.2.9.

Looking at the logs, for the action/form that just skip validation:
[java] [OPDIGITAL] DEBUG [HttpRequestHandler-6148719]
RequestUtils.createActionForm(300) |  --
[EMAIL PROTECTED]
[java] [OPDIGITAL] DEBUG [HttpRequestHandler-6148719]
RequestProcessor.processActionForm(339) |  Storing ActionForm bean
instance in scope 'request' under attribute key 'cadastrarVotanteForm'
[java] [OPDIGITAL] DEBUG [HttpRequestHandler-6148719]
RequestProcessor.processPopulate(805) |  Populating bean properties
from this request
[java] [OPDIGITAL] DEBUG [HttpRequestHandler-6148719]
RequestProcessor.processValidate(948) |  Validating input form
properties
[java] [OPDIGITAL] DEBUG [HttpRequestHandler-6148719]
RequestProcessor.processValidate(953) |   No errors detected,
accepting input


Well no errors detected? It does not even calls my validate method...

Now for the other action:

 [java] [OPDIGITAL] DEBUG [HttpRequestHandler-20077295]
RequestUtils.createActionForm(294) |  Creating new ActionForm instance
of type 'com.synos.pbh.opdigital.view.form.mailing.VisitanteForm'
[java] [OPDIGITAL] DEBUG [HttpRequestHandler-20077295]
RequestUtils.createActionForm(300) |  --
[EMAIL PROTECTED]
[java] [OPDIGITAL] DEBUG [HttpRequestHandler-20077295]
RequestProcessor.processActionForm(339) |  Storing ActionForm bean
instance in scope 'request' under attribute key
'cadastrarVisitanteForm'
[java] [OPDIGITAL] DEBUG [HttpRequestHandler-20077295]
RequestProcessor.processPopulate(805) |  Populating bean properties
from this request
[java] [OPDIGITAL] DEBUG [HttpRequestHandler-20077295]
RequestProcessor.processValidate(948) |  Validating input form
properties
[java] [OPDIGITAL] DEBUG [HttpRequestHandler-20077295]
RequestProcessor.processValidate(980) |  Validation failed, returning
to '/cadastroVisitante.do'

This time, as the validate method is called, and it fails, i get the
proper message.

Dude I hate this little bugs, Im sure I missed something somewhere ...

Regards
On 7/4/06, David Friedman [EMAIL PROTECTED] wrote:

Do they both have action mapping with 'validate=true'?

Do they both have the same signature for you personal validate() method in
ActionForm?  (i.e. not in Action but ActionForm).  Remember, the method
signature must match YOUR version of struts.

Are there any errors in your log files that might shed some light on this?

Regards,
David

-Original Message-
From: Vinicius Carvalho [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 04, 2006 12:34 PM
To: Struts Users Mailing List
Subject: Re: Validation problems: again...


Hum, how could the one of them being validated them? If both extend
ActionForm? I gave up from validation plugin, I'm writing my own
validate method, isn't validate called even from ActionForm
subclasses?

Regards

On 7/4/06, Paul Benedict [EMAIL PROTECTED] wrote:
 You write:
  Can someone explain me this? Both form extend ActionForm and both
actions extend a common action.

 Vinicius, I think you need to refer to my previous email: ActionForm does
not validate. You need to extend from ValidatorActionForm or ValidatorForm.
The first valdiates based on URI, the second on the form name.

 Paul

 Vinicius Carvalho [EMAIL PROTECTED] wrote: Well, I've just quit
the validation on strtuts (based on
 commons-validator). So I've decided to use dumb manual validation.

 Well problem is, I still can't get one of my forms to validate!

 Here´ my struts-config:



 type=com.synos.pbh.opdigital.view.form.votacao.CadastrarVotanteForm

 type=com.synos.pbh.opdigital.view.form.mailing.VisitanteForm



 type=com.synos.pbh.opdigital.view.action.votacao.CadastrarVotante
 name=cadastrarVotanteForm input=/cadastroVotante.do




 validate=true

type=com.synos.pbh.opdigital.view.action.mailing.ConfirmarCadastroVisitante
Action
 name=cadastrarVisitanteForm input=/cadastroVisitante.do



 What's really pissing me off is that the first formbean/action mapping
 is just ignoring the validate phase, but the second don't. Can someone
 explain me this? Both form extend ActionForm and both actions extend a
 common action.

 How come this be possible? Please, I tried everthing I know and
 nothing seems to make it work, I must be missing a spot somewhere,
 just can't find it.

 Regards

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




 -
 Do you Yahoo!?
  Everyone is raving about the  all-new Yahoo! Mail Beta.


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


-
To unsubscribe, e-mail: [EMAIL PROTECTED

RE: Validation problems: again...

2006-07-04 Thread David Friedman
Have you deleted your server's work directory to ensure that all new classes
are being invoked next time you run it?  And of course try it again before
replying.

Can you post all together:

a) Your complete related form bean mappings (from ... to / for each
mapping, you can cut out any private domain portions of your class name)
b) Your complete related action mappings (from ... to / for each mapping,
you can cut out any private domain portions of your class name)
c) The signature and return lines of your validate methods (contents not
required, only those lines)

Regards,
David

-Original Message-
From: Vinicius Carvalho [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 04, 2006 1:06 PM
To: Struts Users Mailing List
Subject: Re: Validation problems: again...

yes both of em, I've post a pice of the config file ;)
yes either, both has validate(ActionMapping arg0, HttpServletRequest
arg1) signature.
My struts version is 1.2.9.

Looking at the logs, for the action/form that just skip validation:
 [java] [OPDIGITAL] DEBUG [HttpRequestHandler-6148719]
RequestUtils.createActionForm(300) |  --
[EMAIL PROTECTED]
 [java] [OPDIGITAL] DEBUG [HttpRequestHandler-6148719]
RequestProcessor.processActionForm(339) |  Storing ActionForm bean
instance in scope 'request' under attribute key 'cadastrarVotanteForm'
 [java] [OPDIGITAL] DEBUG [HttpRequestHandler-6148719]
RequestProcessor.processPopulate(805) |  Populating bean properties
from this request
 [java] [OPDIGITAL] DEBUG [HttpRequestHandler-6148719]
RequestProcessor.processValidate(948) |  Validating input form
properties
 [java] [OPDIGITAL] DEBUG [HttpRequestHandler-6148719]
RequestProcessor.processValidate(953) |   No errors detected,
accepting input


Well no errors detected? It does not even calls my validate method...

Now for the other action:

  [java] [OPDIGITAL] DEBUG [HttpRequestHandler-20077295]
RequestUtils.createActionForm(294) |  Creating new ActionForm instance
of type 'com.synos.pbh.opdigital.view.form.mailing.VisitanteForm'
 [java] [OPDIGITAL] DEBUG [HttpRequestHandler-20077295]
RequestUtils.createActionForm(300) |  --
[EMAIL PROTECTED]
 [java] [OPDIGITAL] DEBUG [HttpRequestHandler-20077295]
RequestProcessor.processActionForm(339) |  Storing ActionForm bean
instance in scope 'request' under attribute key
'cadastrarVisitanteForm'
 [java] [OPDIGITAL] DEBUG [HttpRequestHandler-20077295]
RequestProcessor.processPopulate(805) |  Populating bean properties
from this request
 [java] [OPDIGITAL] DEBUG [HttpRequestHandler-20077295]
RequestProcessor.processValidate(948) |  Validating input form
properties
 [java] [OPDIGITAL] DEBUG [HttpRequestHandler-20077295]
RequestProcessor.processValidate(980) |  Validation failed, returning
to '/cadastroVisitante.do'

This time, as the validate method is called, and it fails, i get the
proper message.

Dude I hate this little bugs, Im sure I missed something somewhere ...

Regards


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



Re: Validation Problems

2006-05-07 Thread Richard Yee

Sandeep,
You can do complex validations in your ActionForm validate method. You 
can also still invoke Validator validations by calling super.validate() 
in your validation method if you are extending 
|org.apache.struts.validator.action.ValidatorForm


I have found that there are many situations where complex validations 
are more easily handled in a validate() rather than trying to use 
validwhen or requiredif in the validation.xml


-Richard
|
Sandeep Dhanuka wrote:

Hi Everyone,

I am using struts validatior to valiate my form on JSP and dont want 
to take

validation to my Action class.

I have a check box and a text box on my JSP. I want to validate text 
box to

have 19 characters when check box is not checked and 17 characters when
checkbox is checked.

How should I go about solving the problem using validwhen.


Regards
Sandeep




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



Re: Validation problems

2006-01-28 Thread Debendra Barik
Hello,
  I don't know what exactly you are doing, whre you are calling the validation 
condition.
  But still i have  a copule of alternative for you, just try. Hope your 
problem will be solved. Because i had same problem and i solved that by 
applying this teh.
   
  Solution:
  Step1. Your action mapping and form bean looking ok.
   
   action path=/Search name=searchForm type=
com.actions.SearchAction input=home.jsp validate=true
forward name=success path=
displaysearchresults.jsp/
forward name=error path=home.jsp/
/action
  
  Struts config DynaActionForm:
  form-bean name=searchForm type=
 org.apache.struts.action.DynaActionForm
  form-property name=searchString type=java.lang.String
 /form-property

  Step2: is this the page called(home.jsp)if then
  Just use it i have modified your code inside the jsp page.
  jsp:
  html:form action=/Search
  
  input type=text name=searchString size=30 
html:errors/
  input type=submit name=Submit value=Go
  /html:form
   
  Step 3:
  Create an instance of your DynaActionForm in the SearchAction Class
  like example: 
  DynaActionForm dform=(DynaActionForm)form;
  Step4:
  your condition checking appearing wrong, because you cann't directly access 
the text field defined in the form. So i am suggesting two ways to do this:
  String search=dform.getString(searchString);
  or
  Note: to use bellow method write this statement at the top of your action 
class(SearchAction) that is:
  import org.apache.commons.beanutils.BeanUtils; then follow step bellow
  String search=(String)PropertyUtils.getSimpleProperty(form,searchString);
  Step5:
  if(search.equals(kill)){
  ActionMessages errors=new ActionMessages();
  errors.add(searchString, new ActionMessage( errors.required, 
searchString));
  }
  if(!errors.isEmpty()){
  saveErrors(request,errors);
 }
  return mapping.findForward(error);
/*
  1. if(dform.get())
 
   if(searchString.equals(kill)){
ActionErrors errors = new ActionErrors();
errors.add(errors, new ActionError(errors, errors));
saveErrors(request, errors);
 
return mapping.findForward(error);
  */


   
  I think now you will able to see your error message in your home page when 
the searchString field match with the string kill.
  Note: Make sure your program can able to access your 
MessageResources.properties file. So the message string for errors.required  
will be retrieved frorm MessagesResources and it will display on the home.jsp 
page.
  If still you have problem, then let me know by some more details like action 
class, enviromnet you are using so i will try to help you out.
  Thanks,
  Debendra.
   
   


-
 Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews,  more on new 
and used cars.

Re: Validation problems

2006-01-27 Thread Niall Pemberton
On 1/26/06, Daniel Kies [EMAIL PROTECTED] wrote:
 Hello.  I am trying to do some standard validations, but I am failing. Any
 ideas why?  I know the errors are getting raised as the request is
 forwarding back to the initial page making the request, but the error
 messages are not showing on the page.  Any help is appreciated!

 Struts config DynaActionForm:
 form-bean name=searchForm type=org.apache.struts.action.DynaActionForm
 form-property name=searchString type=java.lang.String/form-property

 action path=/Search name=searchForm type=com.actions.SearchAction
 input=/LoadHomePage.do validate=true
 forward name=success path=displaysearchresults.jsp/
 forward name=error path=LoadHomePage.do/
 /action


 jsp:
 html:form action=/Search
 html:errors/
 input type=text name=searchString size=30 
 input type=submit name=Submit value=Go
 /html:form

  if(searchString.equals(kill)){
   ActionErrors errors = new ActionErrors();
   errors.add(errors, new ActionError(errors, errors));
   saveErrors(request, errors);

   return mapping.findForward(error);

Action chaining is generally not recommended...

http://struts.apache.org/struts-doc-1.2.x/faqs/newbie.html#chaining

...however, although your input/error is mapped to another action - I
can't see anything that would prevent your errors being shown. Unless
your LoadHomePage is a redirect? Maybe you could try having your
input/error mapping straight to a jsp and see if the errors appear
then? Also, could you show the entry for LoadHomePage  in your
struts-config.xml?

Niall

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



Re: Validation problems

2006-01-27 Thread Daniel Kies
Niall:

I took your recommendation and removed the action chaning from my struts
config.  I am still not seeing any error text.  Here is my new action
mapping:

action path=/Search name=searchForm type=
com.actions.SearchAction input=home.jsp validate=true
forward name=success path=
displaysearchresults.jsp/
forward name=error path=home.jsp/
/action

On 1/27/06, Niall Pemberton [EMAIL PROTECTED] wrote:

 On 1/26/06, Daniel Kies [EMAIL PROTECTED] wrote:
  Hello.  I am trying to do some standard validations, but I am failing.
 Any
  ideas why?  I know the errors are getting raised as the request is
  forwarding back to the initial page making the request, but the error
  messages are not showing on the page.  Any help is appreciated!
 
  Struts config DynaActionForm:
  form-bean name=searchForm type=
 org.apache.struts.action.DynaActionForm
  form-property name=searchString type=java.lang.String
 /form-property
 
  action path=/Search name=searchForm type=com.actions.SearchAction
  input=/LoadHomePage.do validate=true
  forward name=success path=displaysearchresults.jsp/
  forward name=error path=LoadHomePage.do/
  /action
 
 
  jsp:
  html:form action=/Search
  html:errors/
  input type=text name=searchString size=30 
  input type=submit name=Submit value=Go
  /html:form
 
   if(searchString.equals(kill)){
ActionErrors errors = new ActionErrors();
errors.add(errors, new ActionError(errors, errors));
saveErrors(request, errors);
 
return mapping.findForward(error);

 Action chaining is generally not recommended...

 http://struts.apache.org/struts-doc-1.2.x/faqs/newbie.html#chaining

 ...however, although your input/error is mapped to another action - I
 can't see anything that would prevent your errors being shown. Unless
 your LoadHomePage is a redirect? Maybe you could try having your
 input/error mapping straight to a jsp and see if the errors appear
 then? Also, could you show the entry for LoadHomePage  in your
 struts-config.xml?

 Niall

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




Re: Validation problems

2006-01-26 Thread Thomas Garben
Dan,

Should you be using
html:text 
instead of:
input type=text name=searchString size=30 
input type=submit name=Submit value=Go

Tom





Daniel Kies [EMAIL PROTECTED] 
01/26/2006 04:07 PM
Please respond to
Struts Users Mailing List user@struts.apache.org


To
Struts Users Mailing List user@struts.apache.org
cc

Subject
Validation problems






Hello.  I am trying to do some standard validations, but I am failing. Any
ideas why?  I know the errors are getting raised as the request is
forwarding back to the initial page making the request, but the error
messages are not showing on the page.  Any help is appreciated!

Struts config DynaActionForm:
form-bean name=searchForm 
type=org.apache.struts.action.DynaActionForm
form-property name=searchString 
type=java.lang.String/form-property

action path=/Search name=searchForm type=com.actions.SearchAction
input=/LoadHomePage.do validate=true
forward name=success path=displaysearchresults.jsp/
forward name=error path=LoadHomePage.do/
/action


jsp:
html:form action=/Search
html:errors/
input type=text name=searchString size=30 
input type=submit name=Submit value=Go
/html:form

  if(searchString.equals(kill)){
   ActionErrors errors = new ActionErrors();
   errors.add(errors, new ActionError(errors, errors));
   saveErrors(request, errors);

   return mapping.findForward(error);



Re: Validation problems

2006-01-26 Thread Daniel Kies
Either one would work, to be consistent with other struts tags I am using,
html:text is probably better.  This doesn't affect the validation issue.

On 1/26/06, Thomas Garben [EMAIL PROTECTED] wrote:

 Dan,

 Should you be using
 html:text
 instead of:
 input type=text name=searchString size=30 
 input type=submit name=Submit value=Go

 Tom





 Daniel Kies [EMAIL PROTECTED]
 01/26/2006 04:07 PM
 Please respond to
 Struts Users Mailing List user@struts.apache.org


 To
 Struts Users Mailing List user@struts.apache.org
 cc

 Subject
 Validation problems






 Hello.  I am trying to do some standard validations, but I am failing. Any
 ideas why?  I know the errors are getting raised as the request is
 forwarding back to the initial page making the request, but the error
 messages are not showing on the page.  Any help is appreciated!

 Struts config DynaActionForm:
 form-bean name=searchForm
 type=org.apache.struts.action.DynaActionForm
 form-property name=searchString
 type=java.lang.String/form-property

 action path=/Search name=searchForm type=com.actions.SearchAction
 input=/LoadHomePage.do validate=true
 forward name=success path=displaysearchresults.jsp/
 forward name=error path=LoadHomePage.do/
 /action


 jsp:
 html:form action=/Search
 html:errors/
 input type=text name=searchString size=30 
 input type=submit name=Submit value=Go
 /html:form

   if(searchString.equals(kill)){
ActionErrors errors = new ActionErrors();
errors.add(errors, new ActionError(errors, errors));
saveErrors(request, errors);

return mapping.findForward(error);





RE: Validation Problems

2005-04-19 Thread Folashade Adeyosoye
Try using DynaValidatorActionForm...



-Original Message-
From: Andrew Thorell [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 19, 2005 10:44 AM
To: Struts Mailing List
Subject: Validation Problems

Hey all,

I've been trying for some time now to figure out what my problem is
with my Validations not displaying error messages back to the page
from where the request came from. It's a simple login page which
pretty much follows Ted's Struts in Action example.

I'm using a Form which extends ValidatorForm, using the html:errors
/ tag in my jsp.

If you need anymore code that what's below, let me know.

public static final String errors_login=lifont
color=\red\Wrong User Name and/or Password/font/li;
public static final String errors_userpassequal=liInvalid Email
Address./li;


public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request)
{
ActionErrors errors = null;
errors = super.validate(mapping, request);

if (errors == null) 
{
errors = new ActionErrors();
}

if (username.equals(password))
{
errors.add(password, new
ActionMessage(Constants.errors_login));
}
if (! org.apache.commons.validator.GenericValidator.isEmail(
getusername() ) )
{
errors.add(username, new
ActionMessage(Constants.errors_userpassequal));
}
return errors;
}

// Execute Method from my Action which extends just Action:

public ActionForward execute(ActionMapping mapping, ActionForm
form, HttpServletRequest request,
HttpServletResponse response) throws IOException,
ServletException
{
boolean validate = false;

if (!validate)
{
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_MESSAGE, new   

ActionMessage(Constants.errors_login) );
saveErrors(request, errors);
// getInput() just returns to index.jsp where the html:errors / tag
resides.
return (new ActionForward(mapping.getInput() ) );
}
 }

I'm purposely making the whole validation process fail just to get any
error message to display (Which they aren't). I was going to try using
html:messages but I'm unsure how to assign the id= tag and where I
can set the attribute for it.

Thanks for any help in advance, let me know if I can clear anything up.

-
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: Validation Problems

2005-04-19 Thread Andrew Thorell
Thanks for the speedy reply, My time is limited to solve this
particular problem, but I'll definitely look into using
DynaValidatorActionForm. I do have another question though, why would
not using DynaValidatorActionForm prevent my  code from display the
error back to the jsp? Is there a limitation that I'm unaware of with
my current setup?

Thanks again,

Andrew

On 4/19/05, Folashade Adeyosoye [EMAIL PROTECTED] wrote:
 Try using DynaValidatorActionForm...

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