Re: Little confused

2008-05-19 Thread Peter Stavrinides
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 users@tapestry.apache.org
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]



Re: Little confused

2008-05-18 Thread Manuel Corrales
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]




Re: Little confused

2008-05-18 Thread Filip S. Adamsen

Hi,

Bleeding edge 5.0.12-SNAPSHOT at the moment. @Property autogenerates 
getters and setters so you can just specify getters and setters yourself 
if you don't have access to @Property in your version of Tapestry.


-Filip

On 2008-05-18 16:33, Manuel Corrales wrote:

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]



Re: Little confused

2008-05-18 Thread Toby Hobson
@Property is certainly in 5.0.11, you can also achieve the same effect with 
standard getters and setters - in fact this is probably a better idea because 
it makes it easier to test your pages IMHO

Toby

- Original Message 
From: Manuel Corrales [EMAIL PROTECTED]
To: Tapestry users users@tapestry.apache.org
Sent: Sunday, 18 May, 2008 3:33:58 PM
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]







Re: Little confused

2008-05-18 Thread Toby Hobson
snap!

- Original Message 
From: Filip S. Adamsen [EMAIL PROTECTED]
To: Tapestry users users@tapestry.apache.org
Sent: Sunday, 18 May, 2008 6:17:09 PM
Subject: Re: Little confused

Hi,

Bleeding edge 5.0.12-SNAPSHOT at the moment. @Property autogenerates 
getters and setters so you can just specify getters and setters yourself 
if you don't have access to @Property in your version of Tapestry.

-Filip

On 2008-05-18 16:33, Manuel Corrales wrote:
 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]






Re: Little confused

2008-05-17 Thread Kevin Menard
I would probably use a lazy getter with a @Persist attached to the field.

Something like:

@Persist
private Matafuego matafuego;

public Metafuego getMetafuego()
{
   if (null == metafuego)
   {
   metafuego = new Metafuego();
   }

   return metafuego;
}

The page instance is guaranteed to be accessed by only a single thread at a
time, so that should be safe for you.

-- 
Kevin


On 5/17/08 10:01 AM, Manuel Corrales [EMAIL PROTECTED] 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]



Re: Little confused

2008-05-17 Thread Manuel Corrales
Thanks for your answer, but i still have the same issue. Maybe i am not
explaining the problem ok. I have a page with a link, when i press the link
the application goes to the new Matafuego page, where i am using a hand
made form (i mean not using beaneditorform tag). The first time i do this,
everything works fine, i complete the date press Save and the application
redirects to the main page again. But the second time i press the link to
add a new Matafuego, the form has the data i complete on the first one. The
behavior i am looking here, is that each time i access the form, i create a
new Matafuego, i mean a clean form and a new Matafuego instance.

Thanks in advance.

On Sat, May 17, 2008 at 11:54 AM, Kevin Menard [EMAIL PROTECTED]
wrote:

 I would probably use a lazy getter with a @Persist attached to the field.

 Something like:

 @Persist
 private Matafuego matafuego;

 public Metafuego getMetafuego()
 {
   if (null == metafuego)
   {
   metafuego = new Metafuego();
   }

   return metafuego;
 }

 The page instance is guaranteed to be accessed by only a single thread at a
 time, so that should be safe for you.

 --
 Kevin


 On 5/17/08 10:01 AM, Manuel Corrales [EMAIL PROTECTED] 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]




Re: Little confused

2008-05-17 Thread Ned Jackson Lovely
Set your private variable to null in your onSuccess function.

