Title: Message
Jason,
 
I think of an another idea to resolve the point 1/, because adding ValidationAware to TypeConverters are not a so good idea...
I think to use the ValueStack to push ActionError ... It is very elegant and not so hard to implement.
Afterwards it is always possible that the validation framework pops every ActionError from the ValueStack and add them easily to the Action (ValidationAware) with the addFieldErrors().
Moreover, in this case we could deal with the problem of removing the message #2 generated from validators
#1 "This is not a valid date" (from converters)
#2 "The date is required" (from validators)
 
Any feedbacks welcomed.

Richard HALLIER
Chef de projet
[EMAIL PROTECTED]
01.40.12.41.52
www.uniclick.org
UNICLICK
 
-----Message d'origine-----
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]De la part de Jason Carreira
Envoy� : mercredi 1 octobre 2003 22:42
� : [EMAIL PROTECTED]
Objet : RE: [OS-webwork] Issue with ModelDriven Validation

Good points...
 
1) I think Patrick and I are going to have to work together... I think the TypeConverter is going to need to get a ValidationAware from somewhere.... Maybe the ActionContext...
 
2) Good point... the problem is our built-in converters are masking the errors and returning null.... more work needed....
 
Jason
-----Original Message-----
From: Fred Lamuette [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 01, 2003 4:36 PM
To: [EMAIL PROTECTED]
Subject: RE: [OS-webwork] Issue with ModelDriven Validation

Hi Jason,
I've got the last cvs snapshot of XWork & WW2.
You have worked on 2 points :
- Managing errors occuring in converters
- Enabling Model Driven beans to be correctly validated in the validation framework
 
I've tested your work and I've got 2 remarks :
1/ When populating a model driven bean (ModelDrivenInterceptor  active) and a converter fails, you call handleConversionException(...). That's ok.
The problem is that a model driven bean is NOT an instance of ValidationAware !!!!!! So no chance to call addFieldError on this bean. Handling errors fails.
What is the solution ? Hum ...  
2/ Another very annoying point when  you handle errors from converters is that you consider a converter returning a null value is an error.
You can expect a null value to be a valid value like in this case:
Suppose you have a combo box listing entities with a particular item that is BLANK. In a EntityConverter that translates an id (String type) into an Entity object, you can expect the EntityConverter returns a null value. It just says : I attach no entity. So you cant say a null value returned from the converter means an error.
Why don't you remove this test ? Just handle exceptions thrown in the converters.
 
Except that, everything is ok for me.
 
Richard HALLIER
Chef de projet
[EMAIL PROTECTED]
01.40.12.41.52
www.uniclick.org
UNICLICK
 
 
-----Message d'origine-----
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]De la part de Jason Carreira
Envoy� : mercredi 1 octobre 2003 18:50
� : [EMAIL PROTECTED]
Objet : RE: [OS-webwork] Issue with ModelDriven Validation

This isn't in the latest WW2 yet, though... still having some issues bringing it in there. I'll send another note when people can try this out...
-----Original Message-----
From: Fred Lamuette [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 01, 2003 12:37 PM
To: [EMAIL PROTECTED]
Subject: RE: [OS-webwork] Issue with ModelDriven Validation

Thank you, jason
-----Message d'origine-----
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]De la part de Jason Carreira
Envoy� : mercredi 1 octobre 2003 16:31
� : [EMAIL PROTECTED]
Objet : RE: [OS-webwork] Issue with ModelDriven Validation

Ok, I've fixed this in CVS... It now uses the ValueStack
-----Original Message-----
From: Fred Lamuette [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 01, 2003 5:44 AM
To: [EMAIL PROTECTED]
Subject: RE: [OS-webwork] Issue with ModelDriven Validation

I already posted this issue. The problem is that the validation framework uses the properties ONLY from the action, not from the value stack.
So if you want the validation framework works, you have to change you validation file as follows :

<field name="model.userName">
        <field-validator type="requiredstring">
            <message>You must enter a value for username</message>
        </field-validator> 
</field>

BUT it's not a workaround at all, because in your forms, input names are not "model.userName" but "userName", so you can not match directly the FieldError from your input field.
Just to say : it's a bug. If you want model driven validation works, the validation framework must refer to the ValueStack not directly to the action.

Cheers.

Richard.

-----Message d'origine-----
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]De la part de Thompson, Kris
Envoy� : mardi 30 septembre 2003 22:46
� : Opensymphony-Webwork (E-mail)
Objet : [OS-webwork] Issue with ModelDriven Validation

I am having a problem with getting model driven validation.  I am getting an OGNL exception stating that if can't get the value of my property as defined in the <ActionClassname>-validation.xml file.  I remember reading about a bug in with this and model driven beans but not sure if it is related.   Below is a segment of the excpetion

Sep 30, 2003 2:23:50 PM com.opensymphony.xwork.validator.validators.ValidatorSupport getFieldValue
SEVERE: Caught exception while getting value for field userName
ognl.NoSuchPropertyException: userName
        at ognl.ObjectPropertyAccessor.getProperty(ObjectPropertyAccessor.java:123)
        at ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1219)
        at ognl.ASTProperty.getValueBody(ASTProperty.java:108)
        at ognl.SimpleNode.getValue(SimpleNode.java:129)
        at ognl.Ognl.getValue(Ognl.java:335)
        at ognl.Ognl.getValue(Ognl.java:310)
        at com.opensymphony.xwork.validator.validators.ValidatorSupport.getFieldValue(ValidatorSupport.java:80)
        at com.opensymphony.xwork.validator.validators.RequiredStringValidator.validate(RequiredStringValidator.java:23)


Here is a segment of the validation.xml file

<field name="userName">
        <field-validator type="requiredstring">
            <message>You must enter a value for username</message>
        </field-validator>
    </field>

And I my model does have a getter and setter with the correct case.

And lastly here are there interceptors and the order of which they are called.
                <interceptor-ref name="defaultStack"/>
            <interceptor-ref name="component"/>
            <interceptor-ref name="model-driven"/>       
            <interceptor-ref name="validation"/>
            <interceptor-ref name="workflow"/> 

Any help?

Kris

Reply via email to