Validation in swing using struts-like approach

S

sarath

I have a swings application, which includes a lot of validations in
the client side. When ever I add a new functionality to the same, some
of the validations in the applications breaks.
I am looking for validation method like in struts, where we can
mention all the validation scenarios in an XML or a config file, and
the validation happens as mentioned in that file.
It requries that the validations should be done in the client side
rather than the server side (Like in ActionForm in struts)
Is it possible to have such an approach?
Can I use ActionForm itself in some way for the same?

Regards
Sarath
 
S

sarath

No, you don't.

First of all i really did not know about multiposting and cross
posting.. thanks for enlightening me on that.
and your tip.. that really worked..

sarath
 
L

Lew

sarath said:
I am looking for validation method like in struts, where we can
mention all the validation scenarios in an XML or a config file, and
the validation happens as mentioned in that file.
It requries that the validations should be done in the client side
rather than the server side (Like in ActionForm in struts)
Is it possible to have such an approach?
Can I use ActionForm itself in some way for the same?

I am not aware of a pre-existing framework to permit declarative validation
for Swing, but there may well be one.

I don't think ActionForms from Struts will give you a problem as such,
although you probably should not derive them from a Struts class but instead
use your own interface. I have done this myself for a few projects, most of
them from before I learned Struts. What you will not get this way is the
equivalent of the Struts controller servlet, that is, the dispatcher for the
UI event loop.

OTOH, ActionForms aren't inherently connected to declarative validation rules
anyway. That is something that the Struts framework takes care of; it parses
the validation declarations, including custom validation classes if specified,
in terms of predefined validator interfaces and classes within Struts. By the
time the controller invokes your ActionForm (or in more universal terms, the
action handler class), it's already loaded a bunch of classes and has methods
to call them to enforce the rules.

Swing itself follows a Model-View-Controller paradigm, same as Struts. The
rough equivalent to ActionForm is XxxListener. The EDT (Event Dispatch
Thread) is the equivalent of the Struts controller servlet.

It is likely that rich-client frameworks like Eclipse or Netbeans will give
you declarative validation. I am not familiar enough with either as a
rich-client platform to say for sure.

Java generally supports property sheets for JavaBeans, so that would let you
define validation via property files. You still need to define your own
property and value sets, and parse the properties in custom code, but it's not
hard to use beans this way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,185
Latest member
GluceaReviews

Latest Threads

Top