On 5/17/08, Manuel Corrales [EMAIL PROTECTED] wrote:
 Thanks for your answer, but i still have the same issue. Maybe i am not
 explaining the problem ok. I have a page with a link, when i press the link
 the application goes to the new Matafuego page, where i am using a hand
 made form (i mean not using beaneditorform tag). The first time i do this,
 everything works fine, i complete the date press Save and the application
 redirects to the main page again. But the second time i press the link to
 add a new Matafuego, the form has the data i complete on the first one. The
 behavior i am looking here, is that each time i access the form, i create a
 new Matafuego, i mean a clean form and a new Matafuego instance.

 Thanks in advance.

 On Sat, May 17, 2008 at 11:54 AM, Kevin Menard [EMAIL PROTECTED]
 wrote:

 I would probably use a lazy getter with a @Persist attached to the field.

 Something like:

 @Persist
 private Matafuego matafuego;

 public Metafuego getMetafuego()
 {
   if (null == metafuego)
   {
   metafuego = new Metafuego();
   }

   return metafuego;
 }

 The page instance is guaranteed to be accessed by only a single thread at
 a
 time, so that should be safe for you.

 --
 Kevin


 On 5/17/08 10:01 AM, Manuel Corrales [EMAIL PROTECTED] 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]





-- 
njl

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



Re: Little confused

2008-05-17 Thread Manuel Corrales
Hi Ned, the onSuccess methos is executed before the onSubmit, so that would
not work for me because i am doing the model logic on the onSubmit. I tryed
setting my variable in null after executing my businnes logic, but i still
have the same issue. My private variable should not be cleaned by Tapestry
pooling mechanism?

The only thing i can think to fix this, is to set my variable to null after
the bussines logic, and then on the onACtivate method check if its null, the
i create a new one, if its not null then i do nothing.

Thanks, and still waiting for an elegant solution to this ;)
**

On Sat, May 17, 2008 at 12:12 PM, Ned Jackson Lovely [EMAIL PROTECTED] wrote:

 Set your private variable to null in your onSuccess function.

 On 5/17/08, Manuel Corrales [EMAIL PROTECTED] wrote:
  Thanks for your answer, but i still have the same issue. Maybe i am not
  explaining the problem ok. I have a page with a link, when i press the
 link
  the application goes to the new Matafuego page, where i am using a hand
  made form (i mean not using beaneditorform tag). The first time i do
 this,
  everything works fine, i complete the date press Save and the application
  redirects to the main page again. But the second time i press the link to
  add a new Matafuego, the form has the data i complete on the first one.
 The
  behavior i am looking here, is that each time i access the form, i create
 a
  new Matafuego, i mean a clean form and a new Matafuego instance.
 
  Thanks in advance.
 
  On Sat, May 17, 2008 at 11:54 AM, Kevin Menard [EMAIL PROTECTED]
  wrote:
 
  I would probably use a lazy getter with a @Persist attached to the
 field.
 
  Something like:
 
  @Persist
  private Matafuego matafuego;
 
  public Metafuego getMetafuego()
  {
if (null == metafuego)
{
metafuego = new Metafuego();
}
 
return metafuego;
  }
 
  The page instance is guaranteed to be accessed by only a single thread
 at
  a
  time, so that should be safe for you.
 
  --
  Kevin
 
 
  On 5/17/08 10:01 AM, Manuel Corrales [EMAIL PROTECTED]
 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]
 
 
 


 --
 njl

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




Re: Little confused

2008-05-17 Thread Kevin Menard
It doesn't really matter where you clear it.  Just clear it when you're done
with it.  As for the lifecycle question, you have to clear it because you
@Persisted it.  If you didn't @Persist it, you wouldn't have to clear it,
but you'd likely lose your data when working with the form, depending on
your workflow.

This should work fine.  I do it all the time.

-- 
Kevin


On 5/17/08 12:34 PM, Manuel Corrales [EMAIL PROTECTED] wrote:

 Hi Ned, the onSuccess methos is executed before the onSubmit, so that would
 not work for me because i am doing the model logic on the onSubmit. I tryed
 setting my variable in null after executing my businnes logic, but i still
 have the same issue. My private variable should not be cleaned by Tapestry
 pooling mechanism?
 
 The only thing i can think to fix this, is to set my variable to null after
 the bussines logic, and then on the onACtivate method check if its null, the
 i create a new one, if its not null then i do nothing.
 
 Thanks, and still waiting for an elegant solution to this ;)
 **


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



Re: Little confused

2008-05-17 Thread Manuel Corrales
Ok, thanks. Probably this is some stupid begginer mistake, but i cant make
this work. My class is this:

