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

Reply via email to