The ComponentInterceptor will create and store your component in the
Session. It will not pick up the fact that you've created a new one and
put it into your Action. 

I think we're talking about a persistent object here, right? IMO this is
not a good fit for a component. A good component would be something like
a DAO which will load and save objects for you, not the objects
themselves.

For doing this kind of editing, you're going to want to save your
Objects in the Session manually. You could make your Action ModelDriven
and have something like this:

Public Object getModel() {
   Map session = ActionContext.getContext().getSession();
   MyObject obj = session.get(MY_OBJECT_KEY);
   if (obj == null) {
      obj = // get an object or create a new one
      session.put(MY_OBJECT_KEY);
   }
   return obj;
}

Then form fields will be set on the obj...

Jason

> -----Original Message-----
> From: Mathias Berg [mailto:[EMAIL PROTECTED] 
> Sent: Friday, November 14, 2003 4:58 AM
> To: '[EMAIL PROTECTED]'
> Subject: RE: [OS-webwork] Component object setting
> 
> 
> oki, hmm i'll try with this explanation instead:
> Is this how the flow of the component setting and getting works?
> 
> 1. ComponentInterceptor makes a get to the session, looking 
> for the DAO object (Object specified as enabled in the 
> components.xml file.)We call it X 2. if X==null then make a 
> new X in the session. 3. Action is called and makes a new set 
> of X from a external source (ex
> database) in its execute with setX(..) (is this automatically 
> referred to the session?) 4. Action goes to the view page and 
> fill the FORM with X's data. 5. Form is submitted -> 
> ComponentInterceptor make a get for X in session (Are there 
> existing two X objects now? one in the session and one in the 
> Action? ) and reset X's values with those existing in the 
> FORM. 6. Action re-set also X with setX(..) and now X is 
> reflecting the data from the FORM and not from the Database.
> 
> It feels im loosing my self here...Hope you understand anyways... :)
> 
> Is there a example that i can see how you set session 
> component in you action?
> 
> /Mathias
> 
> Tx Daniel (co-worker) for your more pro-explanation :) 
> 
> -----Original Message-----
> From: Daniel Pfeifer [mailto:[EMAIL PROTECTED]
> Sent: den 13 november 2003 17:42
> To: '[EMAIL PROTECTED]'
> Subject: RE: [OS-webwork] Component object setting
> 
> 
> Well, the problem is as following.
> 
> The Component Interceptor looks up if an instance of a 
> certain class is in the session. As it doesn't find an 
> instance it will create an instance of it and put it to the session.
> 
> As the flow continues he finally arrives at his action class. 
> In this action he retrieves a instance of that class (which 
> should lay in the session) from the database with a Data 
> Access Object and tries to put that very object to the 
> session by writing setPersistetObject() (which is the method 
> in his Aware interface).
> 
> But! Since the Component Interceptor already created this 
> object it will not put the instance created by the action 
> back into the session (the objects of course differ even 
> though they are of the same type). It will ignore it and when 
> he returns to the result view he will actually retrieve the 
> ComponentInterceptor created instance of that type, which of 
> course is empty as the properties in the instance created by 
> the ComponentInterceptor never have been touched!
> 
> I guess what Mathias wants to know if there is a way to 
> persuate the ComponentInterceptor to put the new instance of 
> that type on the session and dispose the untouched one?
> 
> /Daniel
> 
> -----Original Message-----
> From: Jason Carreira [mailto:[EMAIL PROTECTED]
> Sent: den 13 november 2003 17:17
> To: [EMAIL PROTECTED]
> Subject: RE: [OS-webwork] Component object setting
> 
> 
> I didn't understand all of that, but yes, your object will 
> need to go into the HttpSession if you want to reuse it... 
> 
> > -----Original Message-----
> > From: Mathias Berg [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, November 13, 2003 11:13 AM
> > To: WebWork (E-mail)
> > Subject: [OS-webwork] Component object setting
> > 
> > 
> > Hi, We have some problem with our component settings. It
> > seems that our component object that is loaded from our 
> > Database is replaced by another object when we submit our form.
> > 
> > This how it goes.
> > 1. We access the action and the action load a transport
> > (Session Aware object )object from the database. We set this 
> > loaded transport in the action with the setMethod. 2. The 
> > action forwards to the view page. 3. The view loads the 
> > transport object and put its value to the form. 4. The save 
> > button is accessed and goes again to the action for updating 
> > the data from the form into the transport object for later 
> > update in the database.
> > 
> > Now the problem for us is that the transport object is
> > reseted and only those values that was sent from the form is 
> > set in the transport. 
> > 
> > Are we supposed to set the transport in the session manualy
> > when we load the transport from the database? Its seem now 
> > that component interceptor set a own transport in the session 
> > and then our action also set a own transport...And what we 
> > get is the components transport object and not the 
> > Actions...Is this right?
> > 
> > How should this impl. be made?
> > 
> > Tx for any help.
> > 
> > Regards, Mathias.
> > 
> > 
> > 
> > -------------------------------------------------------
> > This SF.Net email sponsored by: ApacheCon 2003,
> > 16-19 November in Las Vegas. Learn firsthand the latest
> > developments in Apache, PHP, Perl, XML, Java, MySQL, WebDAV, 
> > and more! http://www.apachecon.com/ 
> > _______________________________________________
> > Opensymphony-webwork mailing list 
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork
> > 
> 
> 
> -------------------------------------------------------
> This SF.Net email sponsored by: ApacheCon 2003,
> 16-19 November in Las Vegas. Learn firsthand the latest
> developments in Apache, PHP, Perl, XML, Java, MySQL,
> WebDAV, and more! http://www.apachecon.com/
> _______________________________________________
> Opensymphony-webwork mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork
> 
> 
> -------------------------------------------------------
> This SF.Net email sponsored by: ApacheCon 2003,
> 16-19 November in Las Vegas. Learn firsthand the latest
> developments in Apache, PHP, Perl, XML, Java, MySQL,
> WebDAV, and more! http://www.apachecon.com/
> _______________________________________________
> Opensymphony-webwork mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork
> 
> 
> -------------------------------------------------------
> This SF.Net email sponsored by: ApacheCon 2003,
> 16-19 November in Las Vegas. Learn firsthand the latest
> developments in Apache, PHP, Perl, XML, Java, MySQL,
> WebDAV, and more! http://www.apachecon.com/
> _______________________________________________
> Opensymphony-webwork mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork
> 


-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to