|
|
Where is new createBoundComboBox(String,ValueModel, String)?
mon.client.ui.NewElementWizard.execute#40;NewElementWizard.java#58;74#41;
at org..richclient.command.TargetableActionCommand.doExecuteCommand#40;TargetableActionCommand.java#58;102#41;
at org..richclient.command.ActionCommand.execute#40;ActionCommand.java#58;188#41;
at org..richclient.command.ActionCommand$1.actionPerformed#40;ActionCommand.java#58;123#41;
at javax.swing.AbstractButton.fireActionPerformed#40;AbstractButton.java#58;1786#41;I've added the missing method to SwingBindingFactory which should fix your problem with the the cities combo box.
The reason it's not working for you at the moment is because your trying to directly modify the binding which is not supported. If you want to interact with the binding process you'd do it like this:
Code: Map context = new HashMap#40;#41;; context.put#40;ComboBoxBinder.SELECTABLE_ITEMS_HOLDER_KEY, this.citiesModel#41;;#41;; context.put#40;ComboBoxBinder.RENDERER_KEY, new BeanPropertyValueListRenderer#40;quot;namequot;#41;#41;; ComboBoxBinding bCities = #40;ComboBoxBinding#41; factory.createBinding#40;JComboBox.class, quot;cityquot;, context#41;;
To be honest, I'm not entierly happy with this binding context Map, so it's interesting to see the way you've attempted to solve this problem this.
I'm not sure about the CCE. I'd need to find out what the types of the objects going into the ValueObject.equals method are.
Ollie
puteLayoutSize#40;FormLayout.java#58;1075#41;
at com.jgoodies.forms.layout.FormLayout.preferredLayoutSize#40;FormLayout.java#58;912#41;
at java.awt.Container.preferredSize#40;Container.java#58;1178#41;
at java.awt.Container.getPreferredSize#40;Container.java#58;1162#41;
at javax.swing.JComponent.getPreferredSize#40;JComponent.java#58;1277#41;
at org..richclient.wizard.WizardDialog.createPageControls#40;WizardDialog.java#58;130#41;
at org..richclient.wizard.WizardDialog.createTitledDialogContentPane#40;WizardDialog.java#58;84#41;
at org..richclient.dialog.TitledApplicationDialog.createDialogContentPane#40;TitledApplicationDialog.java#58;132#41;
at org..richclient.dialog.TitledApplicationDialog.addDialogComponents#40;TitledApplicationDialog.java#58;120#41;
at org..richclient.dialog.ApplicationDialog.createDialog#40;ApplicationDialog.java#58;288#41;
at org..richclient.dialog.ApplicationDialog.showDialog#40;ApplicationDialog.java#58;258#41;
at com.wplex.common.client.ui.NewElementWizard.execute#40;NewElementWizard.java#58;74#41;
at org..richclient.command.TargetableActionCommand.doExecuteCommand#40;TargetableActionCommand.java#58;102#41;
at org..richclient.command.ActionCommand.execute#40;ActionCommand.java#58;188#41;
at org..richclient.command.ActionCommand$1.actionPerformed#40;ActionCommand.java#58;123#41;
at javax.swing.AbstractButton.fireActionPerformed#40;AbstractButton.java#58;1786#41;
Instead of this, if a use binding creation with the new context, all works perfectly!Code: /** * @return JComboBox com estados. */ private JComponent createStatesField#40;#41; #123; ... code ... code ... SwingBindingFactory factory = #40;SwingBindingFactory#41; getBindingFactory#40;#41;;
Map context = new HashMap#40;#41;; context.put#40;ComboBoxBinder.SELECTABLE_ITEMS_HOLDER_KEY,statesHolder#41;; JComboBox jcbStates = #40;JComboBox#41;factory.createBinding#40;JComboBox.class, quot;city.statequot;, context#41;.getControl#40;#41;; ... code ... code ... #125;
/** * @return JComboBox com cidades. */ private JComponent createCitiesField#40;#41; #123; ValueModel statesModel = getFormModel#40;#41;.getValueModel#40;quot;city.statequot;#41;; //$NON-NLS-1$ String sState = #40;String#41; statesModel.getValue#40;#41;; try #123;State state = this.delegate.findStateByCode#40;sState#41;;Collection colCities = this.delegate.findCities#40;state#41;;this.citiesModel.setValue#40;colCities#41;; #125; catch #40;WplexError e#41; #123;JOptionPane .showMessageDialog#40;this.getControl#40;#41;, e.getMessage#40;#41;#41;; #125;
SwingBindingFactory factory = #40;SwingBindingFactory#41; getBindingFactory#40;#41;; Map context = new HashMap#40;#41;; context.put#40;ComboBoxBinder.SELECTABLE_ITEMS_HOLDER_KEY,this.citiesModel#41;; context.put#40;ComboBoxBinder.RENDERER_KEY,new BeanPropertyValueListRenderer#40;quot;namequot;#41;#41;; ComboBoxBinding bCities = #40;ComboBoxBinding#41; factory.createBinding#40;JComboBox.class, quot;cityquot;, context#41;; return bCities.getControl#40;#41;; #125;
I think the binding context map is a good idea if you would like to do a custom binding creation, but I think the specifics bound creation methods like SwingBindingFactory.createBoundComboBox(String,Val ueModel, String) should to do the full job, like create the formValueModel if it doesn't exists yet. That will prevent some bugs and the programmed to do it manualy.
BTW, previously the fields validations happens when typing in the field, now happens when field lost the focus. How can I change this?
Thanks,
Mauro.
If I use the new SwingBindingFactory.createBoundComboBox(String,Val ueModel, String) an NPE happens when loading my NewQuarterWinzard class.
The BeanPropertyValueListRenderer.getTextValue(Object) is returning null because the propertyName of class is null. I think it should be quot;city.statequot;. So, BeanWrapperImpl.getNestedPropertySeparatorIndex(St ring propertyPath, boolean) is receiving null propertyPath.
It's because you're passing null in as the renderedItemProperty, this is not supported. I'll add another method createBoundComboBox(String,ValueModel).
Ollie
Originally Posted by oliverhutchisonIt's because you're passing null in as the renderedItemProperty, this is not supported. I'll add another method createBoundComboBox(String,ValueModel).
Ollie
Thank you so much Ollie!
About the fields validation, some tip?
Originally Posted by ManusBTW, previously the fields validations happens when typing in the field, now happens when field lost the focus. How can I change this?
Mauro.
Mauro, FormattedTextFieldBinding needs work. Basically I wouldn't recommend using a JFormttatedTextField unless you absolutely have too, as they cause problems for validation etc... Once this conferance I'm working for is over I'll post some more.
Ollie |
|