You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Howard Lewis Ship <hl...@gmail.com> on 2011/09/02 01:55:13 UTC

tapestry-hibernate handling of transients instances ValueEncoder

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: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


Re: tapestry-hibernate handling of transients instances ValueEncoder

Posted by Howard Lewis Ship <hl...@gmail.com>.
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 <ul...@spielviel.de> 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: dev-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: dev-help@tapestry.apache.org
>
>



-- 
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: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


Re: tapestry-hibernate handling of transients instances ValueEncoder

Posted by Ulrich Stärk <ul...@spielviel.de>.
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: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


Re: tapestry-hibernate handling of transients instances ValueEncoder

Posted by Barry Books <tr...@gmail.com>.
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: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


Re: tapestry-hibernate handling of transients instances ValueEncoder

Posted by Massimo Lusetti <ml...@gmail.com>.
On Fri, Sep 2, 2011 at 1:55 AM, Howard Lewis Ship <hl...@gmail.com> 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: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org