コード例 #1
0
ファイル: DefineTag.java プロジェクト: srpras78/study-prj
  /**
   * Retrieve the required property and expose it as a scripting variable.
   *
   * @throws JspException if a JSP exception has occurred
   */
  public int doEndTag() throws JspException {
    // Enforce restriction on ways to declare the new value
    int n = 0;

    if (this.body != null) {
      n++;
    }

    if (this.name != null) {
      n++;
    }

    if (this.value != null) {
      n++;
    }

    if (n > 1) {
      JspException e = new JspException(messages.getMessage("define.value", id));

      TagUtils.getInstance().saveException(pageContext, e);
      throw e;
    }

    // Retrieve the required property value
    Object value = this.value;

    if ((value == null) && (name != null)) {
      value = TagUtils.getInstance().lookup(pageContext, name, property, scope);
    }

    if ((value == null) && (body != null)) {
      value = body;
    }

    if (value == null) {
      JspException e = new JspException(messages.getMessage("define.null", id));

      TagUtils.getInstance().saveException(pageContext, e);
      throw e;
    }

    // Expose this value as a scripting variable
    int inScope = PageContext.PAGE_SCOPE;

    try {
      if (toScope != null) {
        inScope = TagUtils.getInstance().getScope(toScope);
      }
    } catch (JspException e) {
      log.warn("toScope was invalid name so we default to PAGE_SCOPE", e);
    }

    pageContext.setAttribute(id, value, inScope);

    // Continue processing this page
    return (EVAL_PAGE);
  }
コード例 #2
0
  /**
   * Returns true if the bean given in the <code>name</code> attribute is found.
   *
   * @since Struts 1.2
   */
  protected boolean isBeanPresent() {
    Object value = null;
    try {
      if (this.property != null) {
        value = TagUtils.getInstance().lookup(pageContext, name, this.property, scope);
      } else {
        value = TagUtils.getInstance().lookup(pageContext, name, scope);
      }
    } catch (JspException e) {
      value = null;
    }

    return (value != null);
  }
コード例 #3
0
ファイル: HiddenTagHDIV.java プロジェクト: ravej/hdiv
  /**
   * Generate the required input tag, followed by the optional rendered text. Support for <code>
   * write</code> property since Struts 1.1.
   *
   * @exception JspException if a JSP exception has occurred
   * @see org.hdiv.dataComposer.IDataComposer#composeFormField(String, String, boolean, String)
   */
  public int doStartTag() throws JspException {

    try {
      String hiddenValue = value;
      Object lookupValue = null;

      if (value == null) {
        // locate and return the specified property of the specified bean
        lookupValue = TagUtils.getInstance().lookup(pageContext, name, property, null);

        if (lookupValue != null) {
          hiddenValue = lookupValue.toString();
        }
      }

      HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
      IDataComposer dataComposer = HDIVUtil.getDataComposer(request);
      this.encodedValue = dataComposer.composeFormField(prepareName(), hiddenValue, false, null);

      // Render the result to the output writer
      TagUtils.getInstance().write(this.pageContext, this.renderInputElement());

      // Is rendering the value separately requested?
      if (!write) {
        return (EVAL_BODY_TAG);
      }

      // Calculate the value to be rendered separately
      // * @since Struts 1.1
      String results = null;
      if (value != null) {
        results = TagUtils.getInstance().filter(value);
      } else {
        if (lookupValue == null) {
          results = "";
        } else {
          results = TagUtils.getInstance().filter(lookupValue.toString());
        }
      }

      // Render the result to the output writer
      TagUtils.getInstance().write(pageContext, results);
      return (EVAL_BODY_TAG);

    } catch (JspException e) {
      log.debug(e.getMessage());
      throw e;
    }
  }
コード例 #4
0
ファイル: ArchiveTag.java プロジェクト: joantune/fenix
  @Override
  public int doStartTag() throws JspException {

    final Object value = TagUtils.getInstance().lookup(pageContext, name, property, scope);
    if (value == null) {
      throw new JspTagException(
          "Could not find the archive object (name,property,scope)="
              + "("
              + name
              + ","
              + "property"
              + ","
              + scope
              + ")");
    }
    if (!(value instanceof AnnouncementArchive)) {
      throw new JspTagException(
          "The specified object is not of the correct type. Is "
              + value.getClass().getName()
              + " should be "
              + AnnouncementArchive.class.getName());
    } else {

      try {
        pageContext.getOut().write(this.renderArchive(value));

      } catch (IOException e) {
        throw new JspTagException("IO Error: " + e.getMessage());
      }
    }
    return EVAL_BODY_INCLUDE;
  }
