Re: Question on validation
Le mercredi 23 janvier 2008 à 11:17 +0200, Andriy Kharchuk a écrit : > You can turn off validation for a specific method by using the > @SkipValidation annotation above your action method. > > http://struts.apache.org/2.x/docs/validation.html > Ok many thanks, I though it works only for validation in java, not with .xml files -- Martin Braure de Calignon signature.asc Description: Ceci est une partie de message numériquement signée
Re: Question on validation
Le lundi 21 janvier 2008 à 14:35 +0100, Martin Braure de Calignon a écrit : > Hello :-), > > I have two questions, the first one is more important for me : > I have a validation xml files, but I want to validate only if user click > on 'OK' button, and not on 'Cancel'. How to do this ? Do I have to make > all my fields as expression or fieldexpression and test the value of the > submit button ? Well, ok my problem was that my cancel button wasn't defined a action= inside it, so it goes throw the validator.xml of 'Ok' button. Sorry in fact the problem is to deal with conversion errors and cancel button. For example, for a Date field, user input is 'd', which throw a conversion exception. So 'input' result is throw... Can I ignore all the value of field of my form on cancel button ? For the moment, I add a onclick="this.form.reset()" to my submit button. And it works... Any other possibility ? (Sorry for the noise) -- Martin Braure de Calignon - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Question on validation
Hello :-), I have two questions, the first one is more important for me : I have a validation xml files, but I want to validate only if user click on 'OK' button, and not on 'Cancel'. How to do this ? Do I have to make all my fields as expression or fieldexpression and test the value of the submit button ? The second question is more complicated. When there's a validation error, I want to display back the page but with errors. I'm using wildcard action, and per-method (per-alias) validation. What I've done for the moment, but I think it's not a clear method, is to have an interceptor (BackViewInterceptor), that intercept the result 'input', and change it to the previous result. But this solution only works on simple cases. Is there's a better way of handling such a behaviour ? Thank you all, -- Martin Braure de Calignon - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validation question
Le vendredi 11 janvier 2008 à 15:46 -0800, Dave Newton a écrit : > The validation interceptor will look for, and call, validate${methodName} > (and validateDo${methodName}). > > d. Great ! thank you all :-) -- Martin Braure de Calignon signature.asc Description: Ceci est une partie de message numériquement signée
Re: Validation question
Le vendredi 11 janvier 2008 à 09:15 -0500, Ted Husted a écrit : > On Jan 11, 2008 8:10 AM, Martin Braure de Calignon <[EMAIL PROTECTED]> wrote: > > Of course yes :-). But I need a validate() per method. > > I haven't used it myself, but the syntax validate-action is suppose to > work, in the same way that it works for the validation framework. I don't think so. You see, with per alias or per method validation, you can have multiple xml files for the same action with the filename format : ActionName-alias-validation.xml e.g.: if I have defined my action like this : View1.jsp View2.jsp View3.jsp I can per alias validation. As I'm using wildcards, it is as if I defined CycleManagement!A action and CycleManagement!B action ... So I can have : CycleManagement-CycleManagement!A-validation.xml CycleManagement-CycleManagement!B-validation.xml CycleManagement-CycleManagement!C-validation.xml I don't see how implementing Validatable allow me such a thing. I will only have one Validate() method (without parameter) for my action class. No ? Am I missing something ? Cheers, -- Martin Braure de Calignon signature.asc Description: Ceci est une partie de message numériquement signée
Re: Validation question
Le vendredi 11 janvier 2008 à 07:36 -0500, Ted Husted a écrit : > Rather than use the validation framework, I'd probably go with a > Validate method (by implementing Validatable). Firstly, thank you very much for your answer :) Ok then... That what I though... But my problem is that Validate() is called every time no ? I mean, I currently use action like that : View1.jsp View2.jsp View3.jsp and I have per-method validation... Is it possible with Validate() ? How can I do ? (I think it's possible with ActionContext.(... get current method...)) > Then, instead of using an OGNL expression, you can loop through the > list using Java, and call addFieldError if there's a problem. Of course yes :-). But I need a validate() per method. > Alternatively, a custom type converter that turned the nulls into > false booleans might work, or there might be another way to form the > OGNL expression. But given the choice between OGNL and Java, I'll take > Java. :) So for me it seems the better choice would be type converter ? what do you think ? Thanks, -- Martin Braure de Calignon signature.asc Description: Ceci est une partie de message numériquement signée
[S2] validation on list of bean (was Validation question)
Le mardi 08 janvier 2008 à 14:08 +0100, Martin Braure de Calignon a écrit : Sorry I've forgot [S2] in subject > Hello, > > I'm currently using struts2 for a project. > I want to validate all elements of a list (each elements should have a > non-empty value, or the list should be empty). > > what I have done in my validator is : > > > > > > > error ${myList.size} > > > > Then in console I have a warning, and the validator does not do what I > want. > WARN - Got result of null when trying to get Boolean > I don't know if it is related to my validator but it seems to be. > > Any idea on how writing validator on all elements of the list ? > > Thanks :-) -- Martin Braure de Calignon signature.asc Description: Ceci est une partie de message numériquement signée
Validation question
Hello, I'm currently using struts2 for a project. I want to validate all elements of a list (each elements should have a non-empty value, or the list should be empty). what I have done in my validator is : error ${myList.size} Then in console I have a warning, and the validator does not do what I want. WARN - Got result of null when trying to get Boolean I don't know if it is related to my validator but it seems to be. Any idea on how writing validator on all elements of the list ? Thanks :-) -- Martin Braure de Calignon signature.asc Description: Ceci est une partie de message numériquement signée