public class NuevoMatafuego {

private Matafuego matafuego = new Matafuego();
@Inject
private Messages messages;
@Component
private Form nuevoMatafuegoForm;
@Component(id = nroAparato)
private TextField nroAparato;

public SelectModel getTiposDeMatafuego() {
return new EnumSelectModel(TipoMatafuego.class, messages);
}

public Matafuego getMatafuego() {
return matafuego;
}

public void setMatafuego(Matafuego matafuego) {
this.matafuego = matafuego;
}

void onActivate() {
if (matafuego == null) {
matafuego = new Matafuego();
}
}

@OnEvent(value = submit, component = nuevoMatafuegoForm)
Object onSubmitNuevoMatafuegoForm() {
MatafuegoFacade facade = new MatafuegoFacade();
try {
facade.guardarMatafuego(matafuego);
matafuego = null;
return MainMatafuegos.class;
} catch ( ConstraintViolationException e) {
nuevoMatafuegoForm.recordError(nroAparato,
messages.get(matafuegoDuplicado));
return this;
}
}

}


As you can see, the matafuego instance is not @Persist, so i really do not
undestand why is not being cleared. Also if instead of doing Matafuego
matafuego = new Matafuego(); on the declaration, i dont initialize it, then
when i try to save it, it is null in the onSubmit method.

Any suggestion?

On Sat, May 17, 2008 at 1:51 PM, Kevin Menard [EMAIL PROTECTED] wrote:

 It doesn't really matter where you clear it.  Just clear it when you're
 done
 with it.  As for the lifecycle question, you have to clear it because you
 @Persisted it.  If you didn't @Persist it, you wouldn't have to clear it,
 but you'd likely lose your data when working with the form, depending on
 your workflow.

 This should work fine.  I do it all the time.

 --
 Kevin


 On 5/17/08 12:34 PM, Manuel Corrales [EMAIL PROTECTED] wrote:

  Hi Ned, the onSuccess methos is executed before the onSubmit, so that
 would
  not work for me because i am doing the model logic on the onSubmit. I
 tryed
  setting my variable in null after executing my businnes logic, but i
 still
  have the same issue. My private variable should not be cleaned by
 Tapestry
  pooling mechanism?
 
  The only thing i can think to fix this, is to set my variable to null
 after
  the bussines logic, and then on the onACtivate method check if its null,
 the
  i create a new one, if its not null then i do nothing.
 
  Thanks, and still waiting for an elegant solution to this ;)
  **


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




Re: Little confused

2008-05-17 Thread Manuel Corrales
Sorry, my mistake. The same code i posted but without initializing the
matafuego variable is working now. I still dont completely understand why
tapestry is not cleaning my matafuego variable.

Thanks very much for your help!

On Sat, May 17, 2008 at 2:39 PM, Manuel Corrales [EMAIL PROTECTED]
wrote:

 Ok, thanks. Probably this is some stupid begginer mistake, but i cant make
 this work. My class is this:

 public class NuevoMatafuego {

 private Matafuego matafuego = new Matafuego();
 @Inject
 private Messages messages;
 @Component
 private Form nuevoMatafuegoForm;
 @Component(id = nroAparato)
 private TextField nroAparato;

 public SelectModel getTiposDeMatafuego() {
 return new EnumSelectModel(TipoMatafuego.class, messages);
 }

 public Matafuego getMatafuego() {
 return matafuego;
 }

 public void setMatafuego(Matafuego matafuego) {
 this.matafuego = matafuego;
 }

 void onActivate() {
 if (matafuego == null) {
 matafuego = new Matafuego();
 }
 }

 @OnEvent(value = submit, component = nuevoMatafuegoForm)
 Object onSubmitNuevoMatafuegoForm() {
 MatafuegoFacade facade = new MatafuegoFacade();
 try {
 facade.guardarMatafuego(matafuego);
 matafuego = null;
 return MainMatafuegos.class;
 } catch ( ConstraintViolationException e) {
 nuevoMatafuegoForm.recordError(nroAparato,
 messages.get(matafuegoDuplicado));
 return this;
 }
 }

 }


 As you can see, the matafuego instance is not @Persist, so i really do not
 undestand why is not being cleared. Also if instead of doing Matafuego
 matafuego = new Matafuego(); on the declaration, i dont initialize it, then
 when i try to save it, it is null in the onSubmit method.

 Any suggestion?


 On Sat, May 17, 2008 at 1:51 PM, Kevin Menard [EMAIL PROTECTED]
 wrote:

 It doesn't really matter where you clear it.  Just clear it when you're
 done
 with it.  As for the lifecycle question, you have to clear it because you
 @Persisted it.  If you didn't @Persist it, you wouldn't have to clear it,
 but you'd likely lose your data when working with the form, depending on
 your workflow.

 This should work fine.  I do it all the time.

 --
 Kevin


 On 5/17/08 12:34 PM, Manuel Corrales [EMAIL PROTECTED] wrote:

  Hi Ned, the onSuccess methos is executed before the onSubmit, so that
 would
  not work for me because i am doing the model logic on the onSubmit. I
 tryed
  setting my variable in null after executing my businnes logic, but i
 still
  have the same issue. My private variable should not be cleaned by
 Tapestry
  pooling mechanism?
 
  The only thing i can think to fix this, is to set my variable to null
 after
  the bussines logic, and then on the onACtivate method check if its null,
 the
  i create a new one, if its not null then i do nothing.
 
  Thanks, and still waiting for an elegant solution to this ;)
  **


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





