hi rudy, it's great to hear that you added additional features to the add-on.
+1 for creating a short tutorial as soon as the patch is committed. regards, gerhard http://www.irian.at Your JSF powerhouse - JSF Consulting, Development and Courses in English and German Professional Support for Apache MyFaces 2010/6/15 Rudy De Busscher <rdebussc...@gmail.com> > Hi all, > > A few weeks ago, a first version of the Required label add-on was > committed. It was able to place an asterisk in front of a label that was > 'attached' to a required field > > (by his for attribute), based on the extval/BeanVal annotations it found. > > The Required label add-on was something that I always wanted, so I had the > specs for a more advanced version already prepared. Now I took the > opportunity to extend the > > initial version to a completely customizable one. First the plain extval > version was taken (not the BV one, although code could also be integrated > there) > > Due to the fact that I encountered a few problems (see further on), it took > me a bit more time but everything works now. > > These are the functionalities (when label is 'attached' to a required > field): > - By default, it places an asterisk in front of the label > - By default, it adds the css-class 'ExtValRequiredLabel' to the label > - the marker can be customized by the web.xml parameter > at.gp.web.jsf.extval.label.REQUIRED_MARKER > example > <context-param> > <param-name>at.gp.web.jsf.extval.label.REQUIRED_MARKER</param-name> > <param-value>X </param-value> > </context-param> > - The location of the marker can be customized by the web.xml parameter > at.gp.web.jsf.extval.label.PLACE_MARKER > Allowed values are BEFORE, BEFORE_COLON and AFTER. > - works with EL expressions and also as literal values in the value > property as text for the label. > - Marker isn't placed when at the requested location, marker is already > present. > - The used css-class (instead of ExtValRequiredLabel) can be customized by > the web.xml parameter at.gp.web.jsf.extval.label.REQUIRED_CLASS > - All these functionalities are implemented in > DefaultRequiredLabelInitializer class. And as in a good ExtVal tradition, > users can replace it by their own implementation. > > They must implement the interface RequiredLabelInitializer and specify the > full class name by the parameter > at.gp.web.jsf.extval.label.REQUIRED_LABEL_INITIALIZER. > > > Some remarks > - If one is only interested in the css way and no marker is required, > following value can be specified > <context-param> > <param-name>at.gp.web.jsf.extval.label.REQUIRED_MARKER</param-name> > <param-value></param-value> > </context-param> > - It is possible to specify HTML in the required marker (like the asterisk > is placed in red). Automatically the escape property of the label is set to > false. (be aware that > > if the original label text contained already HTML or XML, it is no longer > encoded and thus strange effects could occur) > - When you specify BEFORE_COLON and there is no : found in the literal text > or literal part of the EL, the AFTER functionality is used. > So a good usage of resource bundle is <h:outputLabel > value="#{msg['key.field.label']} :" for="label" /> > - By adding the css class, the EL that could be present is evaluated at > that time. For the rest of the lifecycle (and possible subsequent ones if > caching of facelets > > occurs) the css class is a literal value and no changes could be picked up > from referenced sources. > > > So what where the problems: > - The escape property of the OutputLabel isn't taken into account during > rendering. (MYFACES-2751). This will be fixed in version 1.2.10. If one > uses an older version and > > want to use the HTML style of the required marker, one needs to add the > EscapeHtmlLabelRenderer (included in the add-on) as used renderer in the > faces-config file. > - On the otherhand the creation of tests where a problem since > MockValueExpression doesn't allow a mixture of literal and references in the > EL. Therefore a > > CompositeMockValueExpression was created (see package > at.gp.web.jsf.extval.composite.mock) that can handle constructs like > "#{msg['key.field.label']} :". I'll open a JIRA > > issue so that we can add them to Myfaces Test (and later on when ExtVal > will be using Myfaces-test, I shall add it to base-test-infrastructure > subproject. > > > I'll prepare a little tutorial where the above functionalities are > explained in more detail. > > Have fun with it. > > Regards > Rudy. > >