You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (Commented) (JIRA)" <ji...@apache.org> on 2012/04/18 15:07:44 UTC
[jira] [Commented] (WW-3144) Label tag doesn't use "key" attribute
properly
[ https://issues.apache.org/jira/browse/WW-3144?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13256528#comment-13256528 ]
Lukasz Lenart commented on WW-3144:
-----------------------------------
I'm not sure if I understood the problem right, but IMHO label tag shouldn't be wrapped with additional label for xhtml and css_xhtml theme - then there is a label for label :P
Anyway, with simple theme, I've done something like this:
{code:java}
protected void evaluateExtraParams() {
super.evaluateExtraParams();
// try value, then key, then name (this overrides the default behavior in the superclass)
if (value != null) {
addParameter("nameValue", findString(value));
} else if (key != null) {
Object nameValue = parameters.get("nameValue");
if (nameValue == null || nameValue.toString().length() == 0) {
// get the label from a TextProvider (default value is the key)
String providedLabel = TextProviderHelper.getText(key, key, stack);
addParameter("nameValue", providedLabel);
}
} else if (name != null) {
String expr = completeExpressionIfAltSyntax(name);
addParameter("nameValue", findString(expr));
}
if (forAttr != null) {
addParameter("for", findString(forAttr));
} else {
addParameter("for", getParameters().get("nameValue"));
}
}
{code}
and now the result is like this:
{code:html}
<label id="labelKey" for="baz">baz</label>
{code}
The id attribute wasn't translated which is ok, label should have a different Id than the "for" element of label, eg.:
{code:html}
<label id="labelKey" for="baz">baz</label><input id="baz" value="foo"/>
{code}
is it ok ?
> Label tag doesn't use "key" attribute properly
> ----------------------------------------------
>
> Key: WW-3144
> URL: https://issues.apache.org/jira/browse/WW-3144
> Project: Struts 2
> Issue Type: Bug
> Affects Versions: 2.1.6
> Reporter: Dave Newton
> Assignee: Lukasz Lenart
> Priority: Minor
> Fix For: 2.3.4
>
>
> <s:label name="foo"/> works
> <s:label name="foo" label="%{getText('foo')}"/> works
> <s:label key="foo"/> puts the foo msg into the not-label label.
> Positively labelous.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira