コード例 #1
0
ファイル: UpDownSelect.java プロジェクト: ChenLinXi/struts
  public void evaluateParams() {
    super.evaluateParams();

    // override Select's default
    if (StringUtils.isBlank(size)) {
      addParameter("size", "5");
    }
    if (StringUtils.isBlank(multiple)) {
      addParameter("multiple", Boolean.TRUE);
    }

    if (allowMoveUp != null) {
      addParameter("allowMoveUp", findValue(allowMoveUp, Boolean.class));
    }
    if (allowMoveDown != null) {
      addParameter("allowMoveDown", findValue(allowMoveDown, Boolean.class));
    }
    if (allowSelectAll != null) {
      addParameter("allowSelectAll", findValue(allowSelectAll, Boolean.class));
    }

    if (moveUpLabel != null) {
      addParameter("moveUpLabel", findString(moveUpLabel));
    }
    if (moveDownLabel != null) {
      addParameter("moveDownLabel", findString(moveDownLabel));
    }
    if (selectAllLabel != null) {
      addParameter("selectAllLabel", findString(selectAllLabel));
    }

    // inform our form ancestor about this UpDownSelect so the form knows how to
    // auto select all options upon it submission
    Form ancestorForm = (Form) findAncestor(Form.class);
    if (ancestorForm != null) {

      // inform form ancestor that we are using a custom onSubmit
      enableAncestorFormCustomOnsubmit();

      Map m = (Map) ancestorForm.getParameters().get("updownselectIds");
      if (m == null) {
        // map with key -> id ,  value -> headerKey
        m = new LinkedHashMap();
      }
      m.put(getParameters().get("id"), getParameters().get("headerKey"));
      ancestorForm.getParameters().put("updownselectIds", m);
    } else {
      if (LOG.isWarnEnabled()) {
        LOG.warn(
            "no ancestor form found for updownselect "
                + this
                + ", therefore autoselect of all elements upon form submission will not work ");
      }
    }
  }
コード例 #2
0
ファイル: UIBean.java プロジェクト: angelowolf/SEW
 /**
  * Create HTML id element for the component and populate this component parameter map.
  * Additionally, a parameter named escapedId is populated which contains the found id value
  * filtered by {@link #escape(String)}, needed eg. for naming Javascript identifiers based on the
  * id value.
  *
  * <p>The order is as follows :-
  *
  * <ol>
  *   <li>This component id attribute
  *   <li>[containing_form_id]_[this_component_name]
  *   <li>[this_component_name]
  * </ol>
  *
  * @param form enclosing form tag
  */
 protected void populateComponentHtmlId(Form form) {
   String tryId;
   String generatedId;
   if (id != null) {
     // this check is needed for backwards compatibility with 2.1.x
     tryId = findStringIfAltSyntax(id);
   } else if (null == (generatedId = escape(name != null ? findString(name) : null))) {
     if (LOG.isDebugEnabled()) {
       LOG.debug(
           "Cannot determine id attribute for [#0], consider defining id, name or key attribute!",
           this);
     }
     tryId = null;
   } else if (form != null) {
     tryId = form.getParameters().get("id") + "_" + generatedId;
   } else {
     tryId = generatedId;
   }
   addParameter("id", tryId);
   addParameter("escapedId", escape(tryId));
 }
コード例 #3
0
ファイル: UIBean.java プロジェクト: angelowolf/SEW
  public void evaluateParams() {
    String templateDir = getTemplateDir();
    String theme = getTheme();

    addParameter("templateDir", templateDir);
    addParameter("theme", theme);
    addParameter("template", template != null ? findString(template) : getDefaultTemplate());
    addParameter("dynamicAttributes", dynamicAttributes);
    addParameter("themeExpansionToken", uiThemeExpansionToken);
    addParameter("expandTheme", uiThemeExpansionToken + theme);

    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);
      }
    }

    if (labelSeparator != null) {
      addParameter("labelseparator", findString(labelSeparator));
    }

    if (labelPosition != null) {
      addParameter("labelposition", findString(labelPosition));
    }

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

    if (errorPosition != null) {
      addParameter("errorposition", findString(errorPosition));
    }

    if (requiredLabel != null) {
      addParameter("required", findValue(requiredLabel, Boolean.class));
    }

    if (disabled != null) {
      addParameter("disabled", findValue(disabled, Boolean.class));
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    // see if the value was specified as a parameter already
    if (parameters.containsKey("value")) {
      parameters.put("nameValue", parameters.get("value"));
    } else {
      if (evaluateNameValue()) {
        final Class valueClazz = getValueClassType();

        if (valueClazz != null) {
          if (value != null) {
            addParameter("nameValue", findValue(value, valueClazz));
          } else if (name != null) {
            String expr = completeExpressionIfAltSyntax(name);

            addParameter("nameValue", findValue(expr, valueClazz));
          }
        } else {
          if (value != null) {
            addParameter("nameValue", findValue(value));
          } else if (name != null) {
            addParameter("nameValue", findValue(name));
          }
        }
      }
    }

    final Form form = (Form) findAncestor(Form.class);

    // create HTML id element
    populateComponentHtmlId(form);

    if (form != null) {
      addParameter("form", form.getParameters());

      if (name != null) {
        // list should have been created by the form component
        List<String> tags = (List<String>) form.getParameters().get("tagNames");
        tags.add(name);
      }
    }

    // tooltip & tooltipConfig
    if (tooltipConfig != null) {
      addParameter("tooltipConfig", findValue(tooltipConfig));
    }
    if (tooltip != null) {
      addParameter("tooltip", findString(tooltip));

      Map tooltipConfigMap = getTooltipConfig(this);

      if (form != null) { // inform the containing form that we need tooltip javascript included
        form.addParameter("hasTooltip", Boolean.TRUE);

        // tooltipConfig defined in component itseilf will take precedence
        // over those defined in the containing form
        Map overallTooltipConfigMap = getTooltipConfig(form);
        overallTooltipConfigMap.putAll(tooltipConfigMap); // override parent form's tooltip config

        for (Object o : overallTooltipConfigMap.entrySet()) {
          Map.Entry entry = (Map.Entry) o;
          addParameter((String) entry.getKey(), entry.getValue());
        }
      } else {
        if (LOG.isWarnEnabled()) {
          LOG.warn(
              "No ancestor Form found, javascript based tooltip will not work, however standard HTML tooltip using alt and title attribute will still work ");
        }
      }

      // TODO: this is to keep backward compatibility, remove once when tooltipConfig is dropped
      String jsTooltipEnabled = (String) getParameters().get("jsTooltipEnabled");
      if (jsTooltipEnabled != null) this.javascriptTooltip = jsTooltipEnabled;

      // TODO: this is to keep backward compatibility, remove once when tooltipConfig is dropped
      String tooltipIcon = (String) getParameters().get("tooltipIcon");
      if (tooltipIcon != null) this.addParameter("tooltipIconPath", tooltipIcon);
      if (this.tooltipIconPath != null)
        this.addParameter("tooltipIconPath", findString(this.tooltipIconPath));

      // TODO: this is to keep backward compatibility, remove once when tooltipConfig is dropped
      String tooltipDelayParam = (String) getParameters().get("tooltipDelay");
      if (tooltipDelayParam != null) this.addParameter("tooltipDelay", tooltipDelayParam);
      if (this.tooltipDelay != null)
        this.addParameter("tooltipDelay", findString(this.tooltipDelay));

      if (this.javascriptTooltip != null) {
        Boolean jsTooltips = (Boolean) findValue(this.javascriptTooltip, Boolean.class);
        // TODO use a Boolean model when tooltipConfig is dropped
        this.addParameter("jsTooltipEnabled", jsTooltips.toString());

        if (form != null) form.addParameter("hasTooltip", jsTooltips);
        if (this.tooltipCssClass != null)
          this.addParameter("tooltipCssClass", findString(this.tooltipCssClass));
      }
    }

    evaluateExtraParams();
  }