コード例 #5
0
  public int doEndTag() throws JspException {

    Serializable id = (Serializable) TagUtils.getInstance().lookup(pageContext, name, scope);
    if (id == null) {
      return (EVAL_PAGE);
    }

    IMenuControlBS menuControl = (IMenuControlBS) this.getService(service);
    try {
      List all = menuControl.loadMenuItemTree();
      List owned = null;
      if ("user".equals(accordingTo)) {
        owned = menuControl.findAllMenuItemsByUserId(id);
      } else if ("role".equals(accordingTo)) {
        owned = menuControl.findAllMenuItemsByRoleId(id);
      } else {
        throw new JspException("accordingTo ±ØÐëÊÇuser»òrole£¡");
      }
      MenuSelectorDrawer drawer = new MenuSelectorDrawer();
      String result = drawer.draw(all, owned);
      JspWriter out = pageContext.getOut();
      out.write(result);
    } catch (Exception ex) {
      throw new JspException(ex);
    }
    return EVAL_PAGE;
  }
コード例 #6
0
ファイル: RadioTag.java プロジェクト: mumitr0ll/struts1
  /**
   * Optionally render the associated label from the body content.
   *
   * @throws JspException if a JSP exception has occurred
   */
  public int doEndTag() throws JspException {
    // Render any description for this radio button
    if (this.text != null) {
      TagUtils.getInstance().write(pageContext, text);
    }

    return (EVAL_PAGE);
  }
コード例 #7
0
ファイル: RadioTag.java プロジェクト: mumitr0ll/struts1
  /**
   * Generate the required input tag. [Indexed property since Struts 1.1]
   *
   * @throws JspException if a JSP exception has occurred
   */
  public int doStartTag() throws JspException {
    String radioTag = renderRadioElement(serverValue(), currentValue());

    TagUtils.getInstance().write(pageContext, radioTag);

    this.text = null;

    return (EVAL_BODY_TAG);
  }
コード例 #8
0
 @Override
 public int doStartTag() throws JspException {
   if (fieldConfig.isFieldHidden(getKeyhm())) {
     return SKIP_BODY;
   } else if (!fieldConfig.isFieldHidden(getKeyhm())
       && fieldConfig.isFieldManadatory(getKeyhm())) {
     TagUtils.getInstance().write(this.pageContext, renderDoStartTag());
   }
   return super.doStartTag();
 }
コード例 #9
0
  public static class Cb implements AccessXmlCb, Serializable {
    private Client cl;
    private TagUtils tagUtil = TagUtils.getInstance();

    QName errorTag;
    String errorMsg;

    Cb(final Client cl) {
      this.cl = cl;
    }

    public String makeHref(final String id, final int whoType) throws AccessException {
      try {
        return tagUtil.filter(cl.makePrincipalUri(id, whoType));
      } catch (Throwable t) {
        throw new AccessException(t);
      }
    }

    public AccessPrincipal getPrincipal() throws AccessException {
      try {
        return cl.getCurrentPrincipal();
      } catch (CalFacadeException cfe) {
        throw new AccessException(cfe);
      }
    }

    public AccessPrincipal getPrincipal(final String href) throws AccessException {
      try {
        return cl.getPrincipal(href);
      } catch (CalFacadeException cfe) {
        throw new AccessException(cfe);
      }
    }

    @Override
    public void setErrorTag(final QName tag) throws AccessException {
      errorTag = tag;
    }

    @Override
    public QName getErrorTag() throws AccessException {
      return errorTag;
    }

    @Override
    public void setErrorMsg(final String val) throws AccessException {
      errorMsg = val;
    }

    @Override
    public String getErrorMsg() throws AccessException {
      return errorMsg;
    }
  }
コード例 #10
0
  /**
   * Evaluate the condition that is being tested by this particular tag, and return <code>true
   * </code> if there is at least one message in the class or for the property specified. This
   * method must be implemented by concrete subclasses.
   *
   * @param desired Desired outcome for a true result
   * @exception JspException if a JSP exception occurs
   */
  protected boolean condition(boolean desired) throws JspException {
    ActionMessages am = null;

    String key = name;
    if (message != null && "true".equalsIgnoreCase(message)) {
      key = Globals.MESSAGE_KEY;
    }

    try {
      am = TagUtils.getInstance().getActionMessages(pageContext, key);

    } catch (JspException e) {
      TagUtils.getInstance().saveException(pageContext, e);
      throw e;
    }

    Iterator iterator = (property == null) ? am.get() : am.get(property);

    return (iterator.hasNext() == desired);
  }
