FileDocCategorySizeDatePackage
FormButton.javaAPI DocExample5653Mon Jul 23 13:26:36 BST 2007org.apache.struts2.components

FormButton

public abstract class FormButton extends UIBean
FormButton.

Fields Summary
static final String
BUTTONTYPE_INPUT
static final String
BUTTONTYPE_BUTTON
static final String
BUTTONTYPE_IMAGE
protected String
action
protected String
method
protected String
align
protected String
type
Constructors Summary
public FormButton(com.opensymphony.xwork2.util.ValueStack stack, HttpServletRequest request, HttpServletResponse response)


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

        super.evaluateExtraParams();
        if (align == null) {
            align = "right";
        }

        String submitType = BUTTONTYPE_INPUT;
        if (type != null && (BUTTONTYPE_BUTTON.equalsIgnoreCase(type) || (supportsImageType() && BUTTONTYPE_IMAGE.equalsIgnoreCase(type))))
        {
            submitType = type;
        }

        //super.evaluateParams();

        addParameter("type", submitType);

        if (!BUTTONTYPE_INPUT.equals(submitType) && (label == null)) {
            addParameter("label", getParameters().get("nameValue"));
        }

        if (action != null || method != null) {
            String name;

            if (action != null) {
                name = "action:" + findString(action);

                if (method != null) {
                    name += "!" + findString(method);
                }
            } else {
                name = "method:" + findString(method);
            }

            addParameter("name", name);
        }

        addParameter("align", findString(align));

    
protected voidpopulateComponentHtmlId(Form form)
Override UIBean's implementation, such that component Html id is determined in the following order :-
  1. This component id attribute
  2. [containing_form_id]_[this_component_name]
  3. [containing_form_id]_[this_component_action]_[this_component_method]
  4. [containing_form_id]_[this_component_method]
  5. [this_component_name]
  6. [this_component_action]_[this_component_method]
  7. [this_component_method]
  8. [an increasing sequential number unique to the form starting with 0]

        String _tmp_id = "";
        if (id != null) {
            // this check is needed for backwards compatibility with 2.1.x
            if (altSyntax()) {
                _tmp_id = findString(id);
            } else {
                _tmp_id = id;
            }
        }
        else {
            if (form != null && form.getParameters().get("id") != null) {
                _tmp_id = _tmp_id + form.getParameters().get("id").toString() + "_";
            }
            if (name != null) {
                _tmp_id = _tmp_id + escape(name);
            } else if (action != null || method != null){
                if (action != null) {
                    _tmp_id = _tmp_id + escape(action);
                }
                if (method != null) {
                    _tmp_id = _tmp_id + "_" + escape(method);
                }
            } else {
                // if form is null, this component is used, without a form, i guess
                // there's not much we could do then.
                if (form != null) {
                    _tmp_id = _tmp_id + form.getSequence();
                }
            }
        }
        addParameter("id", _tmp_id);
    
public voidsetAction(java.lang.String action)

        this.action = action;
    
public voidsetAlign(java.lang.String align)

        this.align = align;
    
public voidsetMethod(java.lang.String method)

        this.method = method;
    
public voidsetType(java.lang.String type)

        this.type = type;
    
protected abstract booleansupportsImageType()
Indicate whether the concrete button supports the type "image".

return
true if type image is supported.