Good thought, but the copy of Donkey isn't the problem.  (Actually, when
using Hibernate or JPA, you'd want to make a copy to allow "cancel" to work,
because altering a JPA entity by binding directly to the "real" instance
could cause the database to be updated immediately... JPA/Hibernate doesn't
wait for you to call any saveToDb or persist method.)  Note that my instance
used for editing has the @Persist annotation, so Tapestry does a great job
remembering its state.

Even with your suggested change, this would still generate a null pointer
exception (NPE) in the same place, since the problem lies with "fooLoopVar"
being null when the eventlink is click is processed by Tapestry.  The NPE
happens before I even get to rendering the description text field.

-Nathan

On Sun, Feb 14, 2010 at 2:02 PM, <p.stavrini...@albourne.com> wrote:

> Hi Nathan,
>
> > Anywhere on my site where I display a Donkey, I want to let the user edit
> the instance.
> So then do exactly that... Tapestry 5 is sometimes simpler than you might
> expect, to me it seems you are complicating things unnecessarily... why are
> you creating new instances when editing? You shouldn't need to, simply pass
> in foo and call getDonkey and edit that instance. Your loop should just
> work, simply bind foo and the correct instance will always be bound, with a
> new instance of the inlinedit component for every iteration, so you have no
> need for extended context info in this case.
>
>    <t:loop source="fooList" value="fooLoopVar">
>        Here's a foo: ${fooLoopVar.name}<br/>
>         <t:viewDonkeyInlineEdit foo="fooLoopVar"/><br/><br/>
>    </t:loop>
>
>
> public class ViewDonkeyInlineEdit
> {
>    @Parameter (allownull=false, required=true)
>    @Property
>    private Foo foo;
>
>
>    //wired to your event onEdit etc.
>    @Persist @Property private Boolean isEditing;
>
>
>    public void onSaveEditDonkey() {
>        foo.getDonkey().saveToDB();
>    }
> }
>
>
> Description: <t:textfield value="foo.donkey.descr" size="50"/>
>
> Its that simple.
>
> Peter
>
>
> ----- Original Message -----
> From: "Nathan Kopp" <nathan.k...@gmail.com>
> To: users@tapestry.apache.org
> Sent: Sunday, 14 February, 2010 04:10:02 GMT +02:00 Athens, Beirut,
> Bucharest, Istanbul
> Subject: Activation context for a component?
>
> Hey everyone!  I'm new here and I apologize for not lurking long before
> posting.  I have searched the archives extensively for this issue and have
> come up empty, so I'm just going to jump in.
> [clip]
>

Reply via email to