You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Vincent Berruchon <vi...@neo-logism.fr> on 2002/09/24 18:06:55 UTC

Re: Using data-source with ActionForm - MVC2

Just a word about MVC2 and what I've read about it:
  MVC2 is the evolution of the MVC model, the main difference seem to be 
  the preference for an unique controller module (a unique controller 
servlet with Struts),
because in first versions of the Model View Controller, MVC, most of the 
time many modules acted as controllers.
MVC2 is also called Model 2...

I'm not an expert, but it seems that MVC2 means something even if we 
often talk now about MVC in place of MVC2

Thanks for your answer
Vincent


Galbreath, Mark wrote:
> First, there's no such thing as "MVC2 Model."  It's "MVC" or, when applied
> to web apps, "Model 2."  This is clearly explained in the Struts'
> Introduction on the Jakarta website.
> 
> Accessing the database from an ActionForm does not violate MVC, but it does
> violate standard usage of JavaBeans and is generally not a good idea from a
> maintenance perspective.  If you need to pre-set an ActionForm's state, have
> your associated Action class do it by calling an EJB session bean or DAO
> (data access object). Read the Struts User Guide and get hold of a copy of
> (at least) Alur, et al, "Core J2EE Patterns" (Sun/PrenticeHall 2001).
> 
> Mark
> 
> -----Original Message-----
> From: Vincent Berruchon [mailto:vincent.berruchon@neo-logism.fr]
> Sent: Friday, September 20, 2002 11:12 AM
> To: Struts Users Mailing List
> Subject: Re: Using data-source with ActionForm
> 
> 
> SHould I avoid to access database in the getXXX methods of an ActionForm 
> to respect MVC2 model?
> 
> Vincent Berruchon wrote:
> 
>>    Hello,
>>I'm a newbie with Struts, I'd like to know how I could smartly use 
>>data-source to fill things like "select" drop down combo in my forms.
>>
>>here what I'm trying to do, can you tell me if I'm wrong:
>>
>>I'v defined a data-source in struts-config.xml to use a mySql DB.
>>I'd like to get data from this DB to fill inputs fields in my forms.
>>
>>So I suppose I could get a connection in data-source pool in each of the 
>>                   "getMyProperty" of my actionForm methods and get the 
>>data that will fill HTML/JSP input...
>>
>>something like that:
>>   DataSource dataSource = (DataSource)
>>   servlet.getServletContext().getAttribute("mysql");
>>   Connection conn = dataSource.getConnection();
>>
>>but it seems to be a bit expensive to get a connection in each "getXXX" 
>>methods...(i'll do the same things several times for one actionForm 
>>use/1 request) where can I place the getConnection to use it in methods 
>>of my actionForm (1 connection for 1 actionForm use/1 request)
>>
>>Tell me if there's something I didn't understand.
>>
>>Thanx
>>Vincent
>>
>>
>>-- 
>>To unsubscribe, e-mail:   
>><ma...@jakarta.apache.org>
>>For additional commands, e-mail: 
>><ma...@jakarta.apache.org>
>>
>>
>>
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>