Quantcast

tapestry-hibernate handling of transients instances ValueEncoder

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

tapestry-hibernate handling of transients instances ValueEncoder

Howard Lewis Ship
I'm helping a client build a CRUD app on top of tapestry-hibernate

His pattern is to use the same exact page for edit and create pages

The problem he's getting is this:

  @PageActivationContext
  private MyEntity myEntity;

  void onActivate() { if (myEntity == null) { myEntity = new MyEntity(); } }

This works fine for editing of existing entities, but the creation
fails ... tapestry-hibernate's ValueEncoder attempts to encode the
transient instance and gets a failure because there's no persistent id
until it is made persistent.

I'd like to change the support to handle this case by returning a null
or empty page activation context when the object to be encoded is null
or transient.

This is a quasi-backwards-compatible change ... it will enable a
behavior that, in prior releases, would be a runtime exception.

Thoughts?

--
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: tapestry-hibernate handling of transients instances ValueEncoder

Massimo Lusetti
On Fri, Sep 2, 2011 at 1:55 AM, Howard Lewis Ship <[hidden email]> wrote:

> I'm helping a client build a CRUD app on top of tapestry-hibernate
>
> His pattern is to use the same exact page for edit and create pages
>
> The problem he's getting is this:
>
>  @PageActivationContext
>  private MyEntity myEntity;
>
>  void onActivate() { if (myEntity == null) { myEntity = new MyEntity(); } }
>
> This works fine for editing of existing entities, but the creation
> fails ... tapestry-hibernate's ValueEncoder attempts to encode the
> transient instance and gets a failure because there's no persistent id
> until it is made persistent.
>
> I'd like to change the support to handle this case by returning a null
> or empty page activation context when the object to be encoded is null
> or transient.
>
> This is a quasi-backwards-compatible change ... it will enable a
> behavior that, in prior releases, would be a runtime exception.
>
> Thoughts?

I've always managed my entity objects myself cause transient instances
are a nightmare... everything which can help in that area is welcome.

Cheers
--
Massimo
http://meridio.blogspot.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: tapestry-hibernate handling of transients instances ValueEncoder

trsvax
I gave up trying to use the same page for create and edit because it
takes more code to use one page than two. My thought would be to do
this

@PageActivationContext(create=true)
private MyEntity myEntity;

This would create the object if you do not pass one in. Then you don't
have any backward compatibility problems and you don't have to have
any code in the activation context.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: tapestry-hibernate handling of transients instances ValueEncoder

"Ulrich Stärk"
In reply to this post by Howard Lewis Ship
Why don't you let beaneditform handle the creation of new entities? I'm doing this all over my apps
and never had a problem with tapestry-hibernate's ValueEncoder getting into my way...

Uli

On 02.09.2011 01:55, Howard Lewis Ship wrote:

> I'm helping a client build a CRUD app on top of tapestry-hibernate
>
> His pattern is to use the same exact page for edit and create pages
>
> The problem he's getting is this:
>
>   @PageActivationContext
>   private MyEntity myEntity;
>
>   void onActivate() { if (myEntity == null) { myEntity = new MyEntity(); } }
>
> This works fine for editing of existing entities, but the creation
> fails ... tapestry-hibernate's ValueEncoder attempts to encode the
> transient instance and gets a failure because there's no persistent id
> until it is made persistent.
>
> I'd like to change the support to handle this case by returning a null
> or empty page activation context when the object to be encoded is null
> or transient.
>
> This is a quasi-backwards-compatible change ... it will enable a
> behavior that, in prior releases, would be a runtime exception.
>
> Thoughts?
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: tapestry-hibernate handling of transients instances ValueEncoder

Howard Lewis Ship
It's not my app, I'm just doing some consulting, and the author
prefers this approach. He isn't using much BeanEditForm either. Also,
that would not help with the primary situation described below ... he
has a @PageActivationContext field that stores either a transient or a
persistent Hibernate entity.

On Tue, Sep 6, 2011 at 12:54 AM, Ulrich Stärk <[hidden email]> wrote:

> Why don't you let beaneditform handle the creation of new entities? I'm doing this all over my apps
> and never had a problem with tapestry-hibernate's ValueEncoder getting into my way...
>
> Uli
>
> On 02.09.2011 01:55, Howard Lewis Ship wrote:
>> I'm helping a client build a CRUD app on top of tapestry-hibernate
>>
>> His pattern is to use the same exact page for edit and create pages
>>
>> The problem he's getting is this:
>>
>>   @PageActivationContext
>>   private MyEntity myEntity;
>>
>>   void onActivate() { if (myEntity == null) { myEntity = new MyEntity(); } }
>>
>> This works fine for editing of existing entities, but the creation
>> fails ... tapestry-hibernate's ValueEncoder attempts to encode the
>> transient instance and gets a failure because there's no persistent id
>> until it is made persistent.
>>
>> I'd like to change the support to handle this case by returning a null
>> or empty page activation context when the object to be encoded is null
>> or transient.
>>
>> This is a quasi-backwards-compatible change ... it will enable a
>> behavior that, in prior releases, would be a runtime exception.
>>
>> Thoughts?
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



--
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...