You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Matt Raible (JIRA)" <de...@tapestry.apache.org> on 2007/09/13 22:58:32 UTC
[jira] Updated: (TAPESTRY-975) Overriding ValidationDelegate and
adding a "class" attribute results in duplicate attributes
[ https://issues.apache.org/jira/browse/TAPESTRY-975?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Matt Raible updated TAPESTRY-975:
---------------------------------
Attachment: ValidationDelegate.java
It seems that having a "class" attribute causes writer.attribute and writer.appendAttribute to not work. Here's my Tapestry code:
<li>
<label class="desc" jwcid="@FieldLabel" field="component:usernameField">Username</label>
<input jwcid="usernameField" type="text" id="username" class="text large"/>
</li>
This produces the following when there's an error (notice no new classes in the "class" attribute):
<li>
<label for="username" class="desc">Username<span class="req"> *</span></label>
<span class="fieldError"><img src="/images/iconWarning.gif" class="validationWarning" alt="Warning"></img> You must enter a value for Username.</span><input type="text" name="username" value="" id="username" class="text large" />
</li>
The extra HTML is because I've overridden the "writePrefix" method.
If I remove the "class" attributes of <label> and <input>, it seems to work properly:
<li>
<label jwcid="@FieldLabel" field="component:usernameField">Username</label>
<input jwcid="usernameField" type="text" id="username"/>
</li>
Produces the following when there's an error:
<li>
<label for="username" class="error">Username<span class="req"> *</span></label>
<span class="fieldError"><img src="/images/iconWarning.gif" class="validationWarning" alt="Warning"></img> You must enter a value for Username.</span><input type="text" name="username" value="" id="username" class="fieldMissing" />
</li>
I've attached my ValidationDelegate.java class.
> Overriding ValidationDelegate and adding a "class" attribute results in duplicate attributes
> --------------------------------------------------------------------------------------------
>
> Key: TAPESTRY-975
> URL: https://issues.apache.org/jira/browse/TAPESTRY-975
> Project: Tapestry
> Issue Type: New Feature
> Components: Framework
> Affects Versions: 4.0.2
> Reporter: Matt Raible
> Assignee: Jesse Kuhnert
> Fix For: 4.1.1
>
> Attachments: ValidationDelegate.java
>
>
> I have the following in my custom ValidationDelegate:
> public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle,
> IFormComponent component, IValidator validator) {
> if (isInError()) {
> String cssClass = ((component.getBinding("class") != null) ?
> component.getBinding("class").getObject().toString() : "");
> writer.attribute("class", cssClass + " error");
> }
> }
> However, rather than just writing a single "class" attribute, it writes two:
> class="text large error" class="text large"
> Ideally, only one "class" attribute gets written. Maybe IMarkupWriter nees an appendAttribute() method, or it just needs to be smart enough to detect duplicates?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org