I believe that at some point in your quest you are going to learn that Struts2 tags delegate to a component (which you'll have to extend/use). So a few questions (if overriding the label setter doesn't work).

- Are you using the "key" attribute on the tag (it's used to generate the label).
- Are you using the "label" and "key" combined?

From the Struts2 source code (UIBean)

public void evaluateParams() {
    addParameter("templateDir", getTemplateDir());
    addParameter("theme", getTheme());
    addParameter("dynamicAttributes", dynamicAttributes);

    String name = null;
    String providedLabel = null;

    if (this.key != null) {

        if(this.name == null) {
            this.name = key;
        }

        if(this.label == null) {
// lookup the label from a TextProvider (default value is the key)
            providedLabel = TextProviderHelper.getText(key, key, stack);
        }

    }

    if (this.name != null) {
        name = findString(this.name);
        addParameter("name", name);
    }

    if (label != null) {
        addParameter("label", findString(label));
    } else {
        if (providedLabel != null) {
            // label found via a TextProvider
            addParameter("label", providedLabel);
        }
    }
....
}

So as you can see, the label (if not null, is expected to be resolved by the findString() method. Please take a look at the source code for further info. I have been overriding my messages (using the key) successfully (and not using labels).

Hope this helps!


Narayana S wrote:
Hi,

      i have a requirement of extending the struts 2 control tags like text
field, check box, select. i want to add a new attribute to the component,
which will allows to identify certain properties like visibility,
editability, label text from the database and render the component.

 to implement this for text field i have created a class that extends
"org.apache.struts2.views.jsp.ui.TextFieldTag", from here i am trying to
assign label for the text field as "super.setLabel("Employee Number");". but
it is not rendering the label. can any one suggest me the correct process to
do this?

Thanks in advance


--
--
Alberto
http://www.linkedin.com/in/aflores

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to