コード例 #11
0
ファイル: HiddenTagHDIV.java プロジェクト: ravej/hdiv
  /**
   * Render the value element.
   *
   * @param results The StringBuffer that output will be appended to.
   */
  protected void prepareValue(StringBuffer results) throws JspException {

    results.append(" value=\"");

    if (this.encodedValue != null) {
      results.append(this.formatValue(this.encodedValue));

    } else if (redisplay || !"password".equals(type)) {
      Object lookupValue = TagUtils.getInstance().lookup(pageContext, name, property, null);
      results.append(this.formatValue(lookupValue));
    }
    results.append("\"");
  }
コード例 #12
0
ファイル: CheckboxTag.java プロジェクト: nguyen-tom/s2struts
  public int doStartTag() throws JspException {
    int ret = super.doStartTag();

    StringBuffer hidden = new StringBuffer();
    hidden.append("<input");
    prepareAttribute(hidden, "type", "hidden");
    prepareAttribute(hidden, "name", Constants.CHECKBOX_NAME + prepareName());
    prepareAttribute(hidden, "value", Boolean.TRUE);
    hidden.append(getElementClose());

    TagUtils.getInstance().write(super.pageContext, hidden.toString());
    return ret;
  }
コード例 #13
0
ファイル: SizeTag.java プロジェクト: BackupTheBerlios/emayor
  /**
   * Retrieve the required property and expose it as a scripting variable.
   *
   * @exception JspException if a JSP exception has occurred
   */
  public int doStartTag() throws JspException {

    // Retrieve the required property value
    Object value = this.collection;
    if (value == null) {
      if (name == null) {
        // Must specify either a collection attribute or a name
        // attribute.
        JspException e = new JspException(messages.getMessage("size.noCollectionOrName"));
        TagUtils.getInstance().saveException(pageContext, e);
        throw e;
      }

      value = TagUtils.getInstance().lookup(pageContext, name, property, scope);
    }

    // Identify the number of elements, based on the collection type
    int size = 0;
    if (value == null) {
      JspException e = new JspException(messages.getMessage("size.collection"));
      TagUtils.getInstance().saveException(pageContext, e);
      throw e;
    } else if (value.getClass().isArray()) {
      size = Array.getLength(value);
    } else if (value instanceof Collection) {
      size = ((Collection) value).size();
    } else if (value instanceof Map) {
      size = ((Map) value).size();
    } else {
      JspException e = new JspException(messages.getMessage("size.collection"));
      TagUtils.getInstance().saveException(pageContext, e);
      throw e;
    }

    // Expose this size as a scripting variable
    pageContext.setAttribute(this.id, new Integer(size), PageContext.PAGE_SCOPE);
    return (SKIP_BODY);
  }
コード例 #14
0
ファイル: MenuBarTag.java プロジェクト: cmorenogg/alsigm
  /** @see javax.servlet.jsp.tagext.Tag#doEndTag() */
  public int doEndTag() throws JspException {

    if (menus == null) {
      menus = (List) pageContext.findAttribute(getName());
    }

    try {
      if (getPosition().equalsIgnoreCase("rows")) drawMenuRows();

      if (getPosition().equalsIgnoreCase("cols"))
        // drawMenuCols();
        drawMenuOcultable();

    } catch (IOException e) {
      TagUtils.getInstance().saveException(pageContext, e);
      throw new JspException(e);
    } catch (ISPACException e) {
      TagUtils.getInstance().saveException(pageContext, e);
      throw new JspException(e);
    }
    menus = null;
    return EVAL_PAGE;
  }
コード例 #15
0
  /**
   * Process the start tag.
   *
   * @return int
   * @exception JspException if a JSP exception has occurred
   */
  public int doStartTag() throws JspException {
    req__ = (HttpServletRequest) pageContext.getRequest();

    // Look up the requested bean (if necessary)
    if (ignore) {
      if (TagUtils.getInstance().lookup(pageContext, name, scope) == null) {
        return (SKIP_BODY); // Nothing to output
      }
    }

    // Look up the requested property value
    Object value = TagUtils.getInstance().lookup(pageContext, name, property, scope);

    if (value == null) {
      return (SKIP_BODY); // Nothing to output
    }
    // 使用する型に置き換える

    if (value instanceof TcdTimezoneChartModel) {
      // 型が違う場合はエラー
      //            return (SKIP_BODY); // Nothing to output
    }
    TcdTimezoneChartModel zoneMdl = (TcdTimezoneChartModel) value;
    JspWriter writer = pageContext.getOut();
    //      //再起的にHTMLを吐き出す。
    try {

      __writeTag(writer, zoneMdl);

    } catch (Exception e) {
      throw new JspException("Jsp出力に失敗しました。", e);
    }

    // Continue processing this page
    return (SKIP_BODY);
  }
