You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "R.Vijayaraghavan" <rv...@cdacnoida.in> on 2006/02/28 10:10:49 UTC

which method is better

Hello,

I usually have set and get methods for all properties in my Model class.
After submitting a form, I pull out all the property values (form fields) in
the Action class from the ActionForm object, set the values of all
properties in the model from the action class and then call a particular
method in the model class for final submission to the database.

I wanted to know thether the above mentioned method is better or is it
better to pass the form reference itself to the Model class which then sets
the values.

In situation 2, I do not have to take care of the various String references
that I create. I simply will pass the ActionForm object to the Model class.

regards,
vijay.



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] The M in MVC (WAS: which method is better)

Posted by Michael Jouravlev <jm...@gmail.com>.
On 2/28/06, Antonio Petrelli <br...@tariffenet.it> wrote:
> R.Vijayaraghavan ha scritto:
> > Hello,
> >
> > I usually have set and get methods for all properties in my Model class.
> > After submitting a form, I pull out all the property values (form fields) in
> > the Action class from the ActionForm object, set the values of all
> > properties in the model from the action class and then call a particular
> > method in the model class for final submission to the database.
> >
> > I wanted to know thether the above mentioned method is better or is it
> > better to pass the form reference itself to the Model class which then sets
> > the values.
> >
> > In situation 2, I do not have to take care of the various String references
> > that I create. I simply will pass the ActionForm object to the Model class.

Or, you can simply set your business object as a property of an
ActionForm, and use session-scoped ActionForm to retain value of
business object in between requests.

Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


[OT] The M in MVC (WAS: which method is better)

Posted by Antonio Petrelli <br...@tariffenet.it>.
R.Vijayaraghavan ha scritto:
> Hello,
>
> I usually have set and get methods for all properties in my Model class.
> After submitting a form, I pull out all the property values (form fields) in
> the Action class from the ActionForm object, set the values of all
> properties in the model from the action class and then call a particular
> method in the model class for final submission to the database.
>
> I wanted to know thether the above mentioned method is better or is it
> better to pass the form reference itself to the Model class which then sets
> the values.
>
> In situation 2, I do not have to take care of the various String references
> that I create. I simply will pass the ActionForm object to the Model class.
>
> regards,
> vijay.
>
>
>   

Ok I think we all should take a breath. Essentially there is not a 
"best" practice in how the controller should call the model.
There are various techniques (session façades, business delegates, 
IoC...) but anyway the controller is responsible to call the model.
All of these techniques, anyway, show their purpose to hide the fact 
that the model is used by a web-app.
 From my point of view, I think that IoC is the best way to call the 
