Validation of component composed from other components

  1 post   Feedicon  
Replies: 0 - Last Post: February 15, 2011 13:10
by: dstutz
showing 1 - 1 of 1
 
Posted: February 15, 2011 13:10 by dstutz
Can someone point me to the proper way to do this. I'm playing around with some simple test code to figure this out but can't seem to figure out the right way.

I currently have a JPanel with 2 textfields and another JPanel with 1 textarea. I am creating a JDialog with the 2 JPanels, a ValidationPanel and OK/Cancel buttons.

-The 2 panels and the dialog all implement the ValidationUI interface, the 2 panels don't do anything in their set/clear methods as they don't have any validation reporting on their own. The Dialog's set/clearproblem methods set enabled state of the OK button.

-The 2 panels implement ValidationGroupProvider so I can get their groups in the Dialog and add them to the Dialog's group.

-In the 2 panels I create the ValidationGoup with ValidationGroup.create(this). In the Dialog I get the group from the ValidationPanel and add the group from each sub-panel to this group

-Another way I've tried of creating the ValidationGroup in the Panels is not implementing ValidationUI and creating a ValidationPanel but not adding it to the panel and getting the VG from the VP.

My problem is that when the Dialog is first shown, it correctly shows errors for the 2 textfields on panel1 and the textarea on panel 2, the ValidationPanel has the error message for the textarea "may not be empty". If I put some text into the textarea, the error is cleared for that component and the OK button is enabled incorrectly even though both textfield's in panel 1 are still empty. I have to type text into both textfields in panel1 to clear the errors and go back to the textarea on panel2 for the validation of the whole dialog to work and be chained together as I expect.

Edit: To clarify a bit. Something is calling clearProblem on the outer Dialog even though there are still problems in the ValidationGroup.
Replies: 0 - Last Post: February 15, 2011 13:10
by: dstutz
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close