Thanks for the suggestion. This looks like a great idea, but it didn't work for me exactly as-is. I still get an NPE when Tapestry is trying to bind component parameters in the level just above ViewDonkeyInlineEdit.
The point of code with the problem is where I'm passing <t:viewDonkeyInlineEdit donkey="fooLoopVar.donkey"/> in Test.tml. When Tapestry tries to process this parameter binding when attempting to fire my startEditDonkey event, it sees that fooLoopVar is null, so I get the NPE. I need to get fooLoopVar to be NOT NULL when T5 is processing the parameter binding. This did get me to think of another possible solution, though. I could use your suggestion of a context parameter, but also make a change to Test.java: <t:viewDonkeyInlineEdit donkey="fooLoopVar.donkey"/> becomes <t:viewDonkeyInlineEdit donkey="fooLoopVarDotDonkey"/> Then add this to Test.java: public getFooLoopVarDotDonkey() { if(fooLoopVar!=null) return fooLoopVar.getDonkey() else return null; } This will allow Tapestry to process the parameter binding without hitting a null pointer exception and thus allow it to actually trigger my event code so that I can actually retrieve the donkey using the ID passed in the EventLink's action context. I'll test this out and let you know how it works. -Nathan On Mon, Feb 15, 2010 at 3:32 PM, Thiago H. de Paula Figueiredo < thi...@arsmachina.com.br> wrote: > Try this: > > <t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd > " > xmlns:p="tapestry:parameter"> > Donkey's name: ${donkey.name}<br/> > <t:if test="editing"> > <t:form context="donkey.id"> > <t:errors/> > Description: <t:textfield value="editDonkey.descr" size="50"/> > <t:submit value="Save" event="saveEditDonkey"/> <t:eventlink > event="cancelEditDonkey">Cancel</t:eventlink><br/> > </t:form> > <p:else> > Description: ${donkey.descr} <t:eventlink > event="startEditDonkey" context="donkey.id">Edit</t:eventlink><br/> > </p:else> > </t:if> > </t:container> > > The only differences here are the use of the context parameter to Form and > EventLink. You can replace id by any field or info that is unique for all > donkeys. > > public class ViewDonkeyInlineEdit > { > @Property @Parameter private Donkey donkey; > @Persist @Property private Donkey editDonkey; > public boolean isEditing() { > return (editDonkey!=null && > editDonkey.getName().equals(donkey.getName())); > } > public void onStartEditDonkey(Integer id) { > // get donkey by id and do any processing needed. > } > public void onSaveEditDonkey(Integer id) { > // get donkey by id > donkey.setDescr(editDonkey.getDescr()); > editDonkey = null; > } > public void onCancelEditDonkey() { > editDonkey = null; > } > } > > By the way, I guess you don't need to @Persist the editDonkey field. > > -- > Thiago H. de Paula Figueiredo > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, > and instructor > Owner, software architect and developer, Ars Machina Tecnologia da > Informação Ltda. > http://www.arsmachina.com.br > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >