You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Stephane Cosmeur <co...@gmail.com> on 2010/05/19 04:02:09 UTC

Create / Edit Form, Best practices

Hello,

My question is quite simple : what are the best practices to manage the edit
and create form who often are exactly the same. Do you usualy create two jsp
? Do you call an action who check if the object is in the DB or not. Maybe
some people use two diffrent action with two submit (seems difficult to me).
I know it's not a such important requirment but my application is barely
only composed of form and save / edit so i would to do it the best way.

Regards,

-- 
Stéphane Cosmeur

Re: Create / Edit Form, Best practices

Posted by Luis Martín Canaval Sánchez <ma...@gmail.com>.
yes, it is possible.

On Tue, May 18, 2010 at 23:22, Stephane Cosmeur <co...@gmail.com> wrote:

> Ok, thanks :)
>
> In the your action description, the method's name shouldnt be prepare()
> instead of input() ?
>
> Additional question : with this method, can you manage the info page with
> the same jsp. In other way, is it possible to set the property editable to
> false and remove the submit when needed.
>
> 2010/5/19 Luis Martín Canaval Sánchez <ma...@gmail.com>
>
> > I do the same as the example here
> > http://struts.apache.org/2.x/docs/struts-2-spring-2-jpa-ajax.html
> >
> > <http://struts.apache.org/2.x/docs/struts-2-spring-2-jpa-ajax.html
> > >basically
> > 1 form and a method input that tests an ID, if the id is given, then its
> a
> > edit form and its filled automatically with the data from teh old object
> to
> > be edited, otherwise it just shows an empty form.
> >
> > in struts.xml
> > ...
> > <result name="input">form.jsp</result>
> > ...
> >
> > in action class
> > public String input() {
> >  if(id != null) {
> >    pig = pigService.find(id);
> >  }
> >  return INPUT;
> > }
> >
> >
> > On Tue, May 18, 2010 at 21:02, Stephane Cosmeur <co...@gmail.com>
> wrote:
> >
> > > Hello,
> > >
> > > My question is quite simple : what are the best practices to manage the
> > > edit
> > > and create form who often are exactly the same. Do you usualy create
> two
> > > jsp
> > > ? Do you call an action who check if the object is in the DB or not.
> > Maybe
> > > some people use two diffrent action with two submit (seems difficult to
> > > me).
> > > I know it's not a such important requirment but my application is
> barely
> > > only composed of form and save / edit so i would to do it the best way.
> > >
> > > Regards,
> > >
> > > --
> > > Stéphane Cosmeur
> > >
> >
> >
> >
> > --
> > Ing. Luis Martín Canaval Sánchez
> > Keep it small and simple.
> >
>
>
>
> --
> Stéphane Cosmeur
>



-- 
Ing. Luis Martín Canaval Sánchez
Keep it small and simple.

Re: Create / Edit Form, Best practices

Posted by Stephane Cosmeur <co...@gmail.com>.
Ok, thanks :)

In the your action description, the method's name shouldnt be prepare()
instead of input() ?

Additional question : with this method, can you manage the info page with
the same jsp. In other way, is it possible to set the property editable to
false and remove the submit when needed.

2010/5/19 Luis Martín Canaval Sánchez <ma...@gmail.com>

> I do the same as the example here
> http://struts.apache.org/2.x/docs/struts-2-spring-2-jpa-ajax.html
>
> <http://struts.apache.org/2.x/docs/struts-2-spring-2-jpa-ajax.html
> >basically
> 1 form and a method input that tests an ID, if the id is given, then its a
> edit form and its filled automatically with the data from teh old object to
> be edited, otherwise it just shows an empty form.
>
> in struts.xml
> ...
> <result name="input">form.jsp</result>
> ...
>
> in action class
> public String input() {
>  if(id != null) {
>    pig = pigService.find(id);
>  }
>  return INPUT;
> }
>
>
> On Tue, May 18, 2010 at 21:02, Stephane Cosmeur <co...@gmail.com> wrote:
>
> > Hello,
> >
> > My question is quite simple : what are the best practices to manage the
> > edit
> > and create form who often are exactly the same. Do you usualy create two
> > jsp
> > ? Do you call an action who check if the object is in the DB or not.
> Maybe
> > some people use two diffrent action with two submit (seems difficult to
> > me).
> > I know it's not a such important requirment but my application is barely
> > only composed of form and save / edit so i would to do it the best way.
> >
> > Regards,
> >
> > --
> > Stéphane Cosmeur
> >
>
>
>
> --
> Ing. Luis Martín Canaval Sánchez
> Keep it small and simple.
>



-- 
Stéphane Cosmeur

Re: Create / Edit Form, Best practices

Posted by Luis Martín Canaval Sánchez <ma...@gmail.com>.
I do the same as the example here
http://struts.apache.org/2.x/docs/struts-2-spring-2-jpa-ajax.html

<http://struts.apache.org/2.x/docs/struts-2-spring-2-jpa-ajax.html>basically
1 form and a method input that tests an ID, if the id is given, then its a
edit form and its filled automatically with the data from teh old object to
be edited, otherwise it just shows an empty form.

in struts.xml
...
<result name="input">form.jsp</result>
...

in action class
public String input() {
  if(id != null) {
    pig = pigService.find(id);
  }
  return INPUT;
}


On Tue, May 18, 2010 at 21:02, Stephane Cosmeur <co...@gmail.com> wrote:

> Hello,
>
> My question is quite simple : what are the best practices to manage the
> edit
> and create form who often are exactly the same. Do you usualy create two
> jsp
> ? Do you call an action who check if the object is in the DB or not. Maybe
> some people use two diffrent action with two submit (seems difficult to
> me).
> I know it's not a such important requirment but my application is barely
> only composed of form and save / edit so i would to do it the best way.
>
> Regards,
>
> --
> Stéphane Cosmeur
>



-- 
Ing. Luis Martín Canaval Sánchez
Keep it small and simple.