Package java.beans

Examples of java.beans.PropertyEditorSupport


  public void testBindTagWithIndexedPropertiesAndCustomEditor() throws JspException {
    PageContext pc = createPageContext();
    IndexedTestBean tb = new IndexedTestBean();
    DataBinder binder = new ServletRequestDataBinder(tb, "tb");
    binder.registerCustomEditor(TestBean.class, null, new PropertyEditorSupport() {
      public String getAsText() {
        return "something";
      }
    });
    Errors errors = binder.getBindingResult();
View Full Code Here


  public void testBindingWithNestedObjectCreation() throws Exception {
    TestBean tb = new TestBean();

    ServletRequestDataBinder binder = new ServletRequestDataBinder(tb, "person");
    binder.registerCustomEditor(ITestBean.class, new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue(new TestBean());
      }
    });
View Full Code Here

  public void testBindingWithNestedObjectCreationAndWrongOrder() throws Exception {
    TestBean tb = new TestBean();

    ServletRequestDataBinder binder = new ServletRequestDataBinder(tb, "person");
    binder.registerCustomEditor(ITestBean.class, new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue(new TestBean());
      }
    });
View Full Code Here

  }
 
  public void testNestedBindingWithPropertyEditor() throws Exception {
    TestController tc = new TestController() {
      protected void initBinder(PortletRequest request, PortletRequestDataBinder binder) {
        binder.registerCustomEditor(ITestBean.class, new PropertyEditorSupport() {
          public void setAsText(String text) throws IllegalArgumentException {
            setValue(new TestBean(text));
          }
        });
      }
View Full Code Here

  }

  public void testBindingWithErrorsAndCustomEditors() throws Exception {
    TestBean rod = new TestBean();
    DataBinder binder = new DataBinder(rod, "person");
    binder.registerCustomEditor(String.class, "touchy", new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("prefix_" + text);
      }
      public String getAsText() {
        return getValue().toString().substring(7);
      }
    });
    binder.registerCustomEditor(TestBean.class, "spouse", new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue(new TestBean(text, 0));
      }
      public String getAsText() {
        return ((TestBean) getValue()).getName();
View Full Code Here

  public void testBindingWithNestedObjectCreation() throws Exception {
    TestBean tb = new TestBean();

    DataBinder binder = new DataBinder(tb, "person");
    binder.registerCustomEditor(ITestBean.class, new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue(new TestBean());
      }
    });
View Full Code Here

  public void testCustomEditorForSingleProperty() {
    TestBean tb = new TestBean();
    tb.setSpouse(new TestBean());
    DataBinder binder = new DataBinder(tb, "tb");

    binder.registerCustomEditor(String.class, "name", new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("prefix" + text);
      }
      public String getAsText() {
        return ((String) getValue()).substring(6);
View Full Code Here

  public void testCustomEditorForPrimitiveProperty() {
    TestBean tb = new TestBean();
    DataBinder binder = new DataBinder(tb, "tb");

    binder.registerCustomEditor(int.class, "age", new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue(new Integer(99));
      }
      public String getAsText() {
        return "argh";
View Full Code Here

  public void testCustomEditorForAllStringProperties() {
    TestBean tb = new TestBean();
    DataBinder binder = new DataBinder(tb, "tb");

    binder.registerCustomEditor(String.class, null, new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("prefix" + text);
      }
      public String getAsText() {
        return ((String) getValue()).substring(6);
View Full Code Here

  public void testCustomEditorWithOldValueAccess() {
    TestBean tb = new TestBean();
    DataBinder binder = new DataBinder(tb, "tb");

    binder.registerCustomEditor(String.class, null, new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        if (getValue() == null || !text.equalsIgnoreCase(getValue().toString())) {
          setValue(text);
        }
      }
View Full Code Here

TOP

Related Classes of java.beans.PropertyEditorSupport

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.