FileDocCategorySizeDatePackage
Label.javaAPI DocExample3404Mon Jul 23 13:26:36 BST 2007org.apache.struts2.components

Label

public class Label extends UIBean
Renders an HTML LABEL that will allow you to output label:name combination that has the same format treatment as the rest of your UI controls.

Examples

In this example, a label is rendered. The label is retrieved from a ResourceBundle via the key attribute giving you an output of 'User Name: Ford.Prefect'. Assuming that i18n message userName corresponds to 'User Name' and the action's getUserName() method returns 'Ford.Prefect'


<s:label key="userName" />


<s:label name="userName" label="User Name" />

Fields Summary
public static final String
TEMPLATE
protected String
forAttr
Constructors Summary
public Label(com.opensymphony.xwork2.util.ValueStack stack, HttpServletRequest request, HttpServletResponse response)


           
        super(stack, request, response);
    
Methods Summary
protected voidevaluateExtraParams()

        super.evaluateExtraParams();

        if (forAttr != null) {
            addParameter("for", findString(forAttr));
        }

        // try value first, then name (this overrides the default behavior in the superclass)
        if (value != null) {
            addParameter("nameValue", findString(value));
        } else if (name != null) {
            String expr = name;
            if (altSyntax()) {
                expr = "%{" + expr + "}";
            }

            addParameter("nameValue", findString(expr));
        }
    
protected java.lang.StringgetDefaultTemplate()

        return TEMPLATE;
    
public voidsetFor(java.lang.String forAttr)

        this.forAttr = forAttr;