short addition:

@ExtValUtils:
i used a local prototype - that's the reason why it didn't work for you.
however, i uploaded a working implementation for trinidad at [1].
it works with the current version (e.g. [2]).

regards,
gerhard

[1] http://people.apache.org/~gpetracek/myfaces/extval/demos/trinidad
[2] http://svn.apache.org/repos/asf/myfaces/extensions/validator/trunk/

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces



2010/4/27 Gerhard Petracek <[email protected]>

> hi thomas,
>
> basically you have 3 possibilities with extval:
>  - use simple but dynamic validation, jpa based validation and
> cross-validation -> use extval-core + extval-property-validation (+ your
> custom constraints)
>  - use bean-validation + some advanced extval mechanisms for it -> use
> extval-core + extval-bean-validation + an impl. of bv (+ custom
> bv-constraints)
>  - create your own validation module(s)/concepts -> use extval-core + your
> own mechanisms on top of it
>
> for sure you can combine all modules. you just have to take care that you
> don't mix different types of constraints and their concepts (esp. in
> combination with extval add-ons). however, i would suggest that you just use
> one validation-module of extval. and as soon as you are using it for a real
> app, you should also think about tweaking it (e.g. see [1])
>
> two (simple) sample setups for extval + bv are available at [2] and [3].
> a nice intro is available at [4].
>
> regards,
> gerhard
>
> [1] http://wiki.apache.org/myfaces/Extensions/Validator/JSR303/Advanced
> [2]
> https://svn.apache.org/repos/asf/myfaces/extensions/validator/trunk/examples/hello_bean-validation/
> [3]
> https://svn.apache.org/repos/asf/myfaces/extensions/validator/trunk/examples/feature-set_02/
> [4] http://people.apache.org/~gpetracek/myfaces/extval/extval_chapter.html
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
> 2010/4/26 Tom M. <[email protected]>
>
> Hi Gerhard, hi Rudy,
>>
>> thank you for your quick response.
>>
>> I tried to proceed just like you suggested but the meta data for the bean
>> validation annotations is not found. ExtValUtils.getTransformedMetaData()
>> always returns an empty map. The reason seems to be that
>> DefaultValidationStrategyFactory.create(String) only holds JPA-Mappings
>> and
>> no BV-Mappings. Am I missing some jars or where can I find something like
>> javax.validation.constraints.NotNull[Validation]Strategy or
>> bean:notNull[Validation]Strategy which is looked for?
>>
>> For my own annotation @RequiredExactlyOneOf (similar to ExtVal's
>> @RequiredIf) I managed to extract the meta data with my own transformer,
>> but
>> I have to take a closer look tomorrow how to go on from that point.
>>
>> Thomas
>>
>>
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Gerhard Petracek [mailto:[email protected]]
>> Gesendet: Montag, 26. April 2010 17:49
>> An: MyFaces Discussion
>> Betreff: Re: ExtVal: Rendering component with visual indication for
>> required
>> fields
>>
>> hi,
>>
>> short addition:
>>
>> basically it depends on the component lib you are using.
>> e.g. myfaces trinidad supports such indicators out-of-the-box (also based
>> on
>> meta-data - e.g. in combination with extval).
>> -> extval + trinidad -> no additional effort.
>>
>> without trinidad you have to implement a small add-on for extval.
>> you can have a look at [1]. you just have to replace the trinidad specific
>> parts and you have to add the indicator on your own (depending on the
>> found
>> meta-data).
>>
>> e.g.: instead of using coreOutputLabel at:
>>  ExtValUtils.configureComponentWithMetaData(facesContext, coreOutputLabel,
>> metaDataResult);
>> you could use the targetComponent (= the input component). after this call
>> you can check if the targetComponent is required.
>> so you keep the compatibility with the required attribute of the component
>> and you can re-use the existing implementation of extval.
>>
>> if you are allowed to donate the add-on, i would commit it to os890 (after
>> reviewing it).
>>
>> regards,
>> gerhard
>>
>> [1]
>>
>> https://svn.apache.org/repos/asf/myfaces/extensions/validator/trunk/componen
>>
>> t-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/valid
>> ator/trinidad/interceptor/TrinidadRendererInterceptor.java<https://svn.apache.org/repos/asf/myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/interceptor/TrinidadRendererInterceptor.java>
>>
>> http://www.irian.at
>>
>> Your JSF powerhouse -
>> JSF Consulting, Development and
>> Courses in English and German
>>
>> Professional Support for Apache MyFaces
>>
>>
>>
>> 2010/4/26 Rudy De Busscher <[email protected]>
>>
>> > hello,
>> >
>> > The main issue with your requirement is that at the time of the
>> rendering
>> > of
>> > the outputlabel, the input text isn't treated yet (because the label is
>> > most
>> > of the time in front of the input field).  So the required property of
>> the
>> > input field isn't set yet by the extval framework. (only the information
>> of
>> > the view is applied, not the annotations on the properties of the
>> classes)
>> >
>> > You mention also the renderer interceptor.  But standard this renderer
>> is
>> > only hit for any editableValueHolder( like input fields or drop downs).
>> > Since those are the type of components we are interested in ( in doing
>> the
>> > validation).
>> > The labels aren't treated at this moment (see processComponent method in
>> > AbstractValidationInterceptor) so you should write a custom renderer
>> > interceptor to achieve it.
>> >
>> > Your requirements is already on my development list (as an add-on) for a
>> > few
>> > months now but had not the time to start with it.
>> >
>> > So you need to create (at least) the following items:
>> > - A custom renderer interceptor for handling the output labels
>> > - A component initializer that put the * in front of it (caution that it
>> > isn't done multiple times)
>> > - The component initializer should search for the referenced component
>> (by
>> > the for attribute) and do the component initialization of this
>> > EditableValueHolder.  Now the @NotNull is taken into account and the *
>> can
>> > be placed.
>> >
>> > You can also look at the Trinidad support module
>> >
>> >
>>
>> http://svn.apache.org/repos/asf/myfaces/extensions/validator/trunk/component
>> -support/trinidad-support<http://svn.apache.org/repos/asf/myfaces/extensions/validator/trunk/component-support/trinidad-support>
>> > .
>> > It has a label that is capable of putting a * behind the text so it is
>> > possible that there is already the kind of solution to your problem.
>>  You
>> > need to port it then only to the standard JSF (or use Trinidad in your
>> > project).
>> >
>> > Regards
>> > Rudy
>> >
>> > On 26 April 2010 14:57, <[email protected]> wrote:
>> >
>> > > Hi there,
>> > >
>> > > I've found some information at
>> > > http://wiki.apache.org/myfaces/Extensions/Validator/DevDoc, that it
>> is
>> > > possible to mark components who require a value via a component
>> > initializer.
>> > > In addition I would like to use bean validation and to annotate a
>> class'
>> > > attributes and mark the input field or even the label of the input
>> field:
>> > >
>> > > 1. @NotNull for an attribute let's say "name"
>> > > 2. Having an output label referencing an input field
>> > > 3. Marking all labels referencing to required fields with a '*'
>> resulting
>> > > in "*name"
>> > >
>> > > I also found the renderer interceptor which seems to be a better
>> choice
>> > for
>> > > me, since I want to manipulate the rendering of the label rather than
>> the
>> > > input component.
>> > >
>> > > Any suggestions?
>> > >
>> > > Thanks.
>> > >
>>
>>
>

Reply via email to