model, because it reduces the levels of indirection in a cleaner way, 
but you have to use Spring or another IoC engine.
Anyway notice that the ActionForm is part of Struts and should not be 
referenced inside your model (though I once used it as a simple bean and 
took away its
property values by using BeanUtils, I don't know how correct it is...)

Just my 2 eurocents
Ciao
Antonio Petrelli

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: which method is better

Posted by Mark Lowe <me...@gmail.com>.
On 2/28/06, R.Vijayaraghavan <rv...@cdacnoida.in> wrote:
> I do something like:
>
> public class ProductAction extends Action
> {
>         execute()
>         {
>                 String name = (String)PropertyUtils.getSimpleProperty(form, "name");
>                 String age = (String)PropertyUtils.getSimpleProperty(form, "age");
>                 ProductModel model = new ProductModel();
>                 model.setName(name);
>                 model.setAge(age);
>                 model.saveToPersistentStore();
>         }
> }
>
> I was wondering if the ActionForm can be used as a DTO. Something like this,
>
> public class ProductAction extends Action
> {
>         execute()
>         {
>                 ProductModel model = new ProductModel();
>                 model.setForm(form);    //      action form reference which the execute method
> gets
>                 model.saveToPersistentStore();
>         }
> }
>
> I do not know which method will be better. I don't even know if there is any
> other technique we should follow as Oshima pointed it.

Passing an action form to the model is considered a bad move as you
are coupling your model to struts. The idea being that your may want
to change the view technology. Usually folk suggest having some
helper/util classes that convert forms to business objects, BeanUtils
is often enough when your form properties are the same as your
business object properties.

Mark

>
> regards,
> vijay.
>
>
> > -----Original Message-----
> > From: Oshima Tlholoe [mailto:oshimat@gmail.com]
> > Sent: Tuesday, February 28, 2006 2:53 PM
> > To: Struts Users Mailing List
> > Subject: Re: which method is better
> >
> >
> > With my rudimentary knowledge,I dont think its advisable for your Action
> > classes to talk directly to your business layer/model classes,
> > Why don't you
> > have a business delegate/session facade or Service Locator sitting between
> > your Action Classes and the model classes, this insulates your action
> > classes from your business layer and it even makes testing
> > simpler. You not
> > going to have test cases that span multiple layers.
> > Let your Actions pull out data from the ActionForm, wrap it and pass it to
> > the Service Locator, then the Service Locator then handles the
> > rest, calling
> > all the related model classes.
> >
> >
> >
> > On 2/28/06, R.Vijayaraghavan <rv...@cdacnoida.in> wrote:
> > >
> > > Hello,
> > >
> > > I usually have set and get methods for all properties in my Model class.
> > > After submitting a form, I pull out all the property values
> > (form fields)
> > > in
> > > the Action class from the ActionForm object, set the values of all
> > > properties in the model from the action class and then call a particular
> > > method in the model class for final submission to the database.
> > >
> > > I wanted to know thether the above mentioned method is better or is it
> > > better to pass the form reference itself to the Model class which then
> > > sets
> > > the values.
> > >
> > > In situation 2, I do not have to take care of the various String
> > > references
> > > that I create. I simply will pass the ActionForm object to the Model
> > > class.
> > >
> > > regards,
> > > vijay.
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> >
> > --
> > Regards
> > Name : Oshima Tlholoe
> > Cell No: +2773 342 4393
> > Tel No : +2712 841 4355(w)
> > E-mail : oshimat@gmail.com
> > simplicity is the ultimate sophistication
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Some inputs are welcome ****

Posted by Angelo zerr <an...@gmail.com>.
Hi thomas,
which component do you use for generate your tabs?
Do you use specific taglib, like struts-layout tabs or ditchnet tabs, or do
you develop
your own taglib ? Perhaps, your tabs can support EL tags. If so you could do
<c:if test="${myCondition}" />
  <myTab:tab .....
</c:if>
For information, I'm developping JSPTabControl component project.
But today it doesn't exist. I will try to developp something which can
support
EL condition.

Regards
Angelo




2006/2/28, Sony Thomas <so...@genialgenetics.com>:
>
> Hi,
>
> I am using tabs in my JSP. Now when I display tabs I have to check for
> some conditions. But the tabs will not allow me to use Scriptlets <%  %>
> inside the tabs. so is there is any struts tag library tags for
> shortcircuit logical operators. I mean for && and || . If anyone has any
> idea please help.
>
>
> Thanks in advance,
>
> sony
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Some inputs are welcome ****

Posted by Sony Thomas <so...@genialgenetics.com>.
Hi,

I am using tabs in my JSP. Now when I display tabs I have to check for 
some conditions. But the tabs will not allow me to use Scriptlets <%  %> 
inside the tabs. so is there is any struts tag library tags for 
shortcircuit logical operators. I mean for && and || . If anyone has any 
idea please help.


Thanks in advance,

sony

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: which method is better

Posted by Mark Lowe <me...@gmail.com>.
On 2/28/06, R.Vijayaraghavan <rv...@cdacnoida.in> wrote:
> I am not using EJB. The model is made using simple JDBC that gets the
> database connection from a helper class which uses JNDI to get the JDBC data
> source.
>
> How can I apply Session Facade here. Is there any text or code examples
> which I can read that talks the same with relation to struts.

The most straight forward way would be to have a class with all your
JDBC in. If you don't want to write a bunch of domain objects/entities
then you could pass hashmaps to your action.

public class DatabaseService {
     public Map findUserById(Long id) {
        //get your jndi connection  and populate a map from the resultset
     }
}

in your action

DatabaseService service = new DatabaseService();
Map user = service.findUserById(id);
UserForm theForm = (UserForm) form;
BeanUtils.populate(theForm,user);

Of course using some properly typed objects for your model might be
preferable but Maps will do the job. Spring will give you a clear path
to achieving this, and better than my example, but this will give you
a way of defining your fasade and a path to unit testing your jdbc
code separate to your actions etc.

There are more optimisations you can do, and improvements to the
example I've given, but this is basically what folk are talking about.

Its also true that for your application it might be perfectly okay to
do jdbc stuff in your actions, this will make it less unit testable
and so on, but sometimes blue prints and patterns can be overkill.
Having your jdbc exceptions in your action allows you to pass messages
back to the view in a easy manner.

try {
   //do some jdbc
} catch (SQLException e) {
    ActionMessages messages = ..
    saveErrors(...)..
}

The disadvantages of doing this however is the fact that unit testing
is harder and your actions get kinda long. But its not always the root
of all evil as some would have one believe.

Mark

>
> regards,
> vijay.
>
> > -----Original Message-----
> > From: Oshima Tlholoe [mailto:oshimat@gmail.com]
> > Sent: Tuesday, February 28, 2006 2:53 PM
> > To: Struts Users Mailing List
> > Subject: Re: which method is better
> >
> >
> > With my rudimentary knowledge,I dont think its advisable for your Action
> > classes to talk directly to your business layer/model classes,
> > Why don't you
> > have a business delegate/session facade or Service Locator sitting between
> > your Action Classes and the model classes, this insulates your action
> > classes from your business layer and it even makes testing
> > simpler. You not
> > going to have test cases that span multiple layers.
> > Let your Actions pull out data from the ActionForm, wrap it and pass it to
> > the Service Locator, then the Service Locator then handles the
> > rest, calling
> > all the related model classes.
> >
> >
> >
> > On 2/28/06, R.Vijayaraghavan <rv...@cdacnoida.in> wrote:
> > >
> > > Hello,
> > >
> > > I usually have set and get methods for all properties in my Model class.
> > > After submitting a form, I pull out all the property values
> > (form fields)
> > > in
> > > the Action class from the ActionForm object, set the values of all
> > > properties in the model from the action class and then call a particular
> > > method in the model class for final submission to the database.
> > >
> > > I wanted to know thether the above mentioned method is better or is it
> > > better to pass the form reference itself to the Model class which then
> > > sets
> > > the values.
> > >
> > > In situation 2, I do not have to take care of the various String
> > > references
> > > that I create. I simply will pass the ActionForm object to the Model
> > > class.
> > >
> > > regards,
> > > vijay.
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> >
> > --
> > Regards
> > Name : Oshima Tlholoe
> > Cell No: +2773 342 4393
> > Tel No : +2712 841 4355(w)
> > E-mail : oshimat@gmail.com
> > simplicity is the ultimate sophistication
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: which method is better

Posted by Oshima Tlholoe <os...@gmail.com>.
If you not using EJB,then i'll find out how u can use Session Facade without
EJBs,i only know how to use Session Facade with EJBs.
tnx

On 2/28/06, R.Vijayaraghavan <rv...@cdacnoida.in> wrote:
>
> I am not using EJB. The model is made using simple JDBC that gets the
> database connection from a helper class which uses JNDI to get the JDBC
> data
> source.
>
> How can I apply Session Facade here. Is there any text or code examples
> which I can read that talks the same with relation to struts.
>
> regards,
> vijay.
>
> > -----Original Message-----
> > From: Oshima Tlholoe [mailto:oshimat@gmail.com]
> > Sent: Tuesday, February 28, 2006 2:53 PM
> > To: Struts Users Mailing List
> > Subject: Re: which method is better
> >
> >
> > With my rudimentary knowledge,I dont think its advisable for your Action
> > classes to talk directly to your business layer/model classes,
> > Why don't you
> > have a business delegate/session facade or Service Locator sitting
> between
> > your Action Classes and the model classes, this insulates your action
> > classes from your business layer and it even makes testing
> > simpler. You not
> > going to have test cases that span multiple layers.
> > Let your Actions pull out data from the ActionForm, wrap it and pass it
> to
> > the Service Locator, then the Service Locator then handles the
> > rest, calling
> > all the related model classes.
> >
> >
> >
> > On 2/28/06, R.Vijayaraghavan <rv...@cdacnoida.in> wrote:
> > >
> > > Hello,
> > >
> > > I usually have set and get methods for all properties in my Model
> class.
> > > After submitting a form, I pull out all the property values
> > (form fields)
> > > in
> > > the Action class from the ActionForm object, set the values of all
> > > properties in the model from the action class and then call a
> particular
> > > method in the model class for final submission to the database.
> > >
> > > I wanted to know thether the above mentioned method is better or is it
> > > better to pass the form reference itself to the Model class which then
> > > sets
> > > the values.
> > >
> > > In situation 2, I do not have to take care of the various String
> > > references
> > > that I create. I simply will pass the ActionForm object to the Model
> > > class.
> > >
> > > regards,
> > > vijay.
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> >
> > --
> > Regards
> > Name : Oshima Tlholoe
> > Cell No: +2773 342 4393
> > Tel No : +2712 841 4355(w)
> > E-mail : oshimat@gmail.com
> > simplicity is the ultimate sophistication
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


--
Regards
Name : Oshima Tlholoe
Cell No: +2773 342 4393
Tel No : +2712 841 4355(w)
E-mail : oshimat@gmail.com
simplicity is the ultimate sophistication

RE: which method is better

Posted by "R.Vijayaraghavan" <rv...@cdacnoida.in>.
I do something like:

public class ProductAction extends Action
{
	execute()
	{
		String name = (String)PropertyUtils.getSimpleProperty(form, "name");
		String age = (String)PropertyUtils.getSimpleProperty(form, "age");
		ProductModel model = new ProductModel();
		model.setName(name);
		model.setAge(age);
		model.saveToPersistentStore();
	}
}

I was wondering if the ActionForm can be used as a DTO. Something like this,

public class ProductAction extends Action
{
	execute()
	{
		ProductModel model = new ProductModel();
		model.setForm(form);	//	action form reference which the execute method
gets
		model.saveToPersistentStore();
	}
}

I do not know which method will be better. I don't even know if there is any
other technique we should follow as Oshima pointed it.

regards,
vijay.


> -----Original Message-----
> From: Oshima Tlholoe [mailto:oshimat@gmail.com]
> Sent: Tuesday, February 28, 2006 2:53 PM
> To: Struts Users Mailing List
> Subject: Re: which method is better
>
>
> With my rudimentary knowledge,I dont think its advisable for your Action
> classes to talk directly to your business layer/model classes,
> Why don't you
> have a business delegate/session facade or Service Locator sitting between
> your Action Classes and the model classes, this insulates your action
> classes from your business layer and it even makes testing
> simpler. You not
> going to have test cases that span multiple layers.
> Let your Actions pull out data from the ActionForm, wrap it and pass it to
> the Service Locator, then the Service Locator then handles the
> rest, calling
> all the related model classes.
>
>
>
> On 2/28/06, R.Vijayaraghavan <rv...@cdacnoida.in> wrote:
> >
> > Hello,
> >
> > I usually have set and get methods for all properties in my Model class.
> > After submitting a form, I pull out all the property values
> (form fields)
> > in
> > the Action class from the ActionForm object, set the values of all
> > properties in the model from the action class and then call a particular
> > method in the model class for final submission to the database.
> >
> > I wanted to know thether the above mentioned method is better or is it
> > better to pass the form reference itself to the Model class which then
> > sets
> > the values.
> >
> > In situation 2, I do not have to take care of the various String
> > references
> > that I create. I simply will pass the ActionForm object to the Model
> > class.
> >
> > regards,
> > vijay.
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> --
> Regards
> Name : Oshima Tlholoe
> Cell No: +2773 342 4393
> Tel No : +2712 841 4355(w)
> E-mail : oshimat@gmail.com
> simplicity is the ultimate sophistication
>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: which method is better

Posted by "R.Vijayaraghavan" <rv...@cdacnoida.in>.
I am not using EJB. The model is made using simple JDBC that gets the
database connection from a helper class which uses JNDI to get the JDBC data
source.

How can I apply Session Facade here. Is there any text or code examples
which I can read that talks the same with relation to struts.

regards,
vijay.

> -----Original Message-----
> From: Oshima Tlholoe [mailto:oshimat@gmail.com]
> Sent: Tuesday, February 28, 2006 2:53 PM
> To: Struts Users Mailing List
> Subject: Re: which method is better
>
>
> With my rudimentary knowledge,I dont think its advisable for your Action
> classes to talk directly to your business layer/model classes,
> Why don't you
> have a business delegate/session facade or Service Locator sitting between
> your Action Classes and the model classes, this insulates your action
> classes from your business layer and it even makes testing
> simpler. You not
> going to have test cases that span multiple layers.
> Let your Actions pull out data from the ActionForm, wrap it and pass it to
> the Service Locator, then the Service Locator then handles the
> rest, calling
> all the related model classes.
>
>
>
> On 2/28/06, R.Vijayaraghavan <rv...@cdacnoida.in> wrote:
> >
> > Hello,
> >
> > I usually have set and get methods for all properties in my Model class.
> > After submitting a form, I pull out all the property values
> (form fields)
> > in
> > the Action class from the ActionForm object, set the values of all
> > properties in the model from the action class and then call a particular
> > method in the model class for final submission to the database.
> >
> > I wanted to know thether the above mentioned method is better or is it
> > better to pass the form reference itself to the Model class which then
> > sets
> > the values.
> >
> > In situation 2, I do not have to take care of the various String
> > references
> > that I create. I simply will pass the ActionForm object to the Model
> > class.
> >
> > regards,
> > vijay.
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> --
> Regards
> Name : Oshima Tlholoe
> Cell No: +2773 342 4393
> Tel No : +2712 841 4355(w)
> E-mail : oshimat@gmail.com
> simplicity is the ultimate sophistication
>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: which method is better

Posted by Oshima Tlholoe <os...@gmail.com>.
With my rudimentary knowledge,I dont think its advisable for your Action
classes to talk directly to your business layer/model classes, Why don't you
have a business delegate/session facade or Service Locator sitting between
your Action Classes and the model classes, this insulates your action
classes from your business layer and it even makes testing simpler. You not
going to have test cases that span multiple layers.
Let your Actions pull out data from the ActionForm, wrap it and pass it to
the Service Locator, then the Service Locator then handles the rest, calling
all the related model classes.



On 2/28/06, R.Vijayaraghavan <rv...@cdacnoida.in> wrote:
>
> Hello,
>
> I usually have set and get methods for all properties in my Model class.
> After submitting a form, I pull out all the property values (form fields)
> in
> the Action class from the ActionForm object, set the values of all
> properties in the model from the action class and then call a particular
> method in the model class for final submission to the database.
>
> I wanted to know thether the above mentioned method is better or is it
> better to pass the form reference itself to the Model class which then
> sets
> the values.
>
> In situation 2, I do not have to take care of the various String
> references
> that I create. I simply will pass the ActionForm object to the Model
> class.
>
> regards,
> vijay.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


--
Regards
Name : Oshima Tlholoe
Cell No: +2773 342 4393
Tel No : +2712 841 4355(w)
E-mail : oshimat@gmail.com
simplicity is the ultimate sophistication

Re: which method is better

Posted by Sony Thomas <so...@genialgenetics.com>.
Hi,

Seding formbean to model is not a good idea. why cant you use 
Beanutils.copyproperties method to copy values from your form to model.

sony


vasumathi wrote:
> If you want to submit all the values to database, you can pass form ref.
> but in case of submitting one or two values to database, what is the need of 
> sending form ref, we can pass those values itself.
>
>   
>> Hello,
>>
>> I usually have set and get methods for all properties in my Model class.
>> After submitting a form, I pull out all the property values (form fields)
>> in
>> the Action class from the ActionForm object, set the values of all
>> properties in the model from the action class and then call a particular
>> method in the model class for final submission to the database.
>>
>> I wanted to know thether the above mentioned method is better or is it
>> better to pass the form reference itself to the Model class which then sets
>> the values.
>>
>> In situation 2, I do not have to take care of the various String references
>> that I create. I simply will pass the ActionForm object to the Model class.
>>
>> regards,
>> vijay.
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>     
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: which method is better

Posted by Shasirekha Engala <sh...@patni.com>.
sending form reference to the model is not the correct way as it will make
model dependent on the view.
do not send the formbean object till the model.

-----Original Message-----
From: vasumathi [mailto:vasumathi@koensoft.com]
Sent: Tuesday, February 28, 2006 5:19 PM
To: Struts Users Mailing List
Subject: Re: which method is better


If you want to submit all the values to database, you can pass form ref.
but in case of submitting one or two values to database, what is the need of
sending form ref, we can pass those values itself.

> Hello,
>
> I usually have set and get methods for all properties in my Model class.
> After submitting a form, I pull out all the property values (form fields)
> in
> the Action class from the ActionForm object, set the values of all
> properties in the model from the action class and then call a particular
> method in the model class for final submission to the database.
>
> I wanted to know thether the above mentioned method is better or is it
> better to pass the form reference itself to the Model class which then
sets
> the values.
>
> In situation 2, I do not have to take care of the various String
references
> that I create. I simply will pass the ActionForm object to the Model
class.
>
> regards,
> vijay.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: which method is better

Posted by vasumathi <va...@koensoft.com>.
If you want to submit all the values to database, you can pass form ref.
but in case of submitting one or two values to database, what is the need of 
sending form ref, we can pass those values itself.

> Hello,
> 
> I usually have set and get methods for all properties in my Model class.
> After submitting a form, I pull out all the property values (form fields)
> in
> the Action class from the ActionForm object, set the values of all
> properties in the model from the action class and then call a particular
> method in the model class for final submission to the database.
> 
> I wanted to know thether the above mentioned method is better or is it
> better to pass the form reference itself to the Model class which then sets
> the values.
> 
> In situation 2, I do not have to take care of the various String references
> that I create. I simply will pass the ActionForm object to the Model class.
> 
> regards,
> vijay.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org