Retrieve multiple objects with MVC/FrontController for view in JSP.

I have made a MVC system (front-end only); a link call the url: ?page=createSomething to the FrontController, that is implemented as a Servlet, and then dispatch to createSomething.jsp. That抯 all fine, but I need to retrieve 2-3 list to use in dropdowns, and that抯 here I give up!

A simple scenario is to retrieve a single object eg a member: I call the url: ?page=viewmemeber&command=viewMemeber&id=5. The Servlet call a commandHandler witch return a member, use setAttribute(搈ember? member); and then dispatch to viewmember.jsp and use JSTL to view the member. That抯 all fine, as long I only need to set a single object or a list of objects.

The problem is now I want to create a member and need to retrieve 2-3 list to use in a dropdown when creating a member.. I can do a ?page=createmember&command=getAllCountries, but that will only allow a dropdown of countries.

Is the solution to use a command pattern and use: ?page=createmember&command=getAllCountrysAndCitysAnd?

My servlet

...

commandhandlerclass = Class.forName("controllers.CommandHandler");

commandhandlerobject = commandhandlerclass.newInstance();

Object arguments[] =new Object[]{ requestContextMap};

commandhandlermethod = commandhandlerclass.getMethod(

getString(requestContextMap,"command"),

new Class[]{ requestContextMap.getClass()}

);

commandhandlerreturndata = commandhandlermethod.invoke(commandhandlerobject, arguments);

...

request.setAttribute("bean", commandhandlerreturndata);

[1822 byte] By [aagaard1a] at [2007-10-3 11:07:29]
# 1

Hi Dear,

I think you want to create a member and in create member page you want two to three combo box.

If my understanding is right then you can create a wrapper method that get all required data like city,state,countries and return all that data as map or collection. After getting all that required data set it to request or whereever you like and forward request to the JSP page. Then in JSP page you can get all that data from the map (Country data, city data ...).

If you required help, i am ready for the same...

Regard

Patel Vinod

vinodpatel2006a at 2007-7-15 13:30:24 > top of Java-index,Other Topics,Patterns & OO Design...