As per a tip from Ollie
in this thread http://forum.springframework.org/showthread.php?t=15213 I'm trying to create a custom PropertyEditor. The one for the date picker got way too complex too quickly so I scaled my effords back some. Now the one I'm writeing is a simple JComboBox that uses a class called PaceValidValue as its list object which is nothing more that a name value pair of which when its toString() method is called the value is returned.Also a few suggestions:
* For the special date pickers use a custom PropertyEditor registered for the Date class. That way they get automatically inserted where needed.
* Let the binding framework create all of your controls rather than doing it yourself. In your initComponents() method you are creating whole lot of components expect for the JFormattedTextFields there's not need. In fact you can even avoid explicitly creating the JFormattedTextFields by registering custom PropertyEditors for the fields that need the special JFormattedTextField formatting.
HTH
Ollie
The problem I'm having is that the PropertyEditor I created does not seam to bind to the form model and I can not see why it does not. Here is the code:
and here is the form that is using the above PropertyEditorCode:/** * * @author stavares */ public class PaceValidValuePropertyEditor extends PropertyEditorSupport implements ChangeListener, ActionListener { private JComboBox jComboBox; private List theList; /** Creates a new instance of PaceValidValuePropertyEditor */ public PaceValidValuePropertyEditor(List theList) { jComboBox = new JComboBox(theList.toArray()); jComboBox.addActionListener(this); } public boolean supportsCustomEditor() { return true; } public Component getCustomEditor() { return jComboBox; } public void setValue(Object value) { PaceValidValue paceValidValue = (PaceValidValue)value; jComboBox.setSelectedItem(paceValidValue); } public Object getValue() { return jComboBox.getSelectedItem(); } public void stateChanged(ChangeEvent e) { firePropertyChange(); } public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox)e.getSource(); this.setValue(cb.getSelectedItem()); } }
The reason I belive its not getting binded is I have a validation rule on each of the two fields using the PropertyEditor of requried yet no matter if I selected an Item out of the list of the comboBox the fields' invalid decorator icon remains on the screen.Code:public class CreateOffenderFormPageOffender extends AbstractForm { public static final String OFFENDER_PAGE = "offenderPage"; private IdentificationSupport identificationSupport; /** Creates a new instance of CreateOffenderFormPageOffender */ public CreateOffenderFormPageOffender(FormModel formModel) { super(formModel, OFFENDER_PAGE); } protected JComponent createFormControl() { JComponent[] jcomponent; JLabel jlabel; JComboBox jcomboBox; // builder.addSeparator("separator.addressDetails"); TableFormBuilder formBuilder = new TableFormBuilder(getFormModel()); registerCustomEditors(); formBuilder.add("iincarcerationNumber"); formBuilder.add("isrg"); formBuilder.add("ijobCode","colspan=1"); formBuilder.row(); formBuilder.add("iinmateId"); formBuilder.add("ipinNo"); formBuilder.add("ibciNumber"); formBuilder.add("icommConfEligDate"); formBuilder.row(); formBuilder.add("ifirstName"); formBuilder.add("iminit"); formBuilder.add("ilastName"); formBuilder.add("isuffix"); formBuilder.row(); formBuilder.add("idob","colspan=1"); jcomponent = formBuilder.add("isexPvv","colspan=1"); jcomboBox = (JComboBox)jcomponent[1]; jcomboBox.setEditable(false); jcomponent = formBuilder.add("iclassCodePvv","colspan=3"); jcomboBox = (JComboBox)jcomponent[1]; jcomboBox.setEditable(false); return formBuilder.getForm(); } private void registerCustomEditors() { identificationSupport = (IdentificationSupport)this.getFormObject(); getFormModel().registerCustomEditor("isexPvv", new PaceValidValuePropertyEditor(identificationSupport .getIsexList())); getFormModel().registerCustomEditor("iclassCodePvv", new PaceValidValuePropertyEditor(identificationSupport .getIclassCodeList())); } }
So the Question is what am I doing wrong????


Reply With Quote