Sighhhhhhhhhhh.......It's right there in the page I tried to show you...
/**
* Adds a class style attribute to the label if in error
* [EMAIL PROTECTED]
*/
public void writeLabelAttributes(IMarkupWriter writer, IRequestCycle
cycle, IFormComponent component) {
if (isInError(component))
{
writer.attribute("class", "labelError");
}
}
On 3/30/06, Matt Raible <[EMAIL PROTECTED]> wrote:
>
> Sorry for being dense, but my problem seems to be with the following:
>
> public void writeLabelPrefix(IFormComponent component,
> IMarkupWriter writer, IRequestCycle
> cycle) {
> writer.begin("label");
>
> if (isInError(component)) {
> writer.attribute("class", "error");
> } else {
> writer.attribute("class", "required");
> }
>
> writer.print(" * ");
> }
>
> Ideally, I don't want to have to write write writer.begin("label"),
> because I don't want two labels. I just want to hook into the one
> that Tapestry wraps around @FieldLabel. With 3.0.3, it didn't do
> this. In fact, nothing was written around a field label. With 4.0, I
> end up with:
>
> <label class="required"> * <label for="username">Username</label>:</label>
>
> Sure I could use some css (label label { font-style: bold }), but I'd
> rather have:
>
> <label class="required" for="username"> * Username:</label>
>
> Is that possible? Does anyone have a ValidationDelegate like the one
> from Tapestry in Action that works with 4.0? Sorry if I'm asking a
> dumb question and the answer is too simple for me to see. ;-)
>
> Matt
>
> On 3/30/06, Jesse Kuhnert <[EMAIL PROTECTED]> wrote:
> > http://jakarta.apache.org/tapestry/UsersGuide/validation.html
> >
> > :(
> >
> >
> > On 3/30/06, Matt Raible <[EMAIL PROTECTED]> wrote:
> > > Is it possible to hook into the <label> that tapestry writes? Or is
> > > this what's in the Tacos example? I'd rather add class="required" to
> > > the FieldLabel component rather than adding <span class="required">
> > > around a <label>.
> > >
> > > Matt
> > >
> > > On 3/30/06, Matt Raible <[EMAIL PROTECTED]> wrote:
> > > > Thanks - that appears to work. However, now I've discovered that
> > > > validation doesn't work at all. In Tapestry 3.0.3, I was using a
> > > > custom ValidationDelegate that I found in Tapestry in Action.
> > > > Unfortunately, it doesn't seem to work in Tapestry 4. I'm setting
> it
> > > > in my page-specification using:
> > > >
> > > > <bean name="delegate" class="
> > org.appfuse.webapp.action.Validator"/>
> > > >
> > > > Is there a different way to set this in 4.0?
> > > >
> > > > The other problem I have with this Validator in 4.0 is there's now a
> > > > nested <label> inside the <label> I'm writing. Is it possible to
> set
> > > > the "required" class on the <label> that Tapestry writes?
> > > >
> > > > public class Validator extends ValidationDelegate {
> > > > private static final long serialVersionUID =
> 6658594142293597652L;
> > > >
> > > > public void writeLabelPrefix(IFormComponent component,
> > > > IMarkupWriter writer,
> > IRequestCycle cycle) {
> > > > writer.begin("label");
> > > >
> > > > if (isInError(component)) {
> > > > writer.attribute("class", "error");
> > > > } else {
> > > > writer.attribute("class", "required");
> > > > }
> > > >
> > > > writer.print(" * ");
> > > > }
> > > >
> > > > public void writeLabelSuffix(IFormComponent component,
> > > > IMarkupWriter writer,
> > IRequestCycle cycle) {
> > > > Locale locale = cycle.getEngine().getLocale();
> > > > String marker = (locale.equals(Locale.FRENCH)) ? " :" : ":";
> > > > writer.print(marker);
> > > > writer.end ();
> > > > }
> > > >
> > > > public void writeAttributes(IMarkupWriter writer, IRequestCycle
> > cycle,
> > > > IFormComponent
> > component, IValidator
> > > > validator) {
> > > > if (isInError()) {
> > > > writer.attribute("class", "error");
> > > > }
> > > > }
> > > >
> > > > public void writeSuffix(IMarkupWriter writer, IRequestCycle
> cycle,
> > > > IFormComponent component, IValidator
> > validator) {
> > > > if (isInError(component)) {
> > > > writer.printRaw(" ");
> > > > writer.begin("img");
> > > >
> > > > String ctxPath = cycle.getInfrastructure
> > ().getContextPath();
> > > > writer.attribute("src", ctxPath +
> > "/images/iconWarning.gif");
> > > > writer.attribute("class", "validationWarning");
> > > > writer.attribute("alt",
> > > > cycle.getPage().getMessages().getMessage("icon.warning"));
> > > > writer.end();
> > > >
> > > > writer.printRaw(" ");
> > > >
> > > > IFieldTracking tracking = getComponentTracking();
> > > > IRender render = tracking.getErrorRenderer();
> > > > String error = "";
> > > >
> > > > if (render instanceof RenderString) {
> > > > error = ((RenderString) render).getString();
> > > > }
> > > >
> > > > writer.begin("span");
> > > > writer.attribute("class", "fieldError");
> > > > writer.printRaw(error);
> > > > writer.end();
> > > > }
> > > > }
> > > > }
> > > >
> > > > Thanks,
> > > >
> > > > Matt
> > > >
> > > >
> > > >
> > > > On 3/30/06, Mike Snare < [EMAIL PROTECTED]> wrote:
> > > > > try replacing
> > > > >
> > > > > value="\\d{5}(-\\d{4})?"
> > > > >
> > > > > with
> > > > >
> > > > > value="literal:\\d{5}(-\\d{4})?"
> > > > >
> > > > > See if that works.
> > > > >
> > > > > -Mike
> > > > >
> > > > > On 3/30/06, Matt Raible <[EMAIL PROTECTED]> wrote:
> > > > > > This worked in 3.0.3:
> > > > > >
> > > > > > <bean name="zipValidator"
> > > > > > class="org.apache.tapestry.valid.PatternValidator">
> > > > > > <set name="patternString" value="\\d{5}(-\\d{4})?"/>
> > > > > > <set name="required" value="true"/>
> > > > > > <set name="patternNotMatchedMessage"
> > value="message:errors.zip"/>
> > > > > > <set name="clientScriptingEnabled" value="true"/>
> > > > > > </bean>
> > > > > >
> > > > > > But this doesn't work in 4.0:
> > > > > >
> > > > > > Unable to read OGNL expression '<parsed OGNL expression>' of
> > > > > > [EMAIL PROTECTED]: Error initializing property
> > > > > > patternString of bean 'zipValidator' (of component signup):
> Unable
> > to
> > > > > > parse OGNL expression '\\d{5}(-\\d{4})?': Malformed OGNL
> expression:
> > > > > > \\d{5}(-\\d{4})?
> > > > > >
> > > > > > Any idea how to fix this? How did the regular expression syntax
> > change?
> > > > > >
> > > > > > Thanks,
> > > > > >
> > > > > > Matt
> > > > > >
> > > > > >
> > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > > > > > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> > >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > >
> > >
> >
> >
> >
> > --
> >
> > Jesse Kuhnert
> > Tacos/Tapestry, team member/developer
> >
> > Open source based consulting work centered around
> > dojo/tapestry/tacos/hivemind. http://opennotion.com
>
--
Jesse Kuhnert
Tacos/Tapestry, team member/developer
Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://opennotion.com