コード例 #16
0
ファイル: ParameterTag.java プロジェクト: nykma/ykt4sungard
  /**
   * Retrieve the required property and expose it as a scripting variable.
   *
   * @exception JspException if a JSP exception has occurred
   */
  public int doStartTag() throws JspException {

    // Deal with a single parameter value
    if (multiple == null) {
      String value = pageContext.getRequest().getParameter(name);
      if ((value == null) && (this.value != null)) {
        value = this.value;
      }

      if (value == null) {
        JspException e = new JspException(messages.getMessage("parameter.get", name));
        TagUtils.getInstance().saveException(pageContext, e);
        throw e;
      }

      pageContext.setAttribute(id, value);
      return (SKIP_BODY);
    }

    // Deal with multiple parameter values
    String values[] = pageContext.getRequest().getParameterValues(name);
    if ((values == null) || (values.length == 0)) {
      if (this.value != null) {
        values = new String[] {this.value};
      }
    }

    if ((values == null) || (values.length == 0)) {
      JspException e = new JspException(messages.getMessage("parameter.get", name));
      TagUtils.getInstance().saveException(pageContext, e);
      throw e;
    }

    pageContext.setAttribute(id, values);
    return (SKIP_BODY);
  }
コード例 #17
0
ファイル: KeepAlive.java プロジェクト: cmorenogg/alsigm
  public int doStartTag() throws JspException {
    String ticket = getTicket();
    String url = getUrl(ticket);
    String period = getPeriod();
    StringBuffer out = buildStartContents(period, url);

    try {
      JspWriter writer = pageContext.getOut();
      writer.print(out.toString());
    } catch (IOException ioe) {
      TagUtils.getInstance().saveException(pageContext, ioe);
      throw new JspException(ioe.toString());
    }

    return (EVAL_BODY_INCLUDE);
  }
コード例 #18
0
ファイル: RadioTag.java プロジェクト: mumitr0ll/struts1
  /**
   * Renders an HTML &lt;input type="radio"&gt; element.
   *
   * @param serverValue The data to be used in the tag's <code>value</code> attribute and sent to
   *     the server when the form is submitted.
   * @param checkedValue If the serverValue equals this value the radio button will be checked.
   * @return A radio input element.
   * @throws JspException
   * @since Struts 1.1
   */
  protected String renderRadioElement(String serverValue, String checkedValue) throws JspException {
    StringBuffer results = new StringBuffer("<input type=\"radio\"");

    prepareAttribute(results, "name", prepareName());
    prepareAttribute(results, "accesskey", getAccesskey());
    prepareAttribute(results, "tabindex", getTabindex());
    prepareAttribute(results, "value", TagUtils.getInstance().filter(serverValue));

    if (serverValue.equals(checkedValue)) {
      results.append(" checked=\"checked\"");
    }

    results.append(prepareEventHandlers());
    results.append(prepareStyles());
    prepareOtherAttributes(results);
    results.append(getElementClose());

    return results.toString();
  }
コード例 #19
0
  @Override
  public int doEndTag() throws JspException {
    if (fieldConfig.isFieldHidden(getKeyhm())) {
      return EVAL_PAGE;
    }

    String bundle = "UIResources";
    String name = org.mifos.framework.util.helpers.Constants.SELECTTAG;

    // Remove the page scope attributes we created
    pageContext.removeAttribute(Constants.SELECT_KEY);

    // Render a tag representing the end of our current form
    StringBuffer results = new StringBuffer();
    results.append("<option value= \"\">");
    String preferredUserLocale = LabelTagUtils.getInstance().getUserPreferredLocale(pageContext);
    String label =
        (LabelTagUtils.getInstance()
            .getLabel(pageContext, bundle, preferredUserLocale, name, null));
    TagUtils.getInstance().write(pageContext, renderDoEndTag(label));
    return (EVAL_PAGE);
  }
