struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From benjamin haimerl <b-ski...@gmx.de>
Subject Re: How to avoid validation if request was done by GET method?
Date Fri, 27 Mar 2009 17:08:44 GMT
its the default validation method...

- if you use the Validation Framework ( FormBean extends ValidationForm)
its validation method will be called(validate all  fields  against the 
configuration in validation.xml) 
and all errors will be added to the default  ActionMessage Object

- if u use your own validate method its in your hand what happens if 
some errors occur
maybe adding the error with
ActionMessages msgs = new ActionMessages();
messages.add(ActionMessages.GLOBAL_MESSAGE, new 
ActionMessage("error.xxx.xxx"));
or something like that



boraldo wrote:
> Do I understand properly that ActionSupport.validate method that you used
> here performs the same validation as validation interceptor ?
>
> How can I see if there were validation errors ?
>
>
>
> benjamin haimerl wrote:
>   
>> hi boraldo
>>
>> a very simple way should be:
>>
>>
>> Action:
>>
>> YourActionConnetedToTheFormAction extends Action..{
>>
>> execute(..){
>>
>> String qString = request.getQueryString();
>> if(qString!=null && paramsFound(...))
>>    // *paramsFound() = check if your formParams were given by query String
>> }
>> else {
>> //check if your formBean is set (depends on the scope you have set in 
>> your struts-config.xml)
>> //e.g.
>>   if(request.getAttribute(yourForm)!=null) {
>>   yourForm.validate() {
>> }
>>  }
>> }
>>
>> }
>>
>> should work ;)
>>
>>
>>
>> boraldo wrote:
>>     
>>> I have a form. And I want to have one url for form itself and for
>>> submitting
>>> it.
>>> Controller should look at method and if it is GET, show form, if POST -
>>> make
>>> validations and so on.
>>>
>>> How can I do it ?
>>>   
>>>       
>> ---------------------------------------------------------------------
>> 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


Mime
View raw message