You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Chiappone <ch...@gmail.com> on 2005/07/15 22:09:00 UTC
Confused with pageBeginRender and Form submission
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.
--
~chris
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Confused with pageBeginRender and Form submission
Posted by Chris Chiappone <ch...@gmail.com>.
40 <component id="appName" type="ValidField">
41 <binding name="value" expression="appInfo.name"/>
42 <binding name="validator" expression="beans.reqValidator"/>
43 <static-binding name="displayName" value="Application Name"/>
44 </component>
Thanks again for the help
On 7/15/05, Dan <po...@hotmail.com> wrote:
> and wat is line 41 in ur spec ?
>
> >From: Chris Chiappone <ch...@gmail.com>
> >Reply-To: Chris Chiappone <ch...@gmail.com>
> >To: Tapestry users <ta...@jakarta.apache.org>
> >Subject: Re: Confused with pageBeginRender and Form submission
> >Date: Fri, 15 Jul 2005 20:49:26 +0000
> >
> >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 <dm...@tolweb.org> 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: tapestry-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > >
> > >
> >
> >
> >--
> >~chris
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
>
> _________________________________________________________________
> Don't just search. Find. Check out the new MSN Search!
> http://search.msn.click-url.com/go/onm00200636ave/direct/01/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
--
~chris
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Confused with pageBeginRender and Form submission
Posted by Danny Mandel <dm...@tolweb.org>.
By default, objects are only 'alive' for the period of that particular
page render. So, if you initialized it on the first render, the second
time it comes around it's null (assuming you are using tapestry to
manage your page properties). If you make the property persistent it
will still be around during the second page render.
Danny
Chris Chiappone wrote:
>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 <dm...@tolweb.org> 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 <dm...@tolweb.org> 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: tapestry-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>
>>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Confused with pageBeginRender and Form submission
Posted by Chris Chiappone <ch...@gmail.com>.
Well It looks like this isn't exactly what I want. With persistance
the form stays filled out after returning to it. So the idea is that
I have to store the object in a hidden value and then get it back?
On 7/15/05, Chris Chiappone <ch...@gmail.com> wrote:
> Well seting the properties to persistant did the trick. I guess I am
> not clear on how the page cycle works yet being new to tapestry. I
> would have expected the values not to be null, but I guess I didn't
> know that the page was rendered again after submission.
>
> On 7/15/05, Robert Zeigler <ro...@scazdl.org> wrote:
> > object should /not/ be initialized on page creation.
> > Pages are pooled; state information in the page is not.
> > If the page-property is a "persistent" property, it is "attached" at
> > page render and "detached" (page property set to null) when the page
> > finishes rendering by the framework. If the property is not persistent,
> > it is still set back to null at the end of page rendering to prevent
> > goofups like user b seeing user a's account information.
> > So, you initialize things in pageBeginRender.
> > Now, you've inited in pageBeginRender, but you probably don't want to
> > re-init when the form is submitted, because you may be "re-initting"
> > something that shouldn't be initialized. One solution to this dilemma
> > is to do something like:
> > pageBeginRender(PageEvent event) {
> > if (!event.getRequestCycle.isRewinding()) {
> > //initialize objects here.
> > }
> > }
> >
> > Then, you use the "hidden" component to store necessary objects at the
> > top of your form. Then your object gets re-initialized automatically on
> > form submission in time for things after it to not be null.
> >
> > Or... you can just make the property persistent, depending on your views
> > on stateful vs. stateless webapps, session-use, etc.
> >
> > Robert
> >
> > Chris Chiappone wrote:
> > > 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 <dm...@tolweb.org> 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 <dm...@tolweb.org> 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: tapestry-user-unsubscribe@jakarta.apache.org
> > >>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >>>
> > >>>
> > >>>
> > >>>
> > >>
> > >>---------------------------------------------------------------------
> > >>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > >>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > >>
> > >>
> > >
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
>
> --
> ~chris
>
--
~chris
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Confused with pageBeginRender and Form submission
Posted by Chris Chiappone <ch...@gmail.com>.
Well seting the properties to persistant did the trick. I guess I am
not clear on how the page cycle works yet being new to tapestry. I
would have expected the values not to be null, but I guess I didn't
know that the page was rendered again after submission.
On 7/15/05, Robert Zeigler <ro...@scazdl.org> wrote:
> object should /not/ be initialized on page creation.
> Pages are pooled; state information in the page is not.
> If the page-property is a "persistent" property, it is "attached" at
> page render and "detached" (page property set to null) when the page
> finishes rendering by the framework. If the property is not persistent,
> it is still set back to null at the end of page rendering to prevent
> goofups like user b seeing user a's account information.
> So, you initialize things in pageBeginRender.
> Now, you've inited in pageBeginRender, but you probably don't want to
> re-init when the form is submitted, because you may be "re-initting"
> something that shouldn't be initialized. One solution to this dilemma
> is to do something like:
> pageBeginRender(PageEvent event) {
> if (!event.getRequestCycle.isRewinding()) {
> //initialize objects here.
> }
> }
>
> Then, you use the "hidden" component to store necessary objects at the
> top of your form. Then your object gets re-initialized automatically on
> form submission in time for things after it to not be null.
>
> Or... you can just make the property persistent, depending on your views
> on stateful vs. stateless webapps, session-use, etc.
>
> Robert
>
> Chris Chiappone wrote:
> > 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 <dm...@tolweb.org> 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 <dm...@tolweb.org> 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: tapestry-user-unsubscribe@jakarta.apache.org
> >>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>>
> >>>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >>
> >>
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
--
~chris
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Confused with pageBeginRender and Form submission
Posted by Robert Zeigler <ro...@scazdl.org>.
object should /not/ be initialized on page creation.
Pages are pooled; state information in the page is not.
If the page-property is a "persistent" property, it is "attached" at
page render and "detached" (page property set to null) when the page
finishes rendering by the framework. If the property is not persistent,
it is still set back to null at the end of page rendering to prevent
goofups like user b seeing user a's account information.
So, you initialize things in pageBeginRender.
Now, you've inited in pageBeginRender, but you probably don't want to
re-init when the form is submitted, because you may be "re-initting"
something that shouldn't be initialized. One solution to this dilemma
is to do something like:
pageBeginRender(PageEvent event) {
if (!event.getRequestCycle.isRewinding()) {
//initialize objects here.
}
}
Then, you use the "hidden" component to store necessary objects at the
top of your form. Then your object gets re-initialized automatically on
form submission in time for things after it to not be null.
Or... you can just make the property persistent, depending on your views
on stateful vs. stateless webapps, session-use, etc.
Robert
Chris Chiappone wrote:
> 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 <dm...@tolweb.org> 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 <dm...@tolweb.org> 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: tapestry-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Confused with pageBeginRender and Form submission
Posted by Dan � <po...@hotmail.com>.
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 <ch...@gmail.com>
>Reply-To: Chris Chiappone <ch...@gmail.com>
>To: Tapestry users <ta...@jakarta.apache.org>
>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 <dm...@tolweb.org> 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 <dm...@tolweb.org> 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: tapestry-user-unsubscribe@jakarta.apache.org
> > >>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > >>
> > >>
> > >>
> > >>
> > >
> > >
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
>
>--
>~chris
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
_________________________________________________________________
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: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Confused with pageBeginRender and Form submission
Posted by Chris Chiappone <ch...@gmail.com>.
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 <dm...@tolweb.org> 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 <dm...@tolweb.org> 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: tapestry-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >>
> >>
> >>
> >>
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
--
~chris
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Confused with pageBeginRender and Form submission
Posted by Danny Mandel <dm...@tolweb.org>.
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 <dm...@tolweb.org> 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: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>
>>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Confused with pageBeginRender and Form submission
Posted by Dan � <po...@hotmail.com>.
and wat is line 41 in ur spec ?
>From: Chris Chiappone <ch...@gmail.com>
>Reply-To: Chris Chiappone <ch...@gmail.com>
>To: Tapestry users <ta...@jakarta.apache.org>
>Subject: Re: Confused with pageBeginRender and Form submission
>Date: Fri, 15 Jul 2005 20:49:26 +0000
>
>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 <dm...@tolweb.org> 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: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
>
>--
>~chris
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
_________________________________________________________________
Dont just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Confused with pageBeginRender and Form submission
Posted by Chris Chiappone <ch...@gmail.com>.
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 <dm...@tolweb.org> 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: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
--
~chris
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Confused with pageBeginRender and Form submission
Posted by Danny Mandel <dm...@tolweb.org>.
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: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org