コード例 #20
0
  /**
   * Evaluate the condition that is being tested by this particular tag, and return <code>true
   * </code> if the nested body content of this tag should be evaluated, or <code>false</code> if it
   * should be skipped. This method must be implemented by concrete subclasses.
   *
   * @param desired Desired outcome for a true result
   * @exception JspException if a JSP exception occurs
   */
  protected boolean condition(boolean desired) throws JspException {
    // Evaluate the presence of the specified value
    boolean present = false;
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    if (cookie != null) {
      present = this.isCookiePresent(request);

    } else if (header != null) {
      String value = request.getHeader(header);
      present = (value != null);

    } else if (name != null) {
      present = this.isBeanPresent();

    } else if (parameter != null) {
      String value = request.getParameter(parameter);
      present = (value != null);

    } else if (role != null) {
      StringTokenizer st = new StringTokenizer(role, ROLE_DELIMITER, false);
      while (!present && st.hasMoreTokens()) {
        present = request.isUserInRole(st.nextToken());
      }

    } else if (user != null) {
      Principal principal = request.getUserPrincipal();
      present = (principal != null) && user.equals(principal.getName());

    } else {
      JspException e = new JspException(messages.getMessage("logic.selector"));
      TagUtils.getInstance().saveException(pageContext, e);
      throw e;
    }

    return (present == desired);
  }
コード例 #21
0
ファイル: MessageTag.java プロジェクト: srpras78/study-prj
  /**
   * Process the start tag.
   *
   * @throws JspException if a JSP exception has occurred
   */
  public int doStartTag() throws JspException {
    String key = this.key;

    if (key == null) {
      // Look up the requested property value
      Object value = TagUtils.getInstance().lookup(pageContext, name, property, scope);

      if ((value != null) && !(value instanceof String)) {
        JspException e = new JspException(messages.getMessage("message.property", key));

        TagUtils.getInstance().saveException(pageContext, e);
        throw e;
      }

      key = (String) value;
    }

    // Construct the optional arguments array we will be using
    Object[] args = new Object[] {arg0, arg1, arg2, arg3, arg4};

    // Retrieve the message string we are looking for
    String message =
        TagUtils.getInstance().message(pageContext, this.bundle, this.localeKey, key, args);

    if (message == null) {
      Locale locale = TagUtils.getInstance().getUserLocale(pageContext, this.localeKey);
      String localeVal = (locale == null) ? "default locale" : locale.toString();
      JspException e =
          new JspException(
              messages.getMessage(
                  "message.message",
                  "\"" + key + "\"",
                  "\"" + ((bundle == null) ? "(default bundle)" : bundle) + "\"",
                  localeVal));

      TagUtils.getInstance().saveException(pageContext, e);
      throw e;
    }

    TagUtils.getInstance().write(pageContext, message);

    return (SKIP_BODY);
  }
コード例 #22
0
ファイル: ErrorsTag.java プロジェクト: mumitr0ll/struts1
  /**
   * Render the specified error messages if there are any.
   *
   * @throws JspException if a JSP exception has occurred
   */
  public int doStartTag() throws JspException {
    // Were any error messages specified?
    ActionMessages errors = null;

    try {
      errors = TagUtils.getInstance().getActionMessages(pageContext, name);
    } catch (JspException e) {
      TagUtils.getInstance().saveException(pageContext, e);
      throw e;
    }

    if ((errors == null) || errors.isEmpty()) {
      return (EVAL_BODY_INCLUDE);
    }

    boolean headerPresent =
        TagUtils.getInstance().present(pageContext, bundle, locale, getHeader());

    boolean footerPresent =
        TagUtils.getInstance().present(pageContext, bundle, locale, getFooter());

    boolean prefixPresent =
        TagUtils.getInstance().present(pageContext, bundle, locale, getPrefix());

    boolean suffixPresent =
        TagUtils.getInstance().present(pageContext, bundle, locale, getSuffix());

    // Render the error messages appropriately
    StringBuffer results = new StringBuffer();
    boolean headerDone = false;
    String message = null;
    Iterator reports = (property == null) ? errors.get() : errors.get(property);

    while (reports.hasNext()) {
      ActionMessage report = (ActionMessage) reports.next();

      if (!headerDone) {
        if (headerPresent) {
          message = TagUtils.getInstance().message(pageContext, bundle, locale, getHeader());

          results.append(message);
        }

        headerDone = true;
      }

      if (prefixPresent) {
        message = TagUtils.getInstance().message(pageContext, bundle, locale, getPrefix());
        results.append(message);
      }

      if (report.isResource()) {
        message =
            TagUtils.getInstance()
                .message(pageContext, bundle, locale, report.getKey(), report.getValues());
      } else {
        message = report.getKey();
      }

      if (message != null) {
        results.append(message);
      }

      if (suffixPresent) {
        message = TagUtils.getInstance().message(pageContext, bundle, locale, getSuffix());
        results.append(message);
      }
    }

    if (headerDone && footerPresent) {
      message = TagUtils.getInstance().message(pageContext, bundle, locale, getFooter());
      results.append(message);
    }

    TagUtils.getInstance().write(pageContext, results.toString());

    return (EVAL_BODY_INCLUDE);
  }
