Package java.beans

Examples of java.beans.PropertyEditorSupport


  @Test
  public void testStringArrayPropertyWithCustomStringEditor() throws Exception {
    PropsTester pt = new PropsTester();
    BeanWrapper bw = new BeanWrapperImpl(pt);
    bw.registerCustomEditor(String.class, "stringArray", new PropertyEditorSupport() {
      @Override
      public void setAsText(String text) {
        setValue(text.substring(1));
      }
    });
View Full Code Here


  @Test
  public void testStringPropertyWithCustomEditor() throws Exception {
    TestBean tb = new TestBean();
    BeanWrapper bw = new BeanWrapperImpl(tb);
    bw.registerCustomEditor(String.class, "name", new PropertyEditorSupport() {
      @Override
      public void setValue(Object value) {
        if (value instanceof String[]) {
          setValue(StringUtils.arrayToDelimitedString(((String[]) value), "-"));
        }
View Full Code Here

  @Test
  public void testIntArrayPropertyWithCustomEditor() {
    PropsTester pt = new PropsTester();
    BeanWrapper bw = new BeanWrapperImpl(pt);
    bw.registerCustomEditor(int.class, new PropertyEditorSupport() {
      @Override
      public void setAsText(String text) {
        setValue(new Integer(Integer.parseInt(text) + 1));
      }
    });
View Full Code Here

  @Test
  public void testMapAccessWithTypeConversion() {
    IndexedTestBean bean = new IndexedTestBean();
    BeanWrapper bw = new BeanWrapperImpl(bean);
    bw.registerCustomEditor(TestBean.class, new PropertyEditorSupport() {
      @Override
      public void setAsText(String text) throws IllegalArgumentException {
        if (!StringUtils.hasLength(text)) {
          throw new IllegalArgumentException();
        }
View Full Code Here

  @Test
  public void testMapAccessWithUnmodifiableMap() {
    IndexedTestBean bean = new IndexedTestBean();
    BeanWrapper bw = new BeanWrapperImpl(bean);
    bw.registerCustomEditor(TestBean.class, "map", new PropertyEditorSupport() {
      @Override
      public void setAsText(String text) throws IllegalArgumentException {
        if (!StringUtils.hasLength(text)) {
          throw new IllegalArgumentException();
        }
View Full Code Here

  @Test
  public void testMapAccessWithCustomUnmodifiableMap() {
    IndexedTestBean bean = new IndexedTestBean();
    BeanWrapper bw = new BeanWrapperImpl(bean);
    bw.registerCustomEditor(TestBean.class, "map", new PropertyEditorSupport() {
      @Override
      public void setAsText(String text) throws IllegalArgumentException {
        if (!StringUtils.hasLength(text)) {
          throw new IllegalArgumentException();
        }
View Full Code Here

  @Test
  public void testLargeMatchingPrimitiveArrayWithSpecificEditor() {
    PrimitiveArrayBean tb = new PrimitiveArrayBean();
    BeanWrapper bw = new BeanWrapperImpl(tb);
    bw.registerCustomEditor(int.class, "array", new PropertyEditorSupport() {
      @Override
      public void setValue(Object value) {
        if (value instanceof Integer) {
          super.setValue(new Integer(((Integer) value).intValue() + 1));
        }
View Full Code Here

  @Test
  public void testLargeMatchingPrimitiveArrayWithIndexSpecificEditor() {
    PrimitiveArrayBean tb = new PrimitiveArrayBean();
    BeanWrapper bw = new BeanWrapperImpl(tb);
    bw.registerCustomEditor(int.class, "array[1]", new PropertyEditorSupport() {
      @Override
      public void setValue(Object value) {
        if (value instanceof Integer) {
          super.setValue(new Integer(((Integer) value).intValue() + 1));
        }
View Full Code Here

  public void testNestedBindWithPropertyEditor() {
    TestBean bean = new TestBean();

    PortletRequestDataBinder binder = new PortletRequestDataBinder(bean);
    binder.registerCustomEditor(ITestBean.class, new PropertyEditorSupport() {
      @Override
      public void setAsText(String text) throws IllegalArgumentException {
        setValue(new TestBean(text));
      }
    });
View Full Code Here

  @Test
  public void testCustomEditorForSingleProperty() {
    TestBean tb = new TestBean();
    BeanWrapper bw = new BeanWrapperImpl(tb);
    bw.registerCustomEditor(String.class, "name", new PropertyEditorSupport() {
      @Override
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("prefix" + 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.