Re: T5 Newbie : populate the value of a form in a bean
In my case I think I was running in confusion, the MyObject was already initialized from a previous page and injected in the page that hold the form. Thus initialising it from onPrepareFromForm or setupRender is useless in this particular case. Things are working fine now, I really don't see what was wrong before as I can't see what's better now ... Newbie bad time. Josh send me good vibes ;-) I'm going to produce a little wiki tutorial on Basic Crud this weekend because that really miss me. Thanks for your help and your explainations. Howard Lewis Ship a écrit : Generally, what you want to do is replace setupRender() with onPrepareFromForm(). void onPrepareFromForm() { if (_myObject == null) _myObject = new MyObject(); } "Prepare" means the prepare event, fired from your Form component. Prepare event is triggered when the form starts to render AND when it starts to process a submission. Instantiating and object is exactly what prepare is intended for. Tapestry will supply an id of "form" for the component. If you have multiple forms, they may end up being "form", "form_0", "form_1". I tend to give an explicit id. You test page is a little different, in that it displays the contents of the myObject property as well, so your setupRender() should do the job (because the _myObject field is persistent). On Nov 15, 2007 11:39 AM, Josh Canfield <[EMAIL PROTECTED]> wrote: Hey Michael, I didn't get to it last night, but here you go, a very simple example: ** Start.tml http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";> Form Test MyObject: Name: ${myObject.name} Number: ${myObject.number} Start.java *package* joshcan.test.myapp.pages; ** *import* joshcan.test.myapp.model.TestObject; *import* org.apache.tapestry.annotations.Persist; /** * Start page of application myapp. */ *public* *class* Start { @Persist // Store this object in the session... * private* TestObject _myObject; * * * public* *void* setupRender() { *if* ( _myObject == *null* ) { // make sure we have an object to work on. _myObject = *new* TestObject(); } } * public* TestObject getMyObject() { *return* _myObject; } * public* *void* setMyObject(TestObject myObject) { _myObject = myObject; } } TestObject.java * package* joshcan.test.myapp.model; *public* *class* TestObject { * private* String name; * private* Long number; * public* String getName() { *return* name; } * public* *void* setName(String name) { *this*.name = name; } * public* Long getNumber() { *return* number; } * public* *void* setNumber(Long number) { *this*.number = number; } } Josh On Nov 15, 2007 1:35 AM, Michael Courcy <[EMAIL PROTECTED]> wrote: The title property of the video object is updated, I don't have a title property on my page class. I can't compile anything right now, but I'll try to put together a small example tonight, if someone else hasn't posted something by then. Josh Josh It would be really really nice !!! If you do so I would make it a small wiki tutorial Josh Canfield a écrit : > Hi Michael, Thanks Josh, but do you have also a title property with getter and setter in your page class ? No, I only have the video getter/setter And if yes (as I guess) whish value is updated when you submit the form : MyPage.title or MyPage.video.title ? The title property of the video object is updated, I don't have a title property on my page class. I can't compile anything right now, but I'll try to put together a small example tonight, if someone else hasn't posted something by then. Josh On Nov 14, 2007 11:01 AM, Michael Courcy <[EMAIL PROTECTED]> wrote: Thanks Josh, but do you have also a title property with getter and setter in your page class ? And if yes (as I guess) whish value is updated when you submit the form : MyPage.title or MyPage.video.title ? Josh Canfield a écrit : >> I want to populate from the form directly to the bean. But this require to use either the beanEditForm or a custom component. You can get this to work. I use the textfield component for editing my bean objects. This is from a working emplate: My page class has a getVideo method which returns an object that has a getTitle method. Good luck, Josh On Nov 14, 2007 9:05 AM, Michael Courcy <[EMAIL PROTECTED]> wrote: You're right here it is, I remove the "offending input" and use this instead ${user}-- ${user.name} And I get [EMAIL PROTECTED] -- A name Obviously user is not null. I think the problem does not come from tapestry but from me. I want to populate from the form directly to the bean. But this require to use either the beanEditForm or a custom component. I
Re: T5 Newbie : populate the value of a form in a bean
I've tried it It works, got to understand my errors now. Thanks a lot. Josh Canfield a écrit : Hey Michael, I didn't get to it last night, but here you go, a very simple example: ** Start.tml http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";> Form Test MyObject: Name: ${myObject.name} Number: ${myObject.number} Start.java *package* joshcan.test.myapp.pages; ** *import* joshcan.test.myapp.model.TestObject; *import* org.apache.tapestry.annotations.Persist; /** * Start page of application myapp. */ *public* *class* Start { @Persist // Store this object in the session... * private* TestObject _myObject; * * * public* *void* setupRender() { *if* ( _myObject == *null* ) { // make sure we have an object to work on. _myObject = *new* TestObject(); } } * public* TestObject getMyObject() { *return* _myObject; } * public* *void* setMyObject(TestObject myObject) { _myObject = myObject; } } TestObject.java * package* joshcan.test.myapp.model; *public* *class* TestObject { * private* String name; * private* Long number; * public* String getName() { *return* name; } * public* *void* setName(String name) { *this*.name = name; } * public* Long getNumber() { *return* number; } * public* *void* setNumber(Long number) { *this*.number = number; } } Josh On Nov 15, 2007 1:35 AM, Michael Courcy <[EMAIL PROTECTED]> wrote: The title property of the video object is updated, I don't have a title property on my page class. I can't compile anything right now, but I'll try to put together a small example tonight, if someone else hasn't posted something by then. Josh Josh It would be really really nice !!! If you do so I would make it a small wiki tutorial Josh Canfield a écrit : > Hi Michael, Thanks Josh, but do you have also a title property with getter and setter in your page class ? No, I only have the video getter/setter And if yes (as I guess) whish value is updated when you submit the form : MyPage.title or MyPage.video.title ? The title property of the video object is updated, I don't have a title property on my page class. I can't compile anything right now, but I'll try to put together a small example tonight, if someone else hasn't posted something by then. Josh On Nov 14, 2007 11:01 AM, Michael Courcy <[EMAIL PROTECTED]> wrote: Thanks Josh, but do you have also a title property with getter and setter in your page class ? And if yes (as I guess) whish value is updated when you submit the form : MyPage.title or MyPage.video.title ? Josh Canfield a écrit : >> I want to populate from the form directly to the bean. But this require to use either the beanEditForm or a custom component. You can get this to work. I use the textfield component for editing my bean objects. This is from a working emplate: My page class has a getVideo method which returns an object that has a getTitle method. Good luck, Josh On Nov 14, 2007 9:05 AM, Michael Courcy <[EMAIL PROTECTED]> wrote: You're right here it is, I remove the "offending input" and use this instead ${user}-- ${user.name} And I get [EMAIL PROTECTED] -- A name Obviously user is not null. I think the problem does not come from tapestry but from me. I want to populate from the form directly to the bean. But this require to use either the beanEditForm or a custom component. I 'm just influenced by other framework like struts2 for instance : If you have something like that in your form When the form is submitted struts2 tries to find if the controller features a user property, and then if user features a name property If the answer is yes to both it calls controller.getUser ().setName("bla"); Ezra Epstein a écrit : > I always pause when hearing "100% sure." An easy check/test is to remove the offending and stick in a simple ${user} and see if indeed you get the toString() value for your user object. Michael Courcy <[EMAIL PROTECTED]> wrote: I'm 100% sure, user is not null I have a getter and a setter for both : name and user Thanks Thiago H de Paula Figueiredo a écrit : On Wed, 14 Nov 2007 12:47:06 -0200, Michael Courcy wrote: [input] I have to provide the setter and the getter for name and I still get an error when I submit. What error? Make sure your user field is not null when the form is submited. Also make sure you have public getters and setters, because otherwise Tapestry cannot access them. -- Michael Courcy http://courcy.blogspot.com
Re: T5 Newbie : populate the value of a form in a bean
Generally, what you want to do is replace setupRender() with onPrepareFromForm(). void onPrepareFromForm() { if (_myObject == null) _myObject = new MyObject(); } "Prepare" means the prepare event, fired from your Form component. Prepare event is triggered when the form starts to render AND when it starts to process a submission. Instantiating and object is exactly what prepare is intended for. Tapestry will supply an id of "form" for the component. If you have multiple forms, they may end up being "form", "form_0", "form_1". I tend to give an explicit id. You test page is a little different, in that it displays the contents of the myObject property as well, so your setupRender() should do the job (because the _myObject field is persistent). On Nov 15, 2007 11:39 AM, Josh Canfield <[EMAIL PROTECTED]> wrote: > Hey Michael, > > I didn't get to it last night, but here you go, a very simple example: > > ** Start.tml > http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";> > > Form Test > > > MyObject: > Name: ${myObject.name} > Number: ${myObject.number} > > > "myObject.name"/> > t:value="myObject.number"/> > > > > > > Start.java > *package* joshcan.test.myapp.pages; > ** > *import* joshcan.test.myapp.model.TestObject; > *import* org.apache.tapestry.annotations.Persist; > > /** > * Start page of application myapp. > */ > *public* *class* Start > { > @Persist // Store this object in the session... > * private* TestObject _myObject; > * * > * public* *void* setupRender() { > *if* ( _myObject == *null* ) { // make sure we have an object to work > on. > _myObject = *new* TestObject(); > } > } > > * public* TestObject getMyObject() { > *return* _myObject; > } > > * public* *void* setMyObject(TestObject myObject) { > _myObject = myObject; > } > } > TestObject.java > * > > package* joshcan.test.myapp.model; > > *public* *class* TestObject { > > * private* String name; > * private* Long number; > > * public* String getName() { > *return* name; > } > > * public* *void* setName(String name) { > *this*.name = name; > } > > * public* Long getNumber() { > *return* number; > } > > * public* *void* setNumber(Long number) { > *this*.number = number; > } > > } > Josh > > > > On Nov 15, 2007 1:35 AM, Michael Courcy <[EMAIL PROTECTED]> wrote: > > > > > > > The title property of the video object is updated, I don't have a title > > > property on my page class. > > > > > > I can't compile anything right now, but I'll try to put together a small > > > example tonight, if someone else hasn't posted something by then. > > > > > > Josh > > Josh It would be really really nice !!! > > If you do so I would make it a small wiki tutorial > > > > > > Josh Canfield a écrit : > > > Hi Michael, > > > > > > > > > > > >> Thanks Josh, but do you have also a title property with getter and > > >> setter in your page class ? > > >> > > >> > > > > > > No, I only have the video getter/setter > > > > > > > > > > > >> And if yes (as I guess) whish value is updated when you submit the form > > >> : MyPage.title or MyPage.video.title ? > > >> > > > > > > > > > The title property of the video object is updated, I don't have a title > > > property on my page class. > > > > > > I can't compile anything right now, but I'll try to put together a small > > > example tonight, if someone else hasn't posted something by then. > > > > > > Josh > > > > > > On Nov 14, 2007 11:01 AM, Michael Courcy <[EMAIL PROTECTED]> > > wrote: > > > > > > > > >> Thanks Josh, but do you have also a title property with getter and > > >> setter in your page class ? > > >> > > >> And if yes (as I guess) whish value is updated when you submit the form > > >> : MyPage.title or MyPage.video.title ? > > >> > > >> Josh Canfield a écrit : > > >> >> I want to populate from the form directly to the bean. But this > > >> require > > >> > > to use either the beanEditForm or a custom component. > > > > > > > > >>> You can get this to work. I use the textfield component for editing my > > >>> > > >> bean > > >> > > >>> objects. This is from a working emplate: > > >>> > > >>> > > >>> My page class has a getVideo method which returns an object that has a > > >>> getTitle method. > > >>> > > >>> Good luck, > > >>> Josh > > >>> > > >>> On Nov 14, 2007 9:05 AM, Michael Courcy <[EMAIL PROTECTED]> > > >>> > > >> wrote: > > >> > > >>> > > You're right > > > > here it is, I remove the "offending input" > > > > and use this instead > > > > ${user}-- ${user.name} > > > > And I get > > > > [EMAIL PROTECTED] -- A name > > > > Obviously user is not null. > > > > I think the problem does not come from tapestry but from me. > > I want to populate from the form directly to the bean. But this > > require > > to use either the beanEdit
Re: T5 Newbie : populate the value of a form in a bean
Hey Michael, I didn't get to it last night, but here you go, a very simple example: ** Start.tml http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";> Form Test MyObject: Name: ${myObject.name} Number: ${myObject.number} Start.java *package* joshcan.test.myapp.pages; ** *import* joshcan.test.myapp.model.TestObject; *import* org.apache.tapestry.annotations.Persist; /** * Start page of application myapp. */ *public* *class* Start { @Persist // Store this object in the session... * private* TestObject _myObject; * * * public* *void* setupRender() { *if* ( _myObject == *null* ) { // make sure we have an object to work on. _myObject = *new* TestObject(); } } * public* TestObject getMyObject() { *return* _myObject; } * public* *void* setMyObject(TestObject myObject) { _myObject = myObject; } } TestObject.java * package* joshcan.test.myapp.model; *public* *class* TestObject { * private* String name; * private* Long number; * public* String getName() { *return* name; } * public* *void* setName(String name) { *this*.name = name; } * public* Long getNumber() { *return* number; } * public* *void* setNumber(Long number) { *this*.number = number; } } Josh On Nov 15, 2007 1:35 AM, Michael Courcy <[EMAIL PROTECTED]> wrote: > > > > The title property of the video object is updated, I don't have a title > > property on my page class. > > > > I can't compile anything right now, but I'll try to put together a small > > example tonight, if someone else hasn't posted something by then. > > > > Josh > Josh It would be really really nice !!! > If you do so I would make it a small wiki tutorial > > > Josh Canfield a écrit : > > Hi Michael, > > > > > > > >> Thanks Josh, but do you have also a title property with getter and > >> setter in your page class ? > >> > >> > > > > No, I only have the video getter/setter > > > > > > > >> And if yes (as I guess) whish value is updated when you submit the form > >> : MyPage.title or MyPage.video.title ? > >> > > > > > > The title property of the video object is updated, I don't have a title > > property on my page class. > > > > I can't compile anything right now, but I'll try to put together a small > > example tonight, if someone else hasn't posted something by then. > > > > Josh > > > > On Nov 14, 2007 11:01 AM, Michael Courcy <[EMAIL PROTECTED]> > wrote: > > > > > >> Thanks Josh, but do you have also a title property with getter and > >> setter in your page class ? > >> > >> And if yes (as I guess) whish value is updated when you submit the form > >> : MyPage.title or MyPage.video.title ? > >> > >> Josh Canfield a écrit : > >> >> I want to populate from the form directly to the bean. But this > >> require > >> > to use either the beanEditForm or a custom component. > > > > >>> You can get this to work. I use the textfield component for editing my > >>> > >> bean > >> > >>> objects. This is from a working emplate: > >>> > >>> > >>> My page class has a getVideo method which returns an object that has a > >>> getTitle method. > >>> > >>> Good luck, > >>> Josh > >>> > >>> On Nov 14, 2007 9:05 AM, Michael Courcy <[EMAIL PROTECTED]> > >>> > >> wrote: > >> > >>> > You're right > > here it is, I remove the "offending input" > > and use this instead > > ${user}-- ${user.name} > > And I get > > [EMAIL PROTECTED] -- A name > > Obviously user is not null. > > I think the problem does not come from tapestry but from me. > I want to populate from the form directly to the bean. But this > require > to use either the beanEditForm or a custom component. > > I 'm just influenced by other framework like struts2 for instance : > > If you have something like that in your form > > > > When the form is submitted struts2 tries to find if the controller > features a user property, and then if user features a name property > If the answer is yes to both it calls controller.getUser > > >> ().setName("bla"); > >> > > > > Ezra Epstein a écrit : > > I always pause when hearing "100% sure." An easy check/test is to > remove the offending and stick in a simple ${user} and see if > > >> indeed > >> > you get the toString() value for your user object. > > > > Michael Courcy <[EMAIL PROTECTED]> wrote: I'm 100% sure, user > > > >> is > >> > not null > > > > I have a getter and a setter for both : name and user > > > > Thanks > > Thiago H de Paula Figueiredo a écrit : > > > > > > > >> On Wed, 14 Nov 2007 12:47:06 -0200, Michael Courcy > >> wrote: > >> > >> > >> > >> > >>> [input] > >>> > >>> I have to provide the setter and the getter for
Re: T5 Newbie : populate the value of a form in a bean
Thanks a lot Josh I'm going to try it now Josh Canfield a écrit : Hey Michael, I didn't get to it last night, but here you go, a very simple example: ** Start.tml http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";> Form Test MyObject: Name: ${myObject.name} Number: ${myObject.number} Start.java *package* joshcan.test.myapp.pages; ** *import* joshcan.test.myapp.model.TestObject; *import* org.apache.tapestry.annotations.Persist; /** * Start page of application myapp. */ *public* *class* Start { @Persist // Store this object in the session... * private* TestObject _myObject; * * * public* *void* setupRender() { *if* ( _myObject == *null* ) { // make sure we have an object to work on. _myObject = *new* TestObject(); } } * public* TestObject getMyObject() { *return* _myObject; } * public* *void* setMyObject(TestObject myObject) { _myObject = myObject; } } TestObject.java * package* joshcan.test.myapp.model; *public* *class* TestObject { * private* String name; * private* Long number; * public* String getName() { *return* name; } * public* *void* setName(String name) { *this*.name = name; } * public* Long getNumber() { *return* number; } * public* *void* setNumber(Long number) { *this*.number = number; } } Josh On Nov 15, 2007 1:35 AM, Michael Courcy <[EMAIL PROTECTED]> wrote: The title property of the video object is updated, I don't have a title property on my page class. I can't compile anything right now, but I'll try to put together a small example tonight, if someone else hasn't posted something by then. Josh Josh It would be really really nice !!! If you do so I would make it a small wiki tutorial Josh Canfield a écrit : > Hi Michael, Thanks Josh, but do you have also a title property with getter and setter in your page class ? No, I only have the video getter/setter And if yes (as I guess) whish value is updated when you submit the form : MyPage.title or MyPage.video.title ? The title property of the video object is updated, I don't have a title property on my page class. I can't compile anything right now, but I'll try to put together a small example tonight, if someone else hasn't posted something by then. Josh On Nov 14, 2007 11:01 AM, Michael Courcy <[EMAIL PROTECTED]> wrote: Thanks Josh, but do you have also a title property with getter and setter in your page class ? And if yes (as I guess) whish value is updated when you submit the form : MyPage.title or MyPage.video.title ? Josh Canfield a écrit : >> I want to populate from the form directly to the bean. But this require to use either the beanEditForm or a custom component. You can get this to work. I use the textfield component for editing my bean objects. This is from a working emplate: My page class has a getVideo method which returns an object that has a getTitle method. Good luck, Josh On Nov 14, 2007 9:05 AM, Michael Courcy <[EMAIL PROTECTED]> wrote: You're right here it is, I remove the "offending input" and use this instead ${user}-- ${user.name} And I get [EMAIL PROTECTED] -- A name Obviously user is not null. I think the problem does not come from tapestry but from me. I want to populate from the form directly to the bean. But this require to use either the beanEditForm or a custom component. I 'm just influenced by other framework like struts2 for instance : If you have something like that in your form When the form is submitted struts2 tries to find if the controller features a user property, and then if user features a name property If the answer is yes to both it calls controller.getUser ().setName("bla"); Ezra Epstein a écrit : > I always pause when hearing "100% sure." An easy check/test is to remove the offending and stick in a simple ${user} and see if indeed you get the toString() value for your user object. Michael Courcy <[EMAIL PROTECTED]> wrote: I'm 100% sure, user is not null I have a getter and a setter for both : name and user Thanks Thiago H de Paula Figueiredo a écrit : On Wed, 14 Nov 2007 12:47:06 -0200, Michael Courcy wrote: [input] I have to provide the setter and the getter for name and I still get an error when I submit. What error? Make sure your user field is not null when the form is submited. Also make sure you have public getters and setters, because otherwise Tapestry cannot access them. -- Michael Courcy http://courcy.blogspot.com -- Mic
Re: T5 Newbie : populate the value of a form in a bean
Ok thanks. I need to work on this component anyway. But things are not totally clear in my mind of the state of @Persist objects during the phase request. I 'm going to work on this as well. Ezra Epstein a écrit : Is it that the user object is null on page load? If so, see the BeanEditForm's implementation of void onPrepareFromForm() Michael Courcy <[EMAIL PROTECTED]> wrote: You're right here it is, I remove the "offending input" and use this instead ${user}-- ${user.name} And I get [EMAIL PROTECTED] -- A name Obviously user is not null. I think the problem does not come from tapestry but from me. I want to populate from the form directly to the bean. But this require to use either the beanEditForm or a custom component. I 'm just influenced by other framework like struts2 for instance : If you have something like that in your form [input] When the form is submitted struts2 tries to find if the controller features a user property, and then if user features a name property If the answer is yes to both it calls controller.getUser().setName("bla"); Ezra Epstein a �crit : I always pause when hearing "100% sure." An easy check/test is to remove the offending [input] and stick in a simple ${user} and see if indeed you get the toString() value for your user object. Michael Courcy wrote: I'm 100% sure, user is not null I have a getter and a setter for both : name and user Thanks Thiago H de Paula Figueiredo a �crit : On Wed, 14 Nov 2007 12:47:06 -0200, Michael Courcy wrote: [input] I have to provide the setter and the getter for name and I still get an error when I submit. What error? Make sure your user field is not null when the form is submited. Also make sure you have public getters and setters, because otherwise Tapestry cannot access them. -- Michael Courcy http://courcy.blogspot.com
Re: T5 Newbie : populate the value of a form in a bean
Is it that the user object is null on page load? If so, see the BeanEditForm's implementation of void onPrepareFromForm() Michael Courcy <[EMAIL PROTECTED]> wrote: You're right here it is, I remove the "offending input" and use this instead ${user}-- ${user.name} And I get [EMAIL PROTECTED] -- A name Obviously user is not null. I think the problem does not come from tapestry but from me. I want to populate from the form directly to the bean. But this require to use either the beanEditForm or a custom component. I 'm just influenced by other framework like struts2 for instance : If you have something like that in your form [input] When the form is submitted struts2 tries to find if the controller features a user property, and then if user features a name property If the answer is yes to both it calls controller.getUser().setName("bla"); Ezra Epstein a �crit : > I always pause when hearing "100% sure." An easy check/test is to remove the > offending [input] and stick in a simple ${user} and see if indeed you get > the toString() value for your user object. > > Michael Courcy wrote: I'm 100% sure, user is not null > > I have a getter and a setter for both : name and user > > Thanks > Thiago H de Paula Figueiredo a �crit : > >> On Wed, 14 Nov 2007 12:47:06 -0200, Michael Courcy >> wrote: >> >> >>> [input] >>> >>> I have to provide the setter and the getter for name and I still get >>> an error when I submit. >>> >> What error? Make sure your user field is not null when the form is >> submited. Also make sure you have public getters and setters, because >> otherwise Tapestry cannot access them. >> >> > > > -- Michael Courcy http://courcy.blogspot.com
Re: T5 Newbie : populate the value of a form in a bean
The title property of the video object is updated, I don't have a title property on my page class. I can't compile anything right now, but I'll try to put together a small example tonight, if someone else hasn't posted something by then. Josh Josh It would be really really nice !!! If you do so I would make it a small wiki tutorial Josh Canfield a écrit : Hi Michael, Thanks Josh, but do you have also a title property with getter and setter in your page class ? No, I only have the video getter/setter And if yes (as I guess) whish value is updated when you submit the form : MyPage.title or MyPage.video.title ? The title property of the video object is updated, I don't have a title property on my page class. I can't compile anything right now, but I'll try to put together a small example tonight, if someone else hasn't posted something by then. Josh On Nov 14, 2007 11:01 AM, Michael Courcy <[EMAIL PROTECTED]> wrote: Thanks Josh, but do you have also a title property with getter and setter in your page class ? And if yes (as I guess) whish value is updated when you submit the form : MyPage.title or MyPage.video.title ? Josh Canfield a écrit : >> I want to populate from the form directly to the bean. But this require to use either the beanEditForm or a custom component. You can get this to work. I use the textfield component for editing my bean objects. This is from a working emplate: My page class has a getVideo method which returns an object that has a getTitle method. Good luck, Josh On Nov 14, 2007 9:05 AM, Michael Courcy <[EMAIL PROTECTED]> wrote: You're right here it is, I remove the "offending input" and use this instead ${user}-- ${user.name} And I get [EMAIL PROTECTED] -- A name Obviously user is not null. I think the problem does not come from tapestry but from me. I want to populate from the form directly to the bean. But this require to use either the beanEditForm or a custom component. I 'm just influenced by other framework like struts2 for instance : If you have something like that in your form When the form is submitted struts2 tries to find if the controller features a user property, and then if user features a name property If the answer is yes to both it calls controller.getUser ().setName("bla"); Ezra Epstein a écrit : > I always pause when hearing "100% sure." An easy check/test is to remove the offending and stick in a simple ${user} and see if indeed you get the toString() value for your user object. Michael Courcy <[EMAIL PROTECTED]> wrote: I'm 100% sure, user is not null I have a getter and a setter for both : name and user Thanks Thiago H de Paula Figueiredo a écrit : On Wed, 14 Nov 2007 12:47:06 -0200, Michael Courcy wrote: [input] I have to provide the setter and the getter for name and I still get an error when I submit. What error? Make sure your user field is not null when the form is submited. Also make sure you have public getters and setters, because otherwise Tapestry cannot access them. -- Michael Courcy http://courcy.blogspot.com -- Michael Courcy http://courcy.blogspot.com -- Michael Courcy http://courcy.blogspot.com
Re: T5 Newbie : populate the value of a form in a bean
Hi Michael, > Thanks Josh, but do you have also a title property with getter and > setter in your page class ? > No, I only have the video getter/setter > And if yes (as I guess) whish value is updated when you submit the form > : MyPage.title or MyPage.video.title ? The title property of the video object is updated, I don't have a title property on my page class. I can't compile anything right now, but I'll try to put together a small example tonight, if someone else hasn't posted something by then. Josh On Nov 14, 2007 11:01 AM, Michael Courcy <[EMAIL PROTECTED]> wrote: > > Thanks Josh, but do you have also a title property with getter and > setter in your page class ? > > And if yes (as I guess) whish value is updated when you submit the form > : MyPage.title or MyPage.video.title ? > > Josh Canfield a écrit : > >> I want to populate from the form directly to the bean. But this > require > >> to use either the beanEditForm or a custom component. > >> > >> > > > > > > You can get this to work. I use the textfield component for editing my > bean > > objects. This is from a working emplate: > > > > > > My page class has a getVideo method which returns an object that has a > > getTitle method. > > > > Good luck, > > Josh > > > > On Nov 14, 2007 9:05 AM, Michael Courcy <[EMAIL PROTECTED]> > wrote: > > > > > >> You're right > >> > >> here it is, I remove the "offending input" > >> > >> and use this instead > >> > >> ${user}-- ${user.name} > >> > >> And I get > >> > >> [EMAIL PROTECTED] -- A name > >> > >> Obviously user is not null. > >> > >> I think the problem does not come from tapestry but from me. > >> I want to populate from the form directly to the bean. But this require > >> to use either the beanEditForm or a custom component. > >> > >> I 'm just influenced by other framework like struts2 for instance : > >> > >> If you have something like that in your form > >> > >> > >> > >> When the form is submitted struts2 tries to find if the controller > >> features a user property, and then if user features a name property > >> If the answer is yes to both it calls controller.getUser > ().setName("bla"); > >> > >> > >> > >> > >> > >> Ezra Epstein a écrit : > >> > I always pause when hearing "100% sure." An easy check/test is to > >> remove the offending and stick in a simple ${user} and see if > indeed > >> you get the toString() value for your user object. > >> > >>> Michael Courcy <[EMAIL PROTECTED]> wrote: I'm 100% sure, user > is > >>> > >> not null > >> > >>> I have a getter and a setter for both : name and user > >>> > >>> Thanks > >>> Thiago H de Paula Figueiredo a écrit : > >>> > >>> > On Wed, 14 Nov 2007 12:47:06 -0200, Michael Courcy > wrote: > > > > > [input] > > > > I have to provide the setter and the getter for name and I still get > > an error when I submit. > > > > > What error? Make sure your user field is not null when the form is > submited. Also make sure you have public getters and setters, because > otherwise Tapestry cannot access them. > > > > >>> > >>> > >> -- > >> Michael Courcy > >> http://courcy.blogspot.com > >> > >> > >> > > > > > > > > > -- > Michael Courcy > http://courcy.blogspot.com > > -- -- TheDailyTube.com. Sign up and get the best new videos on the internet delivered fresh to your inbox.
Re: T5 Newbie : populate the value of a form in a bean
Thanks Josh, but do you have also a title property with getter and setter in your page class ? And if yes (as I guess) whish value is updated when you submit the form : MyPage.title or MyPage.video.title ? Josh Canfield a écrit : I want to populate from the form directly to the bean. But this require to use either the beanEditForm or a custom component. You can get this to work. I use the textfield component for editing my bean objects. This is from a working emplate: My page class has a getVideo method which returns an object that has a getTitle method. Good luck, Josh On Nov 14, 2007 9:05 AM, Michael Courcy <[EMAIL PROTECTED]> wrote: You're right here it is, I remove the "offending input" and use this instead ${user}-- ${user.name} And I get [EMAIL PROTECTED] -- A name Obviously user is not null. I think the problem does not come from tapestry but from me. I want to populate from the form directly to the bean. But this require to use either the beanEditForm or a custom component. I 'm just influenced by other framework like struts2 for instance : If you have something like that in your form When the form is submitted struts2 tries to find if the controller features a user property, and then if user features a name property If the answer is yes to both it calls controller.getUser().setName("bla"); Ezra Epstein a écrit : > I always pause when hearing "100% sure." An easy check/test is to remove the offending and stick in a simple ${user} and see if indeed you get the toString() value for your user object. Michael Courcy <[EMAIL PROTECTED]> wrote: I'm 100% sure, user is not null I have a getter and a setter for both : name and user Thanks Thiago H de Paula Figueiredo a écrit : On Wed, 14 Nov 2007 12:47:06 -0200, Michael Courcy wrote: [input] I have to provide the setter and the getter for name and I still get an error when I submit. What error? Make sure your user field is not null when the form is submited. Also make sure you have public getters and setters, because otherwise Tapestry cannot access them. -- Michael Courcy http://courcy.blogspot.com -- Michael Courcy http://courcy.blogspot.com
Re: T5 Newbie : populate the value of a form in a bean
> > I want to populate from the form directly to the bean. But this require > to use either the beanEditForm or a custom component. > You can get this to work. I use the textfield component for editing my bean objects. This is from a working emplate: My page class has a getVideo method which returns an object that has a getTitle method. Good luck, Josh On Nov 14, 2007 9:05 AM, Michael Courcy <[EMAIL PROTECTED]> wrote: > You're right > > here it is, I remove the "offending input" > > and use this instead > > ${user}-- ${user.name} > > And I get > > [EMAIL PROTECTED] -- A name > > Obviously user is not null. > > I think the problem does not come from tapestry but from me. > I want to populate from the form directly to the bean. But this require > to use either the beanEditForm or a custom component. > > I 'm just influenced by other framework like struts2 for instance : > > If you have something like that in your form > > > > When the form is submitted struts2 tries to find if the controller > features a user property, and then if user features a name property > If the answer is yes to both it calls controller.getUser().setName("bla"); > > > > > > Ezra Epstein a écrit : > > I always pause when hearing "100% sure." An easy check/test is to > remove the offending and stick in a simple ${user} and see if indeed > you get the toString() value for your user object. > > > > Michael Courcy <[EMAIL PROTECTED]> wrote: I'm 100% sure, user is > not null > > > > I have a getter and a setter for both : name and user > > > > Thanks > > Thiago H de Paula Figueiredo a écrit : > > > >> On Wed, 14 Nov 2007 12:47:06 -0200, Michael Courcy > >> wrote: > >> > >> > >>> [input] > >>> > >>> I have to provide the setter and the getter for name and I still get > >>> an error when I submit. > >>> > >> What error? Make sure your user field is not null when the form is > >> submited. Also make sure you have public getters and setters, because > >> otherwise Tapestry cannot access them. > >> > >> > > > > > > > > > -- > Michael Courcy > http://courcy.blogspot.com > > -- -- TheDailyTube.com. Sign up and get the best new videos on the internet delivered fresh to your inbox.
Re: T5 Newbie : populate the value of a form in a bean
You're right here it is, I remove the "offending input" and use this instead ${user}-- ${user.name} And I get [EMAIL PROTECTED] -- A name Obviously user is not null. I think the problem does not come from tapestry but from me. I want to populate from the form directly to the bean. But this require to use either the beanEditForm or a custom component. I 'm just influenced by other framework like struts2 for instance : If you have something like that in your form When the form is submitted struts2 tries to find if the controller features a user property, and then if user features a name property If the answer is yes to both it calls controller.getUser().setName("bla"); Ezra Epstein a écrit : I always pause when hearing "100% sure." An easy check/test is to remove the offending and stick in a simple ${user} and see if indeed you get the toString() value for your user object. Michael Courcy <[EMAIL PROTECTED]> wrote: I'm 100% sure, user is not null I have a getter and a setter for both : name and user Thanks Thiago H de Paula Figueiredo a écrit : On Wed, 14 Nov 2007 12:47:06 -0200, Michael Courcy wrote: [input] I have to provide the setter and the getter for name and I still get an error when I submit. What error? Make sure your user field is not null when the form is submited. Also make sure you have public getters and setters, because otherwise Tapestry cannot access them. -- Michael Courcy http://courcy.blogspot.com
Re: T5 Newbie : populate the value of a form in a bean
I always pause when hearing "100% sure." An easy check/test is to remove the offending and stick in a simple ${user} and see if indeed you get the toString() value for your user object. Michael Courcy <[EMAIL PROTECTED]> wrote: I'm 100% sure, user is not null I have a getter and a setter for both : name and user Thanks Thiago H de Paula Figueiredo a écrit : > On Wed, 14 Nov 2007 12:47:06 -0200, Michael Courcy > wrote: > >> [input] >> >> I have to provide the setter and the getter for name and I still get >> an error when I submit. > > What error? Make sure your user field is not null when the form is > submited. Also make sure you have public getters and setters, because > otherwise Tapestry cannot access them. > -- Michael Courcy http://courcy.blogspot.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5 Newbie : populate the value of a form in a bean
I'm 100% sure, user is not null I have a getter and a setter for both : name and user Thanks Thiago H de Paula Figueiredo a écrit : On Wed, 14 Nov 2007 12:47:06 -0200, Michael Courcy <[EMAIL PROTECTED]> wrote: I have to provide the setter and the getter for name and I still get an error when I submit. What error? Make sure your user field is not null when the form is submited. Also make sure you have public getters and setters, because otherwise Tapestry cannot access them. -- Michael Courcy http://courcy.blogspot.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5 Newbie : populate the value of a form in a bean
On Wed, 14 Nov 2007 12:47:06 -0200, Michael Courcy <[EMAIL PROTECTED]> wrote: I have to provide the setter and the getter for name and I still get an error when I submit. What error? Make sure your user field is not null when the form is submited. Also make sure you have public getters and setters, because otherwise Tapestry cannot access them. -- Thiago H. de Paula Figueiredo Desenvolvedor, Instrutor e Consultor de Tecnologia Eteg Tecnologia da Informação Ltda. http://www.eteg.com.br - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5 Newbie : populate the value of a form in a bean
Yes and I still get the message user is not an Embedded Component CarstenM a écrit : Hi, have you tried it with @ApplicationState private User user; in your page class ? Michael Courcy wrote: Hi In my Page I have a property User, and I want to directly populate the value of the form to the bean User User.java class User{ private String name; private String surName; getters ans setters . } Start.java class Start{ private User user; getters and setters } Start.html : <||input|| ||t||:||type||=||"||TextField||"|| ||t||:||id||=||"||user.name||"|| ||t||:||value||=||"||user.name||"/> <||input|| ||t||:||type||=||"||TextField||"|| ||t||:||id||=||"||user.surName||"|| ||t||:||value||=||"||user.surName||"/> <||input|| ||t||:||id||=||"||submitform||"|| ||t||:||type||=||"||Submit||"|| ||t||:||value||=||"||submit||" /> But It seems that it does not work this way and I get an error message : User is not an embedded component... Do you think I'll have to build my own component : Or is there another way to do this without using the beanEditForm ? || -- Michael Courcy http://courcy.blogspot.com -- Michael Courcy http://courcy.blogspot.com
Re: T5 Newbie : populate the value of a form in a bean
The t:id attribute is not meant as a way to tell Tapestry what are you editing: it's just an id that you can use to refer to it in another component (Label, for example) or in your page class. Ok you're right but if I try this I get a failure because tapestry expect an id Then if I do this I have to provide the setter and the getter for name and I still get an error when I submit. The only thing that work properly is this But I comeback to my initial question : I just can't populate the value to the bean directly from the form The best thing I can do is this public String getName(){ return user.getName(); } public void setName(String name){ user.setName(name); } -- Michael Courcy http://courcy.blogspot.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5 Newbie : populate the value of a form in a bean
Hi, have you tried it with @ApplicationState private User user; in your page class ? Michael Courcy wrote: > > Hi > > In my Page I have a property User, and I want to directly populate the > value of the form to the bean User > > User.java > class User{ > private String name; > private String surName; > getters ans setters . > } > > Start.java > class Start{ >private User user; > getters and setters > } > > > Start.html : > > <||input|| ||t||:||type||=||"||TextField||"|| > ||t||:||id||=||"||user.name||"|| ||t||:||value||=||"||user.name||"/> > <||input|| ||t||:||type||=||"||TextField||"|| > ||t||:||id||=||"||user.surName||"|| > ||t||:||value||=||"||user.surName||"/> > <||input|| ||t||:||id||=||"||submitform||"|| > ||t||:||type||=||"||Submit||"|| ||t||:||value||=||"||submit||" /> > > > But It seems that it does not work this way and I get an error message : > User is not an embedded component... > > Do you think I'll have to build my own component : > > > > Or is there another way to do this without using the beanEditForm ? > || > > -- > Michael Courcy > http://courcy.blogspot.com > > > -- View this message in context: http://www.nabble.com/T5-Newbie-%3A-populate-the-value-of-a-form-in-a-bean-tf4805095.html#a13747048 Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5 Newbie : populate the value of a form in a bean
On Wed, 14 Nov 2007 11:24:03 -0200, Michael Courcy <[EMAIL PROTECTED]> wrote: Try t:id="name" instead of t:id="user.name". ;) The t:id attribute is not meant as a way to tell Tapestry what are you editing: it's just an id that you can use to refer to it in another component (Label, for example) or in your page class. -- Thiago H. de Paula Figueiredo Desenvolvedor, Instrutor e Consultor de Tecnologia Eteg Tecnologia da Informação Ltda. http://www.eteg.com.br - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]