Re: Little confused

2008-05-17 Thread Manuel Corrales
Ok, me bothering again. Now when i have a validation error that was checked
on the server side, the form is completely wiped out. Thats the normal
behavior?

On Sat, May 17, 2008 at 2:49 PM, Manuel Corrales [EMAIL PROTECTED]
wrote:

 Sorry, my mistake. The same code i posted but without initializing the
 matafuego variable is working now. I still dont completely understand why
 tapestry is not cleaning my matafuego variable.

 Thanks very much for your help!


 On Sat, May 17, 2008 at 2:39 PM, Manuel Corrales [EMAIL PROTECTED]
 wrote:

 Ok, thanks. Probably this is some stupid begginer mistake, but i cant make
 this work. My class is this:

 public class NuevoMatafuego {

 private Matafuego matafuego = new Matafuego();
 @Inject
 private Messages messages;
 @Component
 private Form nuevoMatafuegoForm;
 @Component(id = nroAparato)
 private TextField nroAparato;

 public SelectModel getTiposDeMatafuego() {
 return new EnumSelectModel(TipoMatafuego.class, messages);
 }

 public Matafuego getMatafuego() {
 return matafuego;
 }

 public void setMatafuego(Matafuego matafuego) {
 this.matafuego = matafuego;
 }

 void onActivate() {
 if (matafuego == null) {
 matafuego = new Matafuego();
 }
 }

 @OnEvent(value = submit, component = nuevoMatafuegoForm)
 Object onSubmitNuevoMatafuegoForm() {
 MatafuegoFacade facade = new MatafuegoFacade();
 try {
 facade.guardarMatafuego(matafuego);
 matafuego = null;
 return MainMatafuegos.class;
 } catch ( ConstraintViolationException e) {
 nuevoMatafuegoForm.recordError(nroAparato,
 messages.get(matafuegoDuplicado));
 return this;
 }
 }

 }


 As you can see, the matafuego instance is not @Persist, so i really do not
 undestand why is not being cleared. Also if instead of doing Matafuego
 matafuego = new Matafuego(); on the declaration, i dont initialize it, then
 when i try to save it, it is null in the onSubmit method.

 Any suggestion?


 On Sat, May 17, 2008 at 1:51 PM, Kevin Menard [EMAIL PROTECTED]
 wrote:

 It doesn't really matter where you clear it.  Just clear it when you're
 done
 with it.  As for the lifecycle question, you have to clear it because you
 @Persisted it.  If you didn't @Persist it, you wouldn't have to clear it,
 but you'd likely lose your data when working with the form, depending on
 your workflow.

 This should work fine.  I do it all the time.

 --
 Kevin


 On 5/17/08 12:34 PM, Manuel Corrales [EMAIL PROTECTED] wrote:

  Hi Ned, the onSuccess methos is executed before the onSubmit, so that
 would
  not work for me because i am doing the model logic on the onSubmit. I
 tryed
  setting my variable in null after executing my businnes logic, but i
 still
  have the same issue. My private variable should not be cleaned by
 Tapestry
  pooling mechanism?
 
  The only thing i can think to fix this, is to set my variable to null
 after
  the bussines logic, and then on the onACtivate method check if its
 null, the
  i create a new one, if its not null then i do nothing.
 
  Thanks, and still waiting for an elegant solution to this ;)
  **


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