コード例 #4
0
  public void evaluateExtraParams() {
    super.evaluateExtraParams();

    // Object doubleName = null;

    if (emptyOption != null) {
      addParameter("emptyOption", findValue(emptyOption, Boolean.class));
    }

    if (multiple != null) {
      addParameter("multiple", findValue(multiple, Boolean.class));
    }

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

    if ((headerKey != null) && (headerValue != null)) {
      addParameter("headerKey", findString(headerKey));
      addParameter("headerValue", findString(headerValue));
    }

    if (doubleMultiple != null) {
      addParameter("doubleMultiple", findValue(doubleMultiple, Boolean.class));
    }

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

    if (doubleDisabled != null) {
      addParameter("doubleDisabled", findValue(doubleDisabled, Boolean.class));
    }

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

    if (doubleList != null) {
      addParameter("doubleList", doubleList);
    }

    Object tmpDoubleList = findValue(doubleList);
    if (doubleListKey != null) {
      addParameter("doubleListKey", doubleListKey);
    } else if (tmpDoubleList instanceof Map) {
      addParameter("doubleListKey", "key");
    }

    if (doubleListValue != null) {
      if (altSyntax()) {
        // the same logic as with findValue(String)
        // if value start with %{ and end with }, just cut it off!
        if (doubleListValue.startsWith("%{") && doubleListValue.endsWith("}")) {
          doubleListValue = doubleListValue.substring(2, doubleListValue.length() - 1);
        }
      }

      addParameter("doubleListValue", doubleListValue);
    } else if (tmpDoubleList instanceof Map) {
      addParameter("doubleListValue", "value");
    }

    if (formName != null) {
      addParameter("formName", findString(formName));
    } else {
      // ok, let's look it up
      Component form = findAncestor(Form.class);
      if (form != null) {
        addParameter("formName", form.getParameters().get("name"));
      }
    }

    Class valueClazz = getValueClassType();

    if (valueClazz != null) {
      if (doubleValue != null) {
        addParameter("doubleNameValue", findValue(doubleValue, valueClazz));
      } else if (doubleName != null) {
        addParameter("doubleNameValue", findValue(doubleName.toString(), valueClazz));
      }
    } else {
      if (doubleValue != null) {
        addParameter("doubleNameValue", findValue(doubleValue));
      } else if (doubleName != null) {
        addParameter("doubleNameValue", findValue(doubleName.toString()));
      }
    }

    Form form = (Form) findAncestor(Form.class);
    if (doubleId != null) {
      // this check is needed for backwards compatibility with 2.1.x
      if (altSyntax()) {
        addParameter("doubleId", findString(doubleId));
      } else {
        addParameter("doubleId", doubleId);
      }
    } else if (form != null) {
      addParameter("doubleId", form.getParameters().get("id") + "_" + escape(this.doubleName));
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

    if (doubleCssClass != null) {
      addParameter("doubleCss", findString(doubleCssClass));
    }

    if (doubleCssStyle != null) {
      addParameter("doubleStyle", findString(doubleCssStyle));
    }

    if (doubleHeaderKey != null && doubleHeaderValue != null) {
      addParameter("doubleHeaderKey", findString(doubleHeaderKey));
      addParameter("doubleHeaderValue", findString(doubleHeaderValue));
    }

    if (doubleEmptyOption != null) {
      addParameter("doubleEmptyOption", findValue(doubleEmptyOption, Boolean.class));
    }

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