Examples of BindStatus


Examples of org.springframework.web.servlet.support.BindStatus

   * Render the '<code>input(checkbox)</code>' with the supplied value, marking the
   * '<code>input</code>' element as 'checked' if the supplied value matches the
   * bound value.
   */
  protected void renderFromValue(Object resolvedValue, TagWriter tagWriter) throws JspException {
    BindStatus bindStatus = getBindStatus();
    PropertyEditor editor = null;
    if (resolvedValue != null && bindStatus.getErrors() instanceof BindingResult) {
      PropertyEditorRegistry editorRegistry = ((BindingResult) bindStatus.getErrors()).getPropertyEditorRegistry();
      if (editorRegistry != null) {
        editor = editorRegistry.findCustomEditor(resolvedValue.getClass(), bindStatus.getPath());
      }
    }
    tagWriter.writeAttribute("value", getDisplayString(resolvedValue, editor));
    if (SelectedValueComparator.isSelected(bindStatus, resolvedValue)) {
      tagWriter.writeAttribute("checked", "checked");
View Full Code Here

Examples of org.springframework.web.servlet.support.BindStatus

        resolvedPath = nestedPath + resolvedPath;
      }
    }

    try {
      this.status = new BindStatus(getRequestContext(), resolvedPath, isHtmlEscape());
    }
    catch (IllegalStateException ex) {
      throw new JspTagException(ex.getMessage());
    }
View Full Code Here

Examples of org.springframework.web.servlet.support.BindStatus

  protected BindStatus getBindStatus() throws JspException {
    if (this.bindStatus == null) {
      String resolvedPropertyPath = getPath();
      String bindPath = getBindPath(resolvedPropertyPath);
      // HTML escaping in tags is performed by the ValueFormatter class.
      this.bindStatus = new BindStatus(getRequestContext(), bindPath, false);
    }
    return this.bindStatus;
  }
View Full Code Here

Examples of org.springframework.web.servlet.support.BindStatus

  /**
   * Returns '<code>true</code>' if the bound value requires the
   * resultant '<code>select</code>' tag to be multi-select.
   */
  private boolean forceMultiple() throws JspException {
    BindStatus bindStatus = getBindStatus();
    Class valueType = bindStatus.getValueType();
    if (valueType != null && typeRequiresMultiple(valueType)) {
      return true;
    }
    else if (bindStatus.getEditor() != null) {
      Object editorValue = bindStatus.getEditor().getValue();
      if (editorValue != null && typeRequiresMultiple(editorValue.getClass())) {
        return true;
      }
    }
    return false;
View Full Code Here

Examples of org.springframework.web.servlet.support.BindStatus

  /**
   * @see org.springframework.web.servlet.support.RequestContext#getBindStatus(String)
   */
  public BindStatus getBindStatus(String path) throws IllegalStateException {
    return new BindStatus(new RequestContext(this.request), path, false);
  }
View Full Code Here

Examples of org.springframework.web.servlet.support.BindStatus

  /**
   * @see org.springframework.web.servlet.support.RequestContext#getBindStatus(String, boolean)
   */
  public BindStatus getBindStatus(String path, boolean htmlEscape) throws IllegalStateException {
    return new BindStatus(new RequestContext(this.request), path, true);
  }
View Full Code Here

Examples of org.springframework.web.servlet.support.BindStatus

    BindTag tag = new BindTag();
    tag.setPageContext(pc);
    tag.setPath("tb.name");
    pc.getRequest().setAttribute("tb", new TestBean("juergen&eva", 99));
    tag.doStartTag();
    BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
    assertEquals("name", status.getExpression());
    assertEquals("juergen&eva", status.getValue());
  }
View Full Code Here

Examples of org.springframework.web.servlet.support.BindStatus

    tag.setPageContext(pc);
    tag.setPath("tb.name");
    tag.setHtmlEscape("true");
    pc.getRequest().setAttribute("tb", new TestBean("juergen&eva", 99));
    tag.doStartTag();
    BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
    assertEquals("name", status.getExpression());
    assertEquals("juergen&amp;eva", status.getValue());
  }
View Full Code Here

Examples of org.springframework.web.servlet.support.BindStatus

    BindTag tag = new BindTag();
    tag.setPageContext(pc);
    tag.setPath("tb");
    pc.getRequest().setAttribute("tb", new TestBean("juergen", 99));
    tag.doStartTag();
    BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
    assertNull(status.getExpression());
    assertNull(status.getValue());
  }
View Full Code Here

Examples of org.springframework.web.servlet.support.BindStatus

    BindTag bindTag = new BindTag();
    bindTag.setPageContext(pc);
    bindTag.setPath("name");

    assertTrue("Correct doStartTag return value", bindTag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
    BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
    assertTrue("Has status variable", status != null);
    assertEquals("tb.name", status.getPath());
    assertEquals("Correct field value", "", status.getDisplayValue());

    BindTag bindTag2 = new BindTag();
    bindTag2.setPageContext(pc);
    bindTag2.setPath("age");

    assertTrue("Correct doStartTag return value", bindTag2.doStartTag() == Tag.EVAL_BODY_INCLUDE);
    BindStatus status2 = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
    assertTrue("Has status variable", status2 != null);
    assertEquals("tb.age", status2.getPath());
    assertEquals("Correct field value", "0", status2.getDisplayValue());

    bindTag2.doEndTag();

    BindStatus status3 = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
    assertSame("Status matches previous status", status, status3);
    assertEquals("tb.name", status.getPath());
    assertEquals("Correct field value", "", status.getDisplayValue());

    bindTag.doEndTag();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.