I would definitely avoid using this:
private Matafuego matafuego = new Matafuego();
This is the correct way to initialize beans for forms
void onPrepare(){
if (matafuego == null)
matafuego = new Matafuego();
}
You shouldn't use/need a @Persist, at best a @Persist("flash") if you post to
the same page.
----- Original Message -----
From: "Manuel Corrales" <[EMAIL PROTECTED]>
To: "Tapestry users" <[email protected]>
Sent: Sunday, 18 May, 2008 5:33:58 PM GMT +02:00 Athens, Beirut, Bucharest,
Istanbul
Subject: Re: Little confused
Hi Filip, i have no @Property annotation on my Tapestry version. What
version are you using?
On Sat, May 17, 2008 at 7:55 PM, Filip S. Adamsen <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've found the following pattern to work very well - at least I use it
> everywhere on several sites in production with no problems. :)
>
> @Property
> private Item item;
>
> // I have a form in my template with t:id="add"
> void onPrepareFromAdd() {
> if (null == item) item = new Item();
> }
>
> void onSuccessFromAdd() {
> // go about my business with the item
> ...
> // I'd normally return here, but since you need
> // something done in onSubmit...
> }
>
> Object onSubmitFromAdd() {
> // do what you need to do
> return ...;
> }
>
> I sometimes persist the item if needed.
>
> Hope this helps.
>
> -Filip
>
>
> On 2008-05-17 16:01, Manuel Corrales wrote:
>
>> Hi, here is my problem. I have a bean on my java page, but i am not using
>> the beaneditorform component to create a new one. Acording to Alexander
>> book, the beaneditorform component can handle the initialization of the
>> bean, so you dont have to create one. As i am not using this component,
>> should i define the bean with a sentence like this:
>>
>> private Matafuego matafuego = new Matafuego();
>>
>> or should i create the new instance on the onActivate method?
>>
>> I tryied the first approach, but the bean is always the same (i guess
>> because of the page pooling mechanism). What is the right approach to
>> this?
>>
>> Thanks very much.
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]