You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Sven Homburg <ho...@googlemail.com> on 2008/05/15 00:43:52 UTC

best practice

hi there,

situation:
1. i have an edit page for an entity "Report"
2. if the page activated, the method onActivate

    public void onActivate(long primaryKey)
    {
        this.primaryKey = primaryKey;
        if (this.entity == null)
        {
            if (this.primaryKey == 0)
                this.entity = instantiateEntity();
            else
                this.entity = (Report) getDAO().doRetrieve(primaryKey,
false);
        }
    }

this.entity is a private field declared by
    @Persist("flash")
    @Property
    private Report entity;

after i clicked on the action link "del" (look the attached image)
an element from the list (attached to the entiy) should removed.

problem:
after i click the actionlink "del", tapestry reacts in following manner


   1. onActivate (this.entity is not null)
   2. @OnEvent(component = "parameterEditor") void doDeleteParameter(long
   id);
   the list element removed but the entity not persisted.
   3. onActivate (this.entity is null and re-readed from database)


are there any suggestions to prevent the re-reading of the entity after
clicking an action/eventlink?

-- 
with regards
Sven Homburg
http://tapestry5-components.googlecode.com

Re: best practice

Posted by Josh Canfield <jo...@thedailytube.com>.
> onActivate (this.entity is not null)
> @OnEvent(component = "parameterEditor") void doDeleteParameter(long id);
> the list element removed but the entity not persisted.
> onActivate (this.entity is null and re-readed from database)
>
> are there any suggestions to prevent the re-reading of the entity after
> clicking an action/eventlink?

You're using @Persist("flash") so you only get to read it from the
session once, then it gets null'd out. Since you want it to live
longer than one read you could use "session" instead of "flash".
Another option is to re-set the value by implementing the entity
setter method and calling it in the doDeleteParameter handler. That
would ensure that the entity was available in the next onActivate read
of the property.

Josh

On Wed, May 14, 2008 at 3:43 PM, Sven Homburg <ho...@googlemail.com> wrote:
> hi there,
>
> situation:
> 1. i have an edit page for an entity "Report"
> 2. if the page activated, the method onActivate
>
>     public void onActivate(long primaryKey)
>     {
>         this.primaryKey = primaryKey;
>         if (this.entity == null)
>         {
>             if (this.primaryKey == 0)
>                 this.entity = instantiateEntity();
>             else
>                 this.entity = (Report) getDAO().doRetrieve(primaryKey,
> false);
>         }
>     }
>
> this.entity is a private field declared by
>     @Persist("flash")
>     @Property
>     private Report entity;
>
> after i clicked on the action link "del" (look the attached image)
> an element from the list (attached to the entiy) should removed.
>
> problem:
> after i click the actionlink "del", tapestry reacts in following manner
>
> onActivate (this.entity is not null)
> @OnEvent(component = "parameterEditor") void doDeleteParameter(long id);
> the list element removed but the entity not persisted.
> onActivate (this.entity is null and re-readed from database)
>
> are there any suggestions to prevent the re-reading of the entity after
> clicking an action/eventlink?
>
> --
> with regards
> Sven Homburg
> http://tapestry5-components.googlecode.com
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org