Stripes actions are usually request-lived. But you have another option, from
the Stripes website:

 

http://www.stripesframework.org/display/stripes/Save+ActionBean+fields+in+se
ssion

 

Anyway, as a rule of thumb, avoid using the session unless there’s no other
way. Reloading db objects in the POST action is a common accepted path.

 

Hope it helps.

 

  _____  

De: Morten Matras [mailto:[email protected]] 
Enviado el: lunes, 09 de febrero de 2009 10:53
Para: Stripes Users List
Asunto: Re: [Stripes-users] POJOs / forms

 

This is probably because you haven't added a hidden field with the id of the
object you're trying to update.

So if you need to edit an object in the actionBean accessed with:
getCustomer() / setCustomer(...) in the actionBean you need to set the id of
the customer in the form to have it fetched from the database and updated
instead of being instantiated.


<s:form beanclass="${actionBean.class}">

<s:hidden name="customer"/>

...

The trick is to add the hidden field with the name of the bean you need to
edit.

Regards

Morten Matras

Denmark



2009/2/9 Ben <[email protected]>

This feels like it is a stupid question but then sometimes they need to be
asked.

I have a POJO with various fields and a few collections.  I would like to
edit
some of the fields in a form.  I have created an ActionBean with the object
embeded and exposed through a get/set, loaded an instance of the object,
ForwardResolution'ed to the JSP and then used object.field in the form with
a
POST back to the ActionBean - so far so good.

What I understod from the documentation was that Stripes would update the
existing object (i.e. the one that was loaded in the ActionBean) with the
values
in the form but what it is actually doing is instanciating a new object and
populating that from the form.  This basically means that I either have to
have
every field as an editable or hidden field on the form or load another copy
of
the pre-existing object and 'merge' the changes in - which as far as I can
tell
is what the Bugzooky app does.

I guess my question is, can I change the behaviour so I dont have to do
either
of those things and get stripes to simply update an existing object rather
than
create a new one?  Or should I stop complaining and get on with it? ;)

TIA and appologies for what is probably a very basic and stupid question.

Ben

PS In case it makes a difference, I am using JDK 1.6.0.11 / Stripes 1.5 /
Hibernate 3.3.1 / Tomcat 6


----------------------------------------------------------------------------
--
Create and Deploy Rich Internet Apps outside the browser with
Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code
to
build responsive, highly engaging applications that combine the power of
local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users




-- 
 Morten Matras
 Consultant
 Blob Communication ApS
 Svendsagervej 42
 DK-5240 Odense NØ
 P: (+45) 76 6-5-4-3-2-1
 W: www.blobcom.com
 E: [email protected]

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to