Re: Little confused

2008-05-17 Thread Manuel Corrales
Well, i think i am really screwing thnigs up. Very sorry for abusing of your
time, i have almost everything working ok. Thanks for your time!

On Sat, May 17, 2008 at 2:57 PM, Manuel Corrales [EMAIL PROTECTED]
wrote:

 Ok, me bothering again. Now when i have a validation error that was checked
 on the server side, the form is completely wiped out. Thats the normal
 behavior?


 On Sat, May 17, 2008 at 2:49 PM, Manuel Corrales [EMAIL PROTECTED]
 wrote:

 Sorry, my mistake. The same code i posted but without initializing the
 matafuego variable is working now. I still dont completely understand why
 tapestry is not cleaning my matafuego variable.

 Thanks very much for your help!


 On Sat, May 17, 2008 at 2:39 PM, Manuel Corrales 
 [EMAIL PROTECTED] wrote:

 Ok, thanks. Probably this is some stupid begginer mistake, but i cant
 make this work. My class is this:

 public class NuevoMatafuego {

 private Matafuego matafuego = new Matafuego();
 @Inject
 private Messages messages;
 @Component
 private Form nuevoMatafuegoForm;
 @Component(id = nroAparato)
 private TextField nroAparato;

 public SelectModel getTiposDeMatafuego() {
 return new EnumSelectModel(TipoMatafuego.class, messages);
 }

 public Matafuego getMatafuego() {
 return matafuego;
 }

 public void setMatafuego(Matafuego matafuego) {
 this.matafuego = matafuego;
 }

 void onActivate() {
 if (matafuego == null) {
 matafuego = new Matafuego();
 }
 }

 @OnEvent(value = submit, component = nuevoMatafuegoForm)
 Object onSubmitNuevoMatafuegoForm() {
 MatafuegoFacade facade = new MatafuegoFacade();
 try {
 facade.guardarMatafuego(matafuego);
 matafuego = null;
 return MainMatafuegos.class;
 } catch ( ConstraintViolationException e) {
 nuevoMatafuegoForm.recordError(nroAparato,
 messages.get(matafuegoDuplicado));
 return this;
 }
 }

 }


 As you can see, the matafuego instance is not @Persist, so i really do
 not undestand why is not being cleared. Also if instead of doing Matafuego
 matafuego = new Matafuego(); on the declaration, i dont initialize it, then
 when i try to save it, it is null in the onSubmit method.

 Any suggestion?


 On Sat, May 17, 2008 at 1:51 PM, Kevin Menard [EMAIL PROTECTED]
 wrote:

 It doesn't really matter where you clear it.  Just clear it when you're
 done
 with it.  As for the lifecycle question, you have to clear it because
 you
 @Persisted it.  If you didn't @Persist it, you wouldn't have to clear
 it,
 but you'd likely lose your data when working with the form, depending on
 your workflow.

 This should work fine.  I do it all the time.

 --
 Kevin


 On 5/17/08 12:34 PM, Manuel Corrales [EMAIL PROTECTED]
 wrote:

  Hi Ned, the onSuccess methos is executed before the onSubmit, so that
 would
  not work for me because i am doing the model logic on the onSubmit. I
 tryed
  setting my variable in null after executing my businnes logic, but i
 still
  have the same issue. My private variable should not be cleaned by
 Tapestry
  pooling mechanism?
 
  The only thing i can think to fix this, is to set my variable to null
 after
  the bussines logic, and then on the onACtivate method check if its
 null, the
  i create a new one, if its not null then i do nothing.
 
  Thanks, and still waiting for an elegant solution to this ;)
  **


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







Re: Little confused

2008-05-17 Thread Filip S. Adamsen

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]