I have a question...

What is meant in this case by Model 2? Just a set of JSP pages that are
using servlets for their actions? If not what else constitutes model 2? Just
using servlets are "controllers?" ie. directing navigation, fetching data
etc?


> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Kevin Duffey
> Sent: Monday, May 22, 2000 12:48 PM
> To: [EMAIL PROTECTED]
> Subject: XML mapping to objects - Model 2 architecture for config file.
>
>
> This may be a bit inappropriate for this group, but it follows on
> the heels
> of me implementing the Model 2 architecture we all have been discussing so
> much. I have a working Model 2, but, I want to read in my xml
> config file. I
> am using the sun/xml parser because we use it in a couple of places on our
> site. However, my first stab at reading in the XML into a DOM
> object, while
> its being read in, trying to get each element and its value (not
> attribute)
> has proven to be a pain in the butt.
>
> So, my question is, is there any way I can just create a class
> and have the
> XML parser map the right elements (by name) and place the values
> after those
> tags directly into an instance of an object? It would also need to be able
> to add items to a vector, or table of some sort. For example, my
> config file
> looks like so:
>
> <config>
>         <action>
>                 <name>Login</name>
>                 <class>com.bm.ui.actions.Login</class>
>                 <result name="Successful" page="/inside/home.jsp" />
>                 <result name="Error" page="/outside/login_error.jsp" />
>         </action>
>
>         <action>
>                 <name>Enroll</name>
>                 <class>com.bm.ui.actions.Enroll</class>
>                 <result name="Successful" page="/common/login_ok.jsp" />
>                 <result name="BadLogin" page="/common/enroll.jsp" />
>                 <result name="Error" page="/outside/enroll_error.jsp" />
>         </action>
> </config>
>
> So, if I have class like:
>
> public class ActionObject
> {
>   private String  actionName = "";
>   private String  actionClass = "";
>   private Hashmap results     = new Hashmap();
>
>   public ActionObject()
>   {
>   }
>
>   ... and so on ...
> }
>
> Is there a way to automatically get the XML document to map the <name>,
> <class> and <result name/page> tags and attributes and their
> values directly
> to an instance of the object..so that I can do something like:
>
> ... read XML document in...
> ActionObject ao = new ActionObject(XmlDoc);
> while( ao.hasMoreActions() )
> {
>   Object o = ao.nextAction();
>   mytable.add( o );
> }
>
>
> In sum, the few lines above would simply use my ContollerServlet
> (ServletContext) hashtable object that stores each action, to
> cycle through
> my own class (ActionObject) which when created was populated automatically
> (perhaps through reflection of xml to the object) with the xml
> config data,
> and now I am just looping through and adding it to the hash table.
> OFcourse..if ao contains the entire config tree..there is no need to do
> another table..this is all hypothetical..for the use to hopefully explain
> what I am trying to do.
>
> Thanks for anyone that can help.
>
> ==================================================================
> =========
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to