Re: Programmatic Validation in Action

2007-06-11 Thread Matt Luce

This issue is related to my other "issue" with the ModelDriven interface.


Re: Programmatic Validation in Action

2007-06-11 Thread Caine Lai

I hope this code:

public void setAttribue(String attr)
  {
 this.attribute = attr;
  }

Is a typo?  If not, this is why your attribute is not being set in your
action class.

Also, since you are forwarding to the same page regardless of success,
failure and input... are you sure it is actually failing and returning
INPUT?


On 6/9/07, Matt Luce <[EMAIL PROTECTED]> wrote:


Has anyone attempted to use programmatic validation in Struts 2?  When I
add an actionError and return INPUT, it properly goes back to the page
with the form, but it does not keep the values that I typed.  Shouldn't
that work?  This is how it worked in Struts 1.


package com.company.action;

import com.opensymphony.xwork2.ActionSupport;


public class ExampleValidateAction extends ActionSupport
{

private string attribute;

public String execute() throws Exception
{

// complicated validation logic.  Too complicated for xml
validation
this.addActionError("Validation Error");
return INPUT;


}

public string getAttribute()
{
   return attribute;
}

public void setAttribue(String attr)
{
   this.attribute = attr;
}

}




Re: Programmatic Validation in Action

2007-06-09 Thread Torsten Römer
I put my validation code in the validate() method and use addFieldError().

To avoid validation to be performed on initial form display, I made a
mapping like this:


  bookedTiles
  reservationTiles
  errorTiles


and call the action "reservation_input". Struts knows then that it
should not perform validation.

The form itself then calls the action "reservation".

It works fine for me, just that special characters (üöä...) in the typed
values are sometimes messed up when the form is redisplayed on
validation error :-(

Torsten

Matt Luce schrieb:
> Has anyone attempted to use programmatic validation in Struts 2?  When I
> add an actionError and return INPUT, it properly goes back to the page
> with the form, but it does not keep the values that I typed.  Shouldn't
> that work?  This is how it worked in Struts 1.
> 
> 
> package com.company.action;
> 
> import com.opensymphony.xwork2.ActionSupport;
> 
> 
> public class ExampleValidateAction extends ActionSupport
> {
> 
>private string attribute;
> 
>public String execute() throws Exception
>{
> 
>// complicated validation logic.  Too complicated for xml validation
>this.addActionError("Validation Error");
>return INPUT;
> 
> 
>}
> 
>public string getAttribute()
>{
>   return attribute;
>}
> 
>public void setAttribue(String attr)
>{
>   this.attribute = attr;
>}
> 
> }
> 
> 

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



RE: Programmatic Validation in Action

2007-06-09 Thread Matt.Luce
Sure, it's really simple:

  // this is action is
configured in spring
/update.jsp
/update.jsp
/update.jsp


When it goes to the "input" result, the values I typed in are no longer
present.

-Original Message-
From: Dave Newton [mailto:[EMAIL PROTECTED] 
Sent: Saturday, June 09, 2007 2:49 PM
To: Struts Users Mailing List
Subject: Re: Programmatic Validation in Action

--- Matt Luce <[EMAIL PROTECTED]> wrote:
> Has anyone attempted to use programmatic validation in Struts 2?

Sure, although I still used the validation interfaces.

What does your mapping look like?

d.



   


Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.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: Programmatic Validation in Action

2007-06-09 Thread Dave Newton
--- Matt Luce <[EMAIL PROTECTED]> wrote:
> Has anyone attempted to use programmatic validation
> in Struts 2?  

Sure, although I still used the validation interfaces.

What does your mapping look like?

d.



   

Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/

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



Programmatic Validation in Action

2007-06-09 Thread Matt Luce
Has anyone attempted to use programmatic validation in Struts 2?  When I 
add an actionError and return INPUT, it properly goes back to the page 
with the form, but it does not keep the values that I typed.  Shouldn't 
that work?  This is how it worked in Struts 1.



package com.company.action;

import com.opensymphony.xwork2.ActionSupport;


public class ExampleValidateAction extends ActionSupport
{

   private string attribute;

   public String execute() throws Exception
   {

   // complicated validation logic.  Too complicated for xml 
validation

   this.addActionError("Validation Error");
   return INPUT;


   }

   public string getAttribute()
   {
  return attribute;
   }

   public void setAttribue(String attr)
   {
  this.attribute = attr;
   }

}