Why don't you store the user ID as an application state object (aso)?

Martijn

On Thu, 2008-08-21 at 22:07 -0400, Kevin Crenshaw wrote:
> Adam,
> 
> Thanks for responding (again :-) ) . However, as you can see in my 
> question, I'm not trying to use the environment during an event phase - 
> sorry if I misspoke before. The user object is placed on the environment 
> in the SetupRender phase. The problem is that after I submit the form I 
> get the 'user not available on the environment' error. I have attempted 
> to add the userId onto the context of the form as you suggest, but I 
> still get the error. Since I have never dealt with form submissions in 
> tapestry before, I was hoping for an example of how to utilize the 
> context to avoid the error and process the form as expected.
> 
> thanks,
> 
> Kevin
> 
> Adam Ayres wrote:
> > The best way to achieve this is to put the userId on the context of the
> > form using the "context" parameter.  You will then have access to the
> > userId in the OnEvent of the form to do a lookup of the User.
> >
> > If you insist on using the environment during the form submission event
> > phase to get the User, which I recommend against, then you could push
> > the User onto the environment during the onActivate of the page.  The
> > onActivate of a page is run during the event phase of a form action as
> > well as the normal rendering of a page, however the environment is
> > cleared after the onActivate, so you would need to setup the environment
> > in both the onActivate and setupRender if you took this approach.
> >
> > Philosophically I am against setting up the environment in onActivate of
> > a page since the onActivate would need to know about all possible
> > enviornmentals needed by any of the forms or actions it may contain that
> > require context.  By putting the context into the form action (or in the
> > context of an action link) the component that contains the form or
> > action is then responsible for providing the context of the event.
> >
> > Thanks,
> > Adam
> >
> >
> > -----Original Message-----
> > From: Kevin Crenshaw [mailto:[EMAIL PROTECTED] 
> > Sent: Thursday, August 21, 2008 3:49 PM
> > To: users@tapestry.apache.org
> > Subject: Unable to process form submission
> >
> > I have a page that contains a component that contains a form component.
> >
> > The page places a user object on the environment in its SetupRender 
> > phase that is used by the page's components. The User object is obtained
> >
> > using the userId that is passed in the page context.  When I submit the 
> > form I get the error 
> > org.apache.tapestry.runtime.ComponentEventException.  No object of type 
> > IUser is available from the environment.  Available types are....  How 
> > do get around this error?  Do I need to place the userId back on the 
> > page context?  Does anyone have an example of how to do this?
> >
> > I am using Tapestry 5.0.11
> >
> > TIA,
> >
> > Kevin
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >   
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to