Package org.apache.struts2.views.java

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


public class AnchorHandler 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 TokenHandler extends AbstractTagHandler implements TagGenerator {

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

        //first input
        attrs.add("type", "hidden")
                .addDefaultToEmpty("name", params.get("tokenNameField"), false)
                .addDefaultToEmpty("value", params.get("name"));

        start("input", attrs);
        end("input");

        //second input
        attrs = new Attributes();
        attrs.add("type", "hidden")
                .addDefaultToEmpty("name", params.get("name"), false)
                .addDefaultToEmpty("value", params.get("token"));

        start("input", attrs);
        end("input");
View Full Code Here

public class LabelHandler extends AbstractTagHandler implements TagGenerator {

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

        a.addDefaultToEmpty("name", params.get("name"))
                .addIfExists("for", params.get("for"))
                .addIfExists("id", params.get("id"))
                .addIfExists("class", params.get("cssClass"))
                .addIfExists("style", params.get("cssStyle"))
                .addIfExists("title", params.get("title"));
View Full Code Here

        if (errorsObj != null) {
            Iterator itt = MakeIterator.convert(errorsObj);
            if (itt.hasNext()) {
                boolean escape = BooleanUtils.toBooleanDefaultIfNull((Boolean) params.get("escape"), false);
                Attributes attrs = new Attributes();
                attrs.addIfExists("style", params.get("cssStyle"))
                        .add("class", params.containsKey("cssClass") ? (String) params.get("cssClass") : getDefaultClass());
                start("ul", attrs);
                while (itt.hasNext()) {
                    String error = (String) itt.next();
View Full Code Here

                        .defaultString(itemValue == null ? null : itemValue
                                .toString());

                // Radio button section
                String id = params.get("id") + Integer.toString(cnt++);
                Attributes a = new Attributes();
                a.add("type", "radio")
                        .addDefaultToEmpty("name", params.get("name"))
                        .addIfTrue("checked", isChecked(params, itemKeyStr))
                        .addIfExists("value", itemKeyStr)
                        .addIfTrue("disabled", params.get("disabled"))
                        .addIfExists("tabindex", params.get("tabindex"))
                        .addIfExists("id", id);
                super.start("input", a);
                super.end("input");

                // Label section
                a = new Attributes();
                a.addIfExists("for", id)
                        .addIfExists("class", params.get("cssClass"))
                        .addIfExists("style", params.get("cssStyle"))
                        .addIfExists("title", params.get("title"));
                super.start("label", a);
                if (StringUtils.isNotEmpty(itemValueStr)) {
View Full Code Here

                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_"
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 = StringUtils.defaultString((String) params.get("type"), "input");

        if ("button".equals(type)) {
            attrs.addIfExists("name", params.get("name"))
                    .add("type", "submit")
                    .addIfExists("value", params.get("nameValue"))
                    .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"))
                    .add("type", "image")
                    .addIfExists("name", params.get("name"))
                    .addIfExists("alt", params.get("label"))
                    .addIfExists("id", params.get("id"))
                    .addIfExists("class", params.get("cssClass"))
                    .addIfExists("style", params.get("cssStyle"));
            start("input", attrs);
        } else {
            attrs.addIfExists("name", params.get("name"))
                    .add("type", "submit")
                    .addIfExists("value", params.get("nameValue"))
                    .addIfTrue("disabled", params.get("disabled"))
                    .addIfExists("tabindex", params.get("tabindex"))
                    .addIfExists("id", params.get("id"))
View Full Code Here

public class DateTextFieldHandler extends AbstractTagHandler implements TagGenerator {

    @SuppressWarnings("unchecked")
  public void generate() throws IOException {
        Map<String, Object> params = context.getParameters();
        Attributes attr = null;

        // Get format
        String format = (String)params.get("format");
        String id = (String)params.get("id");
        String name = (String)params.get("name");
        if (id == null) {
          id = name;
        }
        Date date = (Date)params.get("nameValue");
       
        if (format != null) {
          // Verify if it's correct
            new SimpleDateFormat(format);
           
            attr = new Attributes();
            attr.addIfExists("id", id);
            super.start("div", attr);
           
            Character antC = null;
            for (Character c : format.toCharArray()) {
             
              try {
                DateWord dateWord = DateWord.get(c);
                if (!c.equals(antC)) {
                 
                  String cssClass = "date_" + dateWord.getDescription();
                  if (params.get("cssClass") != null) {
                    cssClass += " " + params.get("cssClass");
                  }
                 
                  attr = new Attributes();
                      attr.add("type", "text")
                              .addIfExists("class", cssClass)
                              .addIfExists("size", dateWord.getLength())
                              .addIfExists("maxlength", dateWord.getLength())
                              .addIfTrue("disabled", params.get("disabled"))
                              .addIfTrue("readonly", params.get("readonly"))
                              .addIfExists("tabindex", params.get("tabindex"))
                              .addIfExists("style", params.get("cssStyle"))
                              .addIfExists("title", params.get("title"));
                     
                      if (id != null && !"".equals(id)) {
                          attr.addDefaultToEmpty("id", "__" + dateWord.getDescription() + "_" + id);
                      }
                      if (name != null && !"".equals(id)) {
                          attr.addDefaultToEmpty("name", "__" + dateWord.getDescription() + "_" + name);
                      } else {
                          attr.addDefaultToEmpty("name", dateWord.getDescription());
                      }
                      if (date != null) {
                        SimpleDateFormat formatter = new SimpleDateFormat(dateWord.getDateType());
                        attr.addIfExists("value", formatter.format(date), false);
                      }
                     
                      super.start("input", attr);
                      super.end("input");
                     
View Full Code Here

                //the action is equal to the current key value.
                Boolean checked = itemKeyStr != null && itemNameValueStr != null && itemNameValueStr.equals(itemKeyStr);

                //Radio button section
                String id = params.get("id") + Integer.toString(cnt++);
                Attributes a = new Attributes();
                a.add("type", "radio")
                        .addDefaultToEmpty("name", params.get("name"))
                        .addIfTrue("checked", checked)
                        .addIfExists("value", itemKeyStr)
                        .addIfTrue("disabled", params.get("disabled"))
                        .addIfExists("tabindex", params.get("tabindex"))
                        .addIfExists("id", id);
                super.start("input", a);
                super.end("input");

                //Label section
                a = new Attributes();
                a.addIfExists("for", id)
                        .addIfExists("class", params.get("cssClass"))
                        .addIfExists("style", params.get("cssStyle"))
                        .addIfExists("title", params.get("title"));
                super.start("label", a);
                if (StringUtils.isNotEmpty(itemValueStr)) {
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

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.