コード例 #23
0
ファイル: CompareTagBase.java プロジェクト: nykma/ykt4sungard
  /**
   * Evaluate the condition that is being tested by this particular tag, and return <code>true
   * </code> if the nested body content of this tag should be evaluated, or <code>false</code> if it
   * should be skipped. This method must be implemented by concrete subclasses.
   *
   * @param desired1 First desired value for a true result (-1, 0, +1)
   * @param desired2 Second desired value for a true result (-1, 0, +1)
   * @exception JspException if a JSP exception occurs
   */
  protected boolean condition(int desired1, int desired2) throws JspException {

    // Acquire the value and determine the test type
    int type = -1;
    double doubleValue = 0.0;
    long longValue = 0;
    if ((type < 0) && (value.length() > 0)) {
      try {
        doubleValue = Double.parseDouble(value);
        type = DOUBLE_COMPARE;
      } catch (NumberFormatException e) {;
      }
    }
    if ((type < 0) && (value.length() > 0)) {
      try {
        longValue = Long.parseLong(value);
        type = LONG_COMPARE;
      } catch (NumberFormatException e) {;
      }
    }
    if (type < 0) {
      type = STRING_COMPARE;
    }

    // Acquire the unconverted variable value
    Object variable = null;
    if (cookie != null) {
      Cookie cookies[] = ((HttpServletRequest) pageContext.getRequest()).getCookies();
      if (cookies == null) cookies = new Cookie[0];
      for (int i = 0; i < cookies.length; i++) {
        if (cookie.equals(cookies[i].getName())) {
          variable = cookies[i].getValue();
          break;
        }
      }
    } else if (header != null) {
      variable = ((HttpServletRequest) pageContext.getRequest()).getHeader(header);
    } else if (name != null) {
      Object bean = TagUtils.getInstance().lookup(pageContext, name, scope);
      if (property != null) {
        if (bean == null) {
          JspException e = new JspException(messages.getMessage("logic.bean", name));
          TagUtils.getInstance().saveException(pageContext, e);
          throw e;
        }
        try {
          variable = PropertyUtils.getProperty(bean, property);
        } catch (InvocationTargetException e) {
          Throwable t = e.getTargetException();
          if (t == null) t = e;
          TagUtils.getInstance().saveException(pageContext, t);
          throw new JspException(
              messages.getMessage("logic.property", name, property, t.toString()));
        } catch (Throwable t) {
          TagUtils.getInstance().saveException(pageContext, t);
          throw new JspException(
              messages.getMessage("logic.property", name, property, t.toString()));
        }
      } else {
        variable = bean;
      }
    } else if (parameter != null) {
      variable = pageContext.getRequest().getParameter(parameter);
    } else {
      JspException e = new JspException(messages.getMessage("logic.selector"));
      TagUtils.getInstance().saveException(pageContext, e);
      throw e;
    }
    if (variable == null) {
      variable = ""; // Coerce null to a zero-length String
    }

    // Perform the appropriate comparison
    int result = 0;
    if (type == DOUBLE_COMPARE) {
      try {
        double doubleVariable = Double.parseDouble(variable.toString());
        if (doubleVariable < doubleValue) result = -1;
        else if (doubleVariable > doubleValue) result = +1;
      } catch (NumberFormatException e) {
        result = variable.toString().compareTo(value);
      }
    } else if (type == LONG_COMPARE) {
      try {
        long longVariable = Long.parseLong(variable.toString());
        if (longVariable < longValue) result = -1;
        else if (longVariable > longValue) result = +1;
      } catch (NumberFormatException e) {
        result = variable.toString().compareTo(value);
      }
    } else {
      result = variable.toString().compareTo(value);
    }

    // Normalize the result
    if (result < 0) result = -1;
    else if (result > 0) result = +1;

    // Return true if the result matches either desired value
    return ((result == desired1) || (result == desired2));
  }