On Wed, 2004-11-17 at 09:52 +0100, Sylvain Wallez wrote:
> Jonas Ekstedt wrote:
<snip/>
> > Suppose you have a list of tasks that can be viewed/edited. In
> >edit mode all tasks you have been assigned will show a "Finished"
> >button. In JXTemplate you could do this very easy:
> >
> ><jx:forEach var="task" items="${tasks}">
> > <tr>
> > <td>${task.description}</td>
> > <td>
> > <jx:if test="${edit == 'true' and task.assignedTo == user.id}">
> > <button name="task.${task.id}.finished">Finished</button>
> > </jx:if>
> > </td>
> > </tr>
> ></jx:forEach>
> >
> >The model would of course also check that the user trying to finish a
> >task is indeed the assigned user.
> >
> >In CForm I think it would be very difficult to do something like this.
> >Even if using union widgets.
> >
>
> Unions won't be useful here, as we don't have structure variations, but
> a single widget whose state depends on some model and/or other widget
> values.
>
> >You would have to resort to using flow and iterate through all tasks and
> >enable/disable the buttons individually.
> >
> >
>
> That can be handled automatically in the binding when the form is filled
> with task data.
But what would happen if I reassign a task to myself in the example
above. Then the form would have to be saved and reloaded in order for
the "Finish" button to show up. I fail to see what would be so bad in
using JXTemplate logic to decide which widgets should be shown.
Cheers Jonas