You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ruben Pardo <ru...@yahoo.es> on 2003/04/07 11:23:17 UTC

a basic question

Hi everybody!

I'm new in struts and i want to know if someone can help me what is the best form to update a form from a enterprise javabean...

 this is the code suppossing that the actionForm's name is proyectosForm ...

public ActionForward edicion(ActionMapping mapping, ActionForm form,   HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {

String user = request.getSession(true).getAttribute("user"); //To recover the user attributte

ProyectosBean p = getProyectos("user");  //To get the EJB whit the value to edit

request.getSession(true).setAttribute("proyectosForm",p); //to put it the session scope 

return mapping.findForward(target); 

}

Is this sufficient or i need more?, 

Thanks.

 




---------------------------------
Yahoo! Messenger
Nueva versi&oacute;n: Super Webcam, voz, caritas animadas, y m&aacute;s #161;Gratis!

Re: a basic question

Posted by Nicolas De Loof <ni...@cgey.com>.
BeanUtils work fully with mapped form-beans.

To make it more simple, you can add
void populate(Map) and
Map describe()
methods to your beans and just use :

form.populate(businessBean.describe());

businessBean can use BeanUtil to describe or populate itself.

Nico.

>
> But ... is BeansUtils method works well with beans based on map? I mean with beans that communication is with
value("property")?
> thanks.
>  Nicolas De Loof <ni...@cgey.com> wrote:You should not use your business data as formBeans for some reasons :
>
> - business data will not have only String or boolean properties
> - business data does not have to extend ActionForm
> - validate() or reset() have no sense on business tier.
>
> You shoul use a form-bean that will copy datas from business, allow user to edit, and copy back when save is needed.
>
> Look at BeanUtils.copyProperties() to copy datas from and to business Beans. You can also create a Factory to make the
> copy :
> myFactory.getFormBean(businessBean);
> myFactory.getBusinessBean(form);
>
> Nico.
>
>
> >
> > Hi everybody!
> >
> > I'm new in struts and i want to know if someone can help me what is the best form to update a form from a enterprise
> javabean...
> >
> > this is the code suppossing that the actionForm's name is proyectosForm ...
> >
> > public ActionForward edicion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse
> response) throws IOException,ServletException {
> >
> > String user = request.getSession(true).getAttribute("user"); //To recover the user attributte
> >
> > ProyectosBean p = getProyectos("user"); //To get the EJB whit the value to edit
> >
> > request.getSession(true).setAttribute("proyectosForm",p); //to put it the session scope
> >
> > return mapping.findForward(target);
> >
> > }
> >
> > Is this sufficient or i need more?,
> >
> > Thanks.
> >
> >
> >
> >
> >
> >
> > ---------------------------------
> > Yahoo! Messenger
> > Nueva versión: Super Webcam, voz, caritas animadas, y más #161;Gratis!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------
> Yahoo! Messenger
> Nueva versi&oacute;n: Super Webcam, voz, caritas animadas, y m&aacute;s #161;Gratis!


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


Re: a basic question

Posted by Ruben Pardo <ru...@yahoo.es>.
But ... is BeansUtils method works well with beans based on map? I mean with beans that communication is with value("property")?
thanks.
 Nicolas De Loof <ni...@cgey.com> wrote:You should not use your business data as formBeans for some reasons :

- business data will not have only String or boolean properties
- business data does not have to extend ActionForm
- validate() or reset() have no sense on business tier.

You shoul use a form-bean that will copy datas from business, allow user to edit, and copy back when save is needed.

Look at BeanUtils.copyProperties() to copy datas from and to business Beans. You can also create a Factory to make the
copy :
myFactory.getFormBean(businessBean);
myFactory.getBusinessBean(form);

Nico.


>
> Hi everybody!
>
> I'm new in struts and i want to know if someone can help me what is the best form to update a form from a enterprise
javabean...
>
> this is the code suppossing that the actionForm's name is proyectosForm ...
>
> public ActionForward edicion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse
response) throws IOException,ServletException {
>
> String user = request.getSession(true).getAttribute("user"); //To recover the user attributte
>
> ProyectosBean p = getProyectos("user"); //To get the EJB whit the value to edit
>
> request.getSession(true).setAttribute("proyectosForm",p); //to put it the session scope
>
> return mapping.findForward(target);
>
> }
>
> Is this sufficient or i need more?,
>
> Thanks.
>
>
>
>
>
>
> ---------------------------------
> Yahoo! Messenger
> Nueva versión: Super Webcam, voz, caritas animadas, y más #161;Gratis!


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


---------------------------------
Yahoo! Messenger
Nueva versi&oacute;n: Super Webcam, voz, caritas animadas, y m&aacute;s #161;Gratis!

Re: a basic question

Posted by Nicolas De Loof <ni...@cgey.com>.
You should not use your business data as formBeans for some reasons :

- business data will not have only String or boolean properties
- business data does not have to extend ActionForm
- validate() or reset() have no sense on business tier.

You shoul use a form-bean that will copy datas from business, allow user to edit, and copy back when save is needed.

Look at BeanUtils.copyProperties() to copy datas from and to business Beans. You can also create a Factory to make the
copy :
myFactory.getFormBean(businessBean);
myFactory.getBusinessBean(form);

Nico.


>
> Hi everybody!
>
> I'm new in struts and i want to know if someone can help me what is the best form to update a form from a enterprise
javabean...
>
>  this is the code suppossing that the actionForm's name is proyectosForm ...
>
> public ActionForward edicion(ActionMapping mapping, ActionForm form,   HttpServletRequest request, HttpServletResponse
response) throws IOException,ServletException {
>
> String user = request.getSession(true).getAttribute("user"); //To recover the user attributte
>
> ProyectosBean p = getProyectos("user");  //To get the EJB whit the value to edit
>
> request.getSession(true).setAttribute("proyectosForm",p); //to put it the session scope
>
> return mapping.findForward(target);
>
> }
>
> Is this sufficient or i need more?,
>
> Thanks.
>
>
>
>
>
>
> ---------------------------------
> Yahoo! Messenger
> Nueva versi&oacute;n: Super Webcam, voz, caritas animadas, y m&aacute;s #161;Gratis!


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