You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Ariel Pablo Klein <ap...@eml.cc> on 2005/03/27 21:55:37 UTC
Proposal or Discussion: FieldLabel changes
Hi, I'm new on this list, I subscribed yesterday, but the reason that I
subscribed it's to propose some changes in form components if are voted or
can be discussed by us.
My English isn't so good, but I think that you can understand me.
Googling I found this demo:
http://www.sitepoint.com/examples/simpletricks/form-demo.html
Based on an article called "Simple Tricks for More Usable Forms".
http://www.sitepoint.com/print/1273
first that I made to achieve this example on tapestry was:
1. I made on a copy of FieldLabel, it's to change the renderComponent
adjusting it to render <label> tag. I know that can be done on
validatedelegate labelprefix, but I think that this code has to be part of
fieldLabel component making it customizable by CSS like in the demo, and
associating FieldLabel to <Label> tag of HTML 4.
http://www.w3.org/TR/REC-html40/interact/forms.html
2. I made visible isInError(IFormComponent component) on my own
ValidateDelegate because on ValidationDelegate is protected and isn't
visible by fieldlabel to know if a field has errors or not.
3. at this moment I made my own script file to achieve javascript
validation, but could be done by standardizing in all form components.
The code as you can imagine it's very simple:
writer.begin("label");
writer.attribute("for", field.getId());
MyValidationDelegate myDelegate = ((MyValidationDelegate) delegate);
if (myDelegate.isInError(field)) {
writer.attribute("class", "problem");
} else {
IValidator validator = myDelegate.getValidator(field);
if (validator != null && validator.isRequired())
writer.attribute("class", "required");
else
writer.attribute("class", "completed");
}
if (getRaw()) {
writer.printRaw(displayName);
} else {
writer.print(displayName);
}
writer.end();
Maybe more things can be modified. But this could be the start of discussion
about this.
Maybe in a near future validators could services too (sounds crazy :D) and
forms could be validated thru live validators.
Ariel Pablo Klein
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org