Results 1 to 3 of 3

Thread: ComboBox validation with renderedProperty

  1. #1
    Join Date
    Jul 2009
    Posts
    4

    Default ComboBox validation with renderedProperty

    Hi,

    I need some help with the combo box binding. I have a form with a combo box created like this:

    Code:
    List<?> breeders = store.createNamedQuery("listAllBreeders").getResultList();
    		
    Binding breederSelector = ((SwingBindingFactory)getBindingFactory())
    	.createBoundComboBox("breeder", breeders.toArray(new Breeder[0]), "name");
    A validation rule makes the breeder property required. Unfortunately validation still fails after I enter a new value into the box. If an existing value is selected it works as expected i.e. validation succeeds.

    I'd be grateful for any hint on how to make it work. I'm using 1.1.0 btw.

    thanks,

    jokkmokk

  2. #2
    Join Date
    Mar 2007
    Location
    Oudenaarde
    Posts
    294

    Default

    Can you build a test case or sample app that demonstrates this behavior?
    MSN: PM me please
    Skype: doclo_lieven

    Spring Rich Client Project Lead

  3. #3
    Join Date
    Jul 2009
    Posts
    4

    Default

    Hi,

    I modified the simple sample reflected by this patch:

    Code:
    Index: src/main/java/org/springframework/richclient/samples/simple/domain/Contact.java
    ===================================================================
    --- src/main/java/org/springframework/richclient/samples/simple/domain/Contact.java	(revision 2211)
    +++ src/main/java/org/springframework/richclient/samples/simple/domain/Contact.java	(working copy)
    @@ -63,6 +63,16 @@
         private BigDecimal monthlyIncome;
     
         private List<TodoItem> todoItems;
    +    
    +    private TodoItem dummy;
    +    
    +    public void setDummy(TodoItem dummy) {
    +    	this.dummy = dummy;
    +    }
    +    
    +    public TodoItem getDummy() {
    +    	return dummy;
    +    }
     
     	/**
     	 * Default constructor.
    Index: src/main/java/org/springframework/richclient/samples/simple/domain/SimpleValidationRulesSource.java
    ===================================================================
    --- src/main/java/org/springframework/richclient/samples/simple/domain/SimpleValidationRulesSource.java	(revision 2211)
    +++ src/main/java/org/springframework/richclient/samples/simple/domain/SimpleValidationRulesSource.java	(working copy)
    @@ -99,6 +99,8 @@
     				add("address.zip", ZIPCODE_CONSTRAINT);
     
                     add("memo", required());
    +                
    +                add("dummy", required());
     			}
     		};
     	}
    Index: src/main/java/org/springframework/richclient/samples/simple/ui/ContactForm.java
    ===================================================================
    --- src/main/java/org/springframework/richclient/samples/simple/ui/ContactForm.java	(revision 2211)
    +++ src/main/java/org/springframework/richclient/samples/simple/ui/ContactForm.java	(working copy)
    @@ -15,17 +15,24 @@
      */
     package org.springframework.richclient.samples.simple.ui;
     
    -import com.jgoodies.forms.layout.FormLayout;
    +import java.util.HashMap;
    +
    +import javax.swing.JComboBox;
    +import javax.swing.JComponent;
    +import javax.swing.JTextField;
    +
     import org.springframework.richclient.form.AbstractFocussableForm;
     import org.springframework.richclient.form.FormModelHelper;
    +import org.springframework.richclient.form.binding.Binding;
     import org.springframework.richclient.form.binding.swing.NumberBinder;
    +import org.springframework.richclient.form.binding.swing.SwingBindingFactory;
     import org.springframework.richclient.form.builder.FormLayoutFormBuilder;
     import org.springframework.richclient.form.builder.TableFormBuilder;
     import org.springframework.richclient.samples.simple.domain.Contact;
    +import org.springframework.richclient.samples.simple.domain.TodoItem;
     import org.springframework.richclient.samples.simple.ui.binding.TodoItemListBinding;
     
    -import javax.swing.*;
    -import java.util.HashMap;
    +import com.jgoodies.forms.layout.FormLayout;
     
     /**
      * Form to handle the properties of a Contact object. It uses a {@link TableFormBuilder} to construct the layout of the
    @@ -51,6 +58,18 @@
             formBuilder.addPropertyAndLabel("lastName");
             setFocusControl(formBuilder.addPropertyAndLabel("firstName", 5)[1]);
             formBuilder.nextRow();
    +        
    +        TodoItem[] dummyItems = new TodoItem[] { 
    +        	new TodoItem("foo", null, null),
    +        	new TodoItem("bar", null, null)
    +        };
    +        Binding dummySelector = ((SwingBindingFactory)getBindingFactory())
    +    		.createBoundComboBox("dummy", dummyItems, "name");
    +        ((JComboBox)dummySelector.getControl()).setEditable(true);
    +        formBuilder.addLabel("dummy");
    +        formBuilder.addBinding(dummySelector, 3);
    +        formBuilder.nextRow();
    +        
             formBuilder.addPropertyAndLabel("dateOfBirth");
             formBuilder.nextRow();
             formBuilder.addPropertyAndLabel("homePhone");
    Index: src/main/resources/org/springframework/richclient/samples/simple/ctx/richclient-application-context.xml
    ===================================================================
    --- src/main/resources/org/springframework/richclient/samples/simple/ctx/richclient-application-context.xml	(revision 2211)
    +++ src/main/resources/org/springframework/richclient/samples/simple/ctx/richclient-application-context.xml	(working copy)
    @@ -266,7 +266,7 @@
             </bean>
             <bean class="org.springframework.richclient.form.builder.support.OverlayValidationInterceptorFactory" />
             <bean class="org.springframework.richclient.text.TextComponentPopupInterceptorFactory" />
    -        <bean class="org.springframework.richclient.list.ComboBoxAutoCompletionInterceptorFactory" />
    +        <!--<bean class="org.springframework.richclient.list.ComboBoxAutoCompletionInterceptorFactory" />-->
           </list>
         </property>
       </bean>
    I guess it's not intended to work that way because there is no validation triggered when I change the combobox value by typing it in. It would be great though if this were possible somehow.

    thanks,

    jokkmokk

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •