Shasirekha Engala wrote:
Hi,
I want some information regarding the difference between DynaActionforms
and ActionForms and advantages of DynaActionforms over ActionForms. I need
the code of subclassing the dynaforms and using it. For example, I am having
a BaseForm with the variables pageno( page number), action (action to be
performed like save, update, delete, create). This form I have declared
in struts-config.xml. Now all the other forms I am creating should extend my
BaseForm. How can I do this using DynaActionForms in struts-config.xml?
Kindly reply to this mail as soon as possible as it is bit urgent.
The main point of DynaActionForm and friends is so that you can
configure form beans in your struts-config.xml without having to write
any supporting code. Unfortunately, in 1.2.x, there's no mechanism to
achieve what you want.
The good news is that this feature is one of the things that 1.3.x adds.
You can do something like this:
... properties ...
... more properties ...
There isn't yet a release of Struts Action 1.3, though it's getting
close. In the meantime, you'd need to use a nightly build.
If that's not acceptable for your project, you have at least a couple of
other options. One is simply to copy-paste the common properties into
each form-bean declaration, which isn't great but may be OK if you only
have a few common properties. Another, which is really just a refinement
of the first option, is to use a bit of XML trickery.
Basically, you'd add an internal DTD subset declaring an entity with
your common form-bean properties:
...
"]>
Then, in your form-bean declarations, you include the entity:
&common-props;
... more properties ...
Obviously, the Struts Action 1.3 'extends' feature is by far the cleaner
way to go if you can justify using a pre-release version.
L.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]