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/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
> .
> 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.
> >
> > Traumziele - von Beschreibung bis Buchung jetzt kompakt auf den
> > Reise-Seiten von Arcor.de! http://www.arcor.de/rd/footer.reise
> >
>

Reply via email to