Quoting dumdum 420 <[EMAIL PROTECTED]>: > Hi All, > > I want to create a DynaClass instance on the loadup of my application so > that I can use the instance of the DynaClass and use the > DynaClass.newInstance() method to get the particular DynaBean instance. > > The most suitable way to do the same would be thru a XML file which is > parsed at the startup time. > This is the same concept which is used by the Struts1.1 also for there > DynaActionForm. > > Now can anyone tell me how to do this XML parsing using commons.Digester to > achive the resutls or there is some kind of DynaBeanBuilder already coded > which reads the XML and stores the DynaClass reference in the memory which > will then help to create as many instances of the DynaBean to created on the > > basis of the type of the DynaClass locaded. > > This is an example of the .xml file as I am visualizing ... > > > <dyna-bean name="ChangePasswordTO" > type="org.apache.commons.beanutils.DynaBean "> > <form-property name="oldPassword" type="java.lang.String" > initValue="password"/> > <form-property name="password1" type="java.lang.String" /> > <form-property name="password2" type="java.lang.String" /> > </dyna-bean> > > If I am not clear please do let me know. Thanx in advance. >
You might get some useful inspiration by looking at the code in Struts that actually does this sort of thing. You can grab the source bundle from a recent nightly build at: http://cvs.apache.org/builds/jakarta-struts/nightly/ The Digester rules for reading struts-config.xml are set up in class "org.apache.struts.config.ConfigRuleSet" (look for rule patterns that begin with "struts-config/form-beans"), and the FormBeanConfig and FormPropertyConfig bean classes are in the same package. The actual factory for form bean instances is the createActionForm() method in org.apache.struts.util.RequestUtils that takes a FormBeanConfig and an ActionServlet. > Bhanu Pabreja > Craig --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
