You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Frank Schaare <Lo...@gmx.de> on 2004/03/31 15:12:28 UTC

Switching validation on | off

Hi,

i have a dynaValidatorForm declared with validate="true". Under certain
conditions, i´d like to turn validation off. Is there any chance to achive this
on the fly ?

-- 
+++ NEU bei GMX und erstmalig in Deutschland: TÜV-geprüfter Virenschutz +++
100% Virenerkennung nach Wildlist. Infos: http://www.gmx.net/virenschutz


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Switching validation on | off

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
You could extend DynaValidatorForm and override the validate() method in the
DynaValidatorForm:

public ActionErrors validate(ActionMapping mapping,
           HttpServletRequest request) {

    if (---?????????---) {
        return super.validate(mapping, request);
    }

}
Niall

----- Original Message ----- 
From: "Frank Schaare" <Lo...@gmx.de>
To: <st...@jakarta.apache.org>
Sent: Wednesday, March 31, 2004 2:12 PM
Subject: Switching validation on | off


> Hi,
>
> i have a dynaValidatorForm declared with validate="true". Under certain
> conditions, i´d like to turn validation off. Is there any chance to achive
this
> on the fly ?
>
> -- 
> +++ NEU bei GMX und erstmalig in Deutschland: TÜV-geprüfter Virenschutz
+++
> 100% Virenerkennung nach Wildlist. Infos: http://www.gmx.net/virenschutz
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Struts and plugin question

Posted by Andrew Hill <an...@gridnode.com>.
btw: actually I often tend to make the static method a member of the object
that my plugin is initialising, - but only do that if the object is already
'servlet aware'. otoh if the object isnt supposed to know about servlets and
such like (or its a third party thing) then you dont want to introduce a
dependency on servlet.jar so just do it like I said below.

-----Original Message-----
From: Andrew Hill [mailto:andrew.david.hill@gridnode.com]
Sent: Wednesday, 31 March 2004 23:08
To: Struts Users Mailing List
Subject: RE: Struts and plugin question


<snip>
But, fact is that when I want to get my component from servletcontext
I have to cast it to my  proper type.
Is there a way to avoid that?
</snip>

Not really, but you could create a static (or non static if you like) helper
method somewhere to take care of both remembering the key and casting:

public class MyComponentFinder
{
  public static final MyComponent getMyComponent(ServletContext sc)
  {
    return (MyComponent)sc.getATtribute(MY_COMPONENT_KEY);
  }
}

-----Original Message-----
From: Marco Mistroni [mailto:mmistroni@waersystems.com]
Sent: Wednesday, 31 March 2004 23:02
To: 'Struts Users Mailing List'
Subject: Struts and plugin question


Hi all,
	I was wondering something about plugIns.

Let's say, I want to create an object that has application context.
So I create a plugIn to initialize it and store it in ServletContext.
But, fact is that when I want to get my component from servletcontext
I have to cast it to my  proper type.
Is there a way to avoid that?

Just for some brainstorming....

Thanx in advance to all the replies
Regards
	marco


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Struts and plugin question

Posted by Andrew Hill <an...@gridnode.com>.
<snip>
But, fact is that when I want to get my component from servletcontext
I have to cast it to my  proper type.
Is there a way to avoid that?
</snip>

Not really, but you could create a static (or non static if you like) helper
method somewhere to take care of both remembering the key and casting:

public class MyComponentFinder
{
  public static final MyComponent getMyComponent(ServletContext sc)
  {
    return (MyComponent)sc.getATtribute(MY_COMPONENT_KEY);
  }
}

-----Original Message-----
From: Marco Mistroni [mailto:mmistroni@waersystems.com]
Sent: Wednesday, 31 March 2004 23:02
To: 'Struts Users Mailing List'
Subject: Struts and plugin question


Hi all,
	I was wondering something about plugIns.

Let's say, I want to create an object that has application context.
So I create a plugIn to initialize it and store it in ServletContext.
But, fact is that when I want to get my component from servletcontext
I have to cast it to my  proper type.
Is there a way to avoid that?

Just for some brainstorming....

Thanx in advance to all the replies
Regards
	marco


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Struts and plugin question

Posted by Marco Mistroni <mm...@waersystems.com>.
Hi all,
	I was wondering something about plugIns.

Let's say, I want to create an object that has application context.
So I create a plugIn to initialize it and store it in ServletContext.
But, fact is that when I want to get my component from servletcontext
I have to cast it to my  proper type.
Is there a way to avoid that? 

Just for some brainstorming....

Thanx in advance to all the replies
Regards
	marco


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Switching validation on | off

Posted by Joe Germuska <Jo...@Germuska.com>.
>i have a dynaValidatorForm declared with validate="true". Under certain
>conditions, i´d like to turn validation off. Is 
>there any chance to achive this
>on the fly ?

Depending on how dynamic your rules for 
validating or not are, you may be able to use the 
DynaValidatorActionForm.  The only difference 
between DVAF and DVF is that DVAF uses the 
ActionMapping's path value to look up a 
validation configuration from the 
commons-validator, while DVF uses the form-bean's 
name.

If you can't use action paths to signal your 
validation intentions, then Niall's suggestion is 
the way to go.

Joe

-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
       "Imagine if every Thursday your shoes 
exploded if you tied them the usual way.  This 
happens to us all the time with computers, and 
nobody thinks of complaining."
             -- Jef Raskin

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org