Hello,

I have some problems getting started with Tapestry grids and forms.

Here are my classes and templates:

*<t:recruiters.recruiterslayout xmlns:t="
http://tapestry.apache.org/schema/tapestry_5_1_0.xsd";
xmlns:p="tapestry:parameter">
    <form t:type="form" t:id="jobPostings">
        <t:grid source="jobPostings" row="jobPosting" add="actions"
exclude="jobPostingValidationDate">
            <p:actionscell>
                <t:submit t:id="activate" context="jobPosting"
value="activate" event="activate"/><br />
                <t:submit t:id="modify" context="jobPosting" value="modify"
event="modify" /><br />
                <t:submit t:id="delete" context="jobPosting" value="delete"
event="delete" /> <br />
                <t:submit t:id="pause" context="jobPosting" value="pause"
event="pause" />
            </p:actionscell>
         </t:grid>
    </form>
</t:recruiters.recruiterslayout>*

and:
*
public class JobPostingsTable {

    @Property
    private List<JobPosting> jobPostings;

    @Property
    @PageActivationContext
    private JobPosting jobPosting;

    @Property
    private Date date;

    @Inject
    private CheetahService service;

    @Inject
    private PageRenderLinkSource pageRenderLinkSource;


    @OnEvent(EventConstants.ACTIVATE)
    void loadJobPostings() {
        jobPostings = service.loadJobPostings();
    }

    @OnEvent("activate")
    void activateJobPosting(JobPosting jobPosting) {
        service.activateJobPosting(jobPosting);
    }

    @OnEvent("pause")
    void pauseJobPosting(JobPosting jobPosting) {
        service.pauseJobPosting(jobPosting);
    }

    @OnEvent(value = "modify")
    Link modifyJobPosting(JobPosting jobPosting) {
        return
pageRenderLinkSource.createPageRenderLinkWithContext(ModifyJobPosting.class,
jobPosting);
    }

    @OnEvent(value = "delete")
    Link deleteJobPosting(JobPosting jobPosting) {
        return
pageRenderLinkSource.createPageRenderLinkWithContext(DeleteJobPosting.class,
jobPosting);
    }

}*

The current behavior is for my form *to consider that the current row is
always the last one*!! Note that I would rather use the JobPosting as a
context instead of the JobPosting id and I have implemented a
JobPostingValueEncoder to that effect:
*
public class JobPostingEncoder implements ValueEncoder<JobPosting> {
    private CheetahService service;

    public JobPostingEncoder(CheetahService service) {
        this.service = service;
    }

    @Override
    public String toClient(JobPosting jobPosting) {
        return String.valueOf(jobPosting.getIdJobPosting());
    }

    @Override
    public JobPosting toValue(String clientValue) {
        Integer id = Integer.valueOf(clientValue);
        return service.findJobPostingById(id);
    }
}*

Can anyone please help. I am available to provide more information.

Thanks very much in advance,

Julien.

Reply via email to