« Return to Thread: Validating nested loops with helper classes

Validating nested loops with helper classes

by Stephan Windmüller-8 :: Rate this Message:

Reply to Author | View in Thread

Hello!

I am trying to create a simple use-case with Tapestry components, but I
am unsure how to handle this correctly. Perhaps someone knows a solution.

The site is used to assign users to jobs. Each job has a java.util.List
of users assigned to it. Of course a user should not be assigned twice
to a job. So basically my class should look like

public class Job {
        private String title;
        private List<User> assignments;

        ... getter/setter ...
}

Unfortunately the List is not part of the class, I have to get it
directly from the database. So I wrote a helper bean class DisplayJob
which contains the assignments.

Now I want to create a page that displays all jobs and for each job the
assigned users. My first try is a table with

-----

<tr t:type="loop" t:source="jobs" t:encoder="jobEncoder" t:value="job">
 <td>${job.title}</td>

 <td t:type="loop" t:source="job.assignments" t:value="user"
t:encoder="jobEncoder">

 <select t:type="select" t:id="job" t:model="userModel" t:value="user"
t:encoder="userEncoder" blankLabel="Unassigned" />

 </td>
</tr>

-----

All jobs and select boxes are drawn as expected, but now I am stuck.
After submitting the form the values reset, job.assignments is never
changed. Also I am unable to validate if a user has been assigned twice
or more to a job.

JobEncoder creates a new DisplayJob, reading the assignments from the
database, so the data is of course not changed. But where is the place
to change the database?

Does anyone know how I can accomplish this task? Or is it even possible
to display the data in a Grid component?

TIA
 Stephan

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

 « Return to Thread: Validating nested loops with helper classes