maybe it never got initialized? u can check for it in ur beginpagerender
(not during rewind) and see its being initalized in the 1st place...or do
@conditional check in ur html for this object
From: Chris Chiappone <[EMAIL PROTECTED]>
Reply-To: Chris Chiappone <[EMAIL PROTECTED]>
To: Tapestry users <[email protected]>
Subject: Re: Confused with pageBeginRender and Form submission
Date: Fri, 15 Jul 2005 17:05:55 -0400
now im totally confused. The object should have been initialized on
page creation, how come it would become null when submitting the form?
On 7/15/05, Danny Mandel <[EMAIL PROTECTED]> wrote:
> This error means that your appInfo object is null. So, wherever you
> moved your appInfo restoration/initialization logic, it's not getting
> called int this case anymore.
>
> Danny
>
> Chris Chiappone wrote:
>
> >Thanks for the quick responses. The two responses I got were
> >basically the same so I tried it. The problem is now I get:
> >
> >binding: ExpressionBinding[EditApp appInfo.name]
> >location: context:/WEB-INF/EditApp.page, line 41, column 58
> >
> >ognl.OgnlException
> >source is null for getProperty(null, "name")
> >
> >So I am still a bit stuck on what I should do.
> >
> >On 7/15/05, Danny Mandel <[EMAIL PROTECTED]> wrote:
> >
> >
> >>In your pageBeginRender method you can check to see if the form is
> >>rewinding. If it is, you probably don't want to initialize things in
> >>there i.e.:
> >>
> >>public void pageBeginRender(PageEvent event) {
> >> if (!event.getRequestCycle().isRewinding()) {
> >> // do your normal initialization stuff and create if null
> >> }
> >>}
> >>
> >>In the case where it is rewinding, then you'll want to move your
object
> >>retrieval/restoration to a different place. This can be done by
binding
> >>your object's id to a hidden field that will fetch it or by use of a
> >>data squeezer. This has been addressed many times on this list so it
> >>should be in the archives and I know that there is a wiki page on
using
> >>a data squeezer to do this sort of thing:
> >>
> >>http://wiki.apache.org/jakarta-tapestry/DataSqueezer
> >>
> >>Hope that helps,
> >>Danny
> >>
> >>Chris Chiappone wrote:
> >>
> >>
> >>
> >>>I am a bit confused about how pageBeginRender works during a form
> >>>submission Here is the code i have:
> >>>
> >>> public void pageBeginRender(PageEvent event) {
> >>> // initialize app
> >>> retrieveApp(getAppVerId());
> >>> }
> >>>
> >>> private void retrieveApp(Long id){
> >>> if(id != null){
> >>> System.out.println("Updating App: "+ id);
> >>> AppDAO dao = new AppDAO();
> >>> AppVer ver = null;
> >>> AppInfo info = null;
> >>> ver = dao.getAppVerId(id, false);
> >>> info = ver.getAppInfo();
> >>> setAppInfo(info);
> >>> setAppVer(ver);
> >>> }
> >>> if(getAppInfo() == null){
> >>> System.out.println("Creating a new
application");
> >>> setAppInfo(new AppInfo());
> >>> setAppVer(new AppVer());
> >>> getAppVer().setRegdate(new Date());
> >>> }
> >>> }
> >>>
> >>> /**
> >>> * Action taken when this form has been submitted
> >>> *
> >>> * @param cycle
> >>> */
> >>> public void formSubmit(IRequestCycle cycle){
> >>> System.out.println("Current VerId = "+ getAppVerId());
> >>> // Check to see all validation was a success
> >>> ValidationDelegate delegate =
> >>>(ValidationDelegate)getBeans().getBean("delegate");
> >>>
> >>> if(!delegate.getHasErrors()){
> >>> // Insert the new version
> >>> AppDAO dao = new AppDAO();
> >>> AppInfo info = getAppInfo();
> >>> AppVer ver = getAppVer();
> >>>
> >>>....
> >>>
> >>>Basically I need to initialize the AppInfo and AppVer objects when
the
> >>>page is rendered. The page is an add/edit form. If appVerId is not
> >>>null I lookup AppInfo and AppVer to populate my form for editing, if
> >>>null create new objects. This seems to work fine. THe problem I
am
> >>>having is that when I submit the form It create a new AppVer and
> >>>AppInfo because appVerId appears to be null in pageBeginRender(Event)
> >>>but when it continues to formSubmit my print is showing the the
> >>>appVerId != null which is what I expect. The problem is the objects
> >>>have been intialized as new so it ends up creating duplicates. Hope
I
> >>>made this clear.
> >>>
> >>>
> >>>
> >>>
> >>>
> >>---------------------------------------------------------------------
> >>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]
>
>
--
~chris
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________
On the road to retirement? Check out MSN Life Events for advice on how to
get there! http://lifeevents.msn.com/category.aspx?cid=Retirement
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]