Hi Johan,
Q1
Yes, you can combine the JSF validation with ExtVal, like you already found
out since you got 3 messages, 2 of extval and one of JSF.
Although, the idea is that you do everything with ExtVal. You can use
@Length as a replacement for the f:validateLength tag.
Except for the required attribute of the components. This required attribute
is overwritten by the ExtVal code based on the annotations it find on the
property. (so when no annotations set, attribute shouldn't be altered)
You can deactivate that behaviour by specifying the web context parameter
<context-param>
<param-name>org.apache.myfaces.extensions.validator.DEACTIVATE_COMPONENT_INITIALIZATION</param-name>
<param-value>true</param-value>
</context-param>
You also loose then some functionality related to the validation of empty
fields (like specified in the JSF 2.0 spec for example
javax.faces.VALIDATE_EMPTY_FIELDS)
The parameter can be of help about the problem of the value that disappears.
I can't see any reason why the f:validateLength tag impacts the display of
the field value. By using the web context parameter, we make sure the
annotation based bypass validation add-on can't interfere with the encoding
of the page (and thus preventing the display of the field)
I tried to recreate you problem with that but had no luck.
Q2
This could be a classloading problem of Tomcat.
Which of the parameters in web.xml did you try,
JPA_VALIDATION_ERROR_MESSAGES or CUSTOM_MESSAGE_BUNDLE
But you also say that, when ExtVal Libraries placed in WEB-INF/lib you don't
need to specify any parameter and all messages are displayed correctly. So
which messages have you placed in the properties file that are related to
ExtVal.
Regards
Rudy.
On 16 April 2010 08:52, Johan Borchers <[email protected]> wrote:
> Hello,
>
> I'm using Tomcat 6.0.20, Mojarra 1.2_14, RichFaces 3.3.3 and Extval 1.2.3
> on Mac en Windows with Java 1.6.0_17
> The Extval libs are:
> extval-annotation-based-bypass-validation-1.2.3.jar
> myfaces-extval-core-1.2.3.jar
> myfaces-extval-generic-support-1.2.3.jar
> myfaces-extval-property-validation-1.2.3.jar
>
> Extval is helping me al lot with bypass-validation because of fields in a
> form that perform looking up values.
> E.g. a manufacturer code field is required in the big picture. But the
> field is also performing an AJAX lookup of the manufacturer as you leave the
> field. At that moment it is legal to leave the field blank because you are
> just tabbing through your fields. So marking the lookup method with
> @BypassValidation(all = true) works perfect.
>
> Question 1 :
> Is it possible to use also the normal validation mechanism of JSF in
> combination with Extval?
>
> E.g I have 3 fields on a form with 2 fields having Extval @required
> validation and one field has the traditional validation property
> required="true" in the XHTML page.
> Sending the form with 3 blank fields gives me 2 faces messages back. Only
> the messages due to Extval validation.
> So for me it looks like Extval is disabling the JSF validation defined in
> the XHTML page.
>
> A little bit more strange is the behavior of the one field without Extval
> validation if I'm adding a validation to the field like <f:validateLength
> minimum="2" maximum="10"/>
> If I send the form with one character in the field and the 2 other fields
> are left blank I receive 3 faces messages (that's nice).
> And then after retrieving the records from the database showing up in a
> list clicking on the list fills normally all three fields in the form, but
> with the f:validateLength the field is left blank.
> Removing the f:validateLength from the field gives be back the normal
> behavior showing the data from the database.
>
>
> Question 2 :
> Where to place the Extval libraries?
>
> For developing I'm using 1 Tomcat installation per project. I do add all
> the libraries to the lib directory of Tomcat. Placing also the Extval
> libraries to this directory has a little problem.
> If i'm setting my locale to nl_NL and have a Messages_nl_NL.properties in
> my root package Mojarra will find it and Extval not. I do get the missing
> resource exception.
> Even using the special parameter in web.xml giving a hint to Extval finding
> the message bundle does not help.
> But I thought that has something to to with the classloader. I decided to
> place just the Extval libraries in the WEB-INF/lib directory. After that
> Extval is finding my locale specific message bundle perfectly even without
> the hint in web.xml.
> I know it is better to place all third party libs in WEB-INF/lib as of
> class loading but during development redeploying the web app a lot of times
> gives problems with e.g. reloading Mojarra.
>
>
> So that's a lot of text for few questions!
>
> I want to use Extval because of the flexible validation options. I hope
> someone can answer my questions so I will better understand how to use
> Extval?
>
> T.I.A.
>
> Johan Borchers