Package org.apache.struts2.views.java

Examples of org.apache.struts2.views.java.Attributes


import java.io.IOException;

public class HeadHandler extends AbstractTagHandler implements TagGenerator {

    public void generate() throws IOException {
        Attributes attrs = new Attributes();
        attrs.put("type", "text/javascript");

        String base = ServletActionContext.getRequest().getContextPath();
        attrs.put("base", base);
       
        StringBuilder sb = new StringBuilder();
        if (base != null) {
            sb.append(base);
        }
       
        sb.append("/struts/utils.js");
        attrs.put("src", sb.toString());

        super.start("script", attrs);
        super.end("script");
    }
View Full Code Here


                //value
                Object itemValue = findValue(listValue != null ? listValue : "top");
                String itemValueStr = StringUtils.defaultString(itemValue == null ? null : itemValue.toString());

                //Checkbox button section
                Attributes a = new Attributes();
                a.add("type", "checkbox")
                  .add("name", name)
                  .add("value", itemKeyStr)
                  .addIfTrue("checked", isChecked(params, itemKeyStr))
                  .addIfTrue("readonly", params.get("readonly"))
                  .addIfTrue("disabled", disabled)
                  .addIfExists("tabindex", params.get("tabindex"))
                    .addIfExists("id", id + "-" + Integer.toString(cnt));
            start("input", a);
            end("input");

                //Label section
                a = new Attributes();
                a.add("for",id + "-" + Integer.toString(cnt))
                  .addIfExists("class", params.get("cssClass"))
                  .addIfExists("style", params.get("cssStyle"));
                super.start("label", a);
                if (StringUtils.isNotEmpty(itemValueStr))
                    characters(itemValueStr);
                super.end("label");

                //Hidden input section
                a = new Attributes();
                a.add("type", "hidden")
                        .add("id", "__multiselect_" + StringUtils.defaultString(StringEscapeUtils.escapeHtml4(id)))
                        .add("name", "__multiselect_" + StringUtils.defaultString(StringEscapeUtils.escapeHtml4(name)))
                        .add("value", "")
                        .addIfTrue("disabled", disabled);
                start("input", a);
View Full Code Here

        end("span");
        end("li");
    }

    private void startUL(Map<String, Object> params) throws IOException {
        Attributes attrs = new Attributes();
        attrs.addIfExists("style", params.get("cssStyle"))
                .add("class", params.containsKey("cssClass") ? (String) params.get("cssClass") : "errorMessage");
        start("ul", attrs);
    }
View Full Code Here

import java.util.Map;

public class SelectHandler extends AbstractTagHandler implements TagGenerator {
    public void generate() throws IOException {
        Map<String, Object> params = context.getParameters();
        Attributes a = new Attributes();

        Object value = params.get("nameValue");

        a.addDefaultToEmpty("name", params.get("name"))
                .addIfExists("size", params.get("size"))
                .addIfExists("value", value)
                .addIfTrue("disabled", params.get("disabled"))
                .addIfTrue("readonly", params.get("readonly"))
                .addIfTrue("multiple", params.get("multiple"))
View Full Code Here

        super.end("select");
    }

    private void writeOption(String value, String text, boolean selected) throws IOException {
        Attributes attrs = new Attributes();
        attrs.addIfExists("value", value)
                .addIfTrue("selected", selected);

        start("option", attrs);
        characters(text);
        end("option");
View Full Code Here

        end("option");
    }

    private void writeOptionGroup(ListUIBean listUIBean, Object value) throws IOException {
        Map params = listUIBean.getParameters();
        Attributes attrs = new Attributes();
        attrs.addIfExists("label", params.get("label"))
                .addIfTrue("disabled", params.get("disabled"));
        start("optgroup", attrs);

        //options
        ValueStack stack = context.getStack();
View Full Code Here

                //value
                Object itemValue = findValue(listValue != null ? listValue : "top");
                String itemValueStr = StringUtils.defaultString(itemValue == null ? null : itemValue.toString());

                //Checkbox button section
                Attributes a = new Attributes();
                a.add("type", "checkbox")
                  .add("name", name)
                  .add("value", itemKeyStr)
                  .addIfTrue("checked", params.get("nameValue"))
                  .addIfTrue("readonly", params.get("readonly"))
                  .addIfTrue("disabled", disabled)
                  .addIfExists("tabindex", params.get("tabindex"))
                  .addIfExists("id", name + "-" + Integer.toString(cnt++));
            start("input", a);
            end("input");

                //Label section
                a = new Attributes();
                a.add("for",id)
                  .addIfExists("class", params.get("cssClass"))
                  .addIfExists("style", params.get("cssStyle"));
                super.start("label", a);
                if (StringUtils.isNotEmpty(itemValueStr))
                    characters(itemValueStr);
                super.end("label");

                //Hidden input section
                a = new Attributes();
                a.add("type", "hidden")
                        .add("id", "__multiselect_" + StringUtils.defaultString(StringEscapeUtils.escapeHtml4(id)))
                        .add("name", "__multiselect_" + StringUtils.defaultString(StringEscapeUtils.escapeHtml4(name)))
                        .add("value", "")
                        .addIfTrue("disabled", disabled);
                start("input", a);
View Full Code Here

    public static class CloseHandler extends AbstractTagHandler implements TagGenerator {
        public void generate() throws IOException {
            Map<String, Object> params = context.getParameters();

            Attributes attrs = new Attributes();

            attrs.addIfExists("name", params.get("name"))
                    .addIfExists("id", params.get("id"))
                    .addIfExists("class", params.get("cssClass"))
                    .addIfExists("style", params.get("cssStyle"))
                    .addIfExists("href", params.get("href"), false)
                    .addIfExists("title", params.get("title"))
View Full Code Here

public class HeadHandler extends AbstractTagHandler implements TagGenerator {

    public void generate() throws IOException {
        Map<String, Object> params = context.getParameters();
        Attributes attrs = new Attributes();
        attrs.put("type", "text/javascript");

        String base = ServletActionContext.getRequest().getContextPath();
        StringBuilder sb = new StringBuilder();
        if (base != null)
            sb.append(base);
        sb.append("/struts/utils.js");
        attrs.put("src", sb.toString());

        super.start("script", attrs);
        super.end("script");
    }
View Full Code Here

public class SubmitHandler extends AbstractTagHandler implements TagGenerator {

    public void generate() throws IOException {
        Map<String, Object> params = context.getParameters();
        Attributes attrs = new Attributes();

        String type = TextUtils.noNull((String) params.get("type"), "input");

        if ("button".equals(type)) {
            attrs.addIfExists("name", params.get("name"))
                    .add("type", "submit")
                    .addIfExists("value", params.get("nameValue"), false)
                    .addIfTrue("disabled", params.get("disabled"))
                    .addIfExists("tabindex", params.get("tabindex"))
                    .addIfExists("id", params.get("id"))
                    .addIfExists("class", params.get("cssClass"))
                    .addIfExists("style", params.get("cssStyle"));

            start("button", attrs);
        } else if ("image".equals(type)) {
            attrs.addIfExists("src", params.get("src"), false)
                    .add("type", "image")
                    .addIfExists("alt", params.get("label"));

            start("input", attrs);
        } else {
            attrs.addIfExists("name", params.get("name"))
                    .add("type", "submit")
                    .addIfExists("value", params.get("nameValue"), false)
                    .addIfTrue("disabled", params.get("disabled"))
                    .addIfExists("tabindex", params.get("tabindex"))
                    .addIfExists("id", params.get("id"))
View Full Code Here

TOP

Related Classes of org.apache.struts2.views.java.Attributes

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.