Ejemplo n.º 1
0
  public int doStartTag() throws JspException {

    UiControlElementConfigTag ancestorTag =
        (UiControlElementConfigTag) findAncestorWithClass(this, UiControlElementConfigTag.class);
    if (ancestorTag == null) {
      String message = "UiSelectTag tag must be nested within a UiControlElementConfigTag tag.";
      throw new JspException(message);
    }

    if (ancestorTag.getAncestor().getAncestor().isConfigMode()) {

      setName(ancestorTag.getBean());

      if (this.multiple != null) {
        setProperty(ancestorTag.getProperty() + ".values");
      } else {
        setProperty(ancestorTag.getProperty() + ".value");
      }

      if (this.value == null) {
        if (this.multiple == null) {
          setValue(ancestorTag.getControlElement().getValue());
        }
      }
    }

    setAncestor(ancestorTag);

    return super.doStartTag();
  }
Ejemplo n.º 2
0
 public int doEndTag() throws JspException {
   try {
     UiControlView control = ancestor.getAncestor().getControl();
     if (RefCodeNames.UI_CONTROL_STATUS_CD.ACTIVE.equals(control.getUiControlData().getStatusCd())
         || ancestor.getAncestor().getAncestor().isConfigMode()) {
       return super.doEndTag();
     } else if (RefCodeNames.UI_CONTROL_STATUS_CD.INACTIVE.equals(
         control.getUiControlData().getStatusCd())) {
       if (this.multiple != null) {
         for (String value : this.match) {
           String body =
               "<input type=\"hidden\" name=\""
                   + this.property
                   + "\""
                   + (value != null ? " value=\"" + value + "\"" : "")
                   + "/>";
           ancestor.getAncestor().addElementBody(ancestor.getControlElement(), body);
         }
       } else {
         Object value =
             PropertyUtils.getProperty(
                 pageContext.findAttribute(Utility.strNN(this.name)), this.property);
         this.value = value != null ? String.valueOf(value) : null;
         String body =
             "<input type=\"hidden\" name=\""
                 + this.property
                 + "\""
                 + (this.value != null ? " value=\"" + this.value + "\"" : "")
                 + "/>";
         ancestor.getAncestor().addElementBody(ancestor.getControlElement(), body);
       }
     } else if (RefCodeNames.UI_CONTROL_STATUS_CD.DEFAULT.equals(
         control.getUiControlData().getStatusCd())) {
       if (this.multiple != null) {
         if (this.match == null || this.match.length == 0) {
           String[] elementValues =
               ancestor.getControlElement() != null
                   ? new UiControlElementDataWrapper(ancestor.getControlElement()).getValues()
                   : new String[0];
           for (String value : elementValues) {
             String body =
                 "<input type=\"hidden\" name=\""
                     + this.property
                     + "\""
                     + (value != null ? " value=\"" + value + "\"" : "")
                     + "/>";
             ancestor.getAncestor().addElementBody(ancestor.getControlElement(), body);
           }
         } else {
           for (String value : this.match) {
             String body =
                 "<input type=\"hidden\" name=\""
                     + this.property
                     + "\""
                     + (value != null ? " value=\"" + value + "\"" : "")
                     + "/>";
             ancestor.getAncestor().addElementBody(ancestor.getControlElement(), body);
           }
         }
       } else {
         Object value =
             PropertyUtils.getProperty(
                 pageContext.findAttribute(Utility.strNN(this.name)), this.property);
         this.value = value != null ? String.valueOf(value) : null;
         String elementValue =
             ancestor.getControlElement() != null ? ancestor.getControlElement().getValue() : null;
         String body =
             "<input type=\"hidden\" name=\""
                 + this.property
                 + "\" value=\""
                 + (Utility.isSet(this.value)
                     ? String.valueOf(this.value)
                     : Utility.strNN(elementValue))
                 + "\"/>";
         ancestor.getAncestor().addElementBody(ancestor.getControlElement(), body);
       }
     }
     return EVAL_PAGE;
   } catch (Exception e) {
     throw new JspException(e.getMessage());
   } finally {
     this.release();
   }
 }