While doing Lab3 AA (dot notation), I had some problems getting
multi-row update to work on the taskListMR page after I nested the tasks
inside a project. I only have one question at the end, but I thought I
would post my journey in case it would be helpful to other students.
Note: this post is a spoiler, so if you haven't done Lab AA, then I
wouldn't read it. By the way, I highly recommend this lab. It forced
me to a much greater understanding of what is going on.
After Lab 2, my MRTaskList.jsp looked something like this. The formBean
(fb) was a TaskBean.
<c:forEach var="row" items="${fb}">
<tr>
<td>
<c:url value="taskEdit" var ="url">
<c:param name="ID" value="${row.id}"/>
<c:param name="Dispatch" value="Edit"/>
</c:url>
<a href ='<c:out value="${url}"/>' >
<fmt:message key="button.edit"
bundle="${loc}"/>
</a>
</td>
<td>
<html:text styleClass="form" property="name"
size="20" name="row" indexed="true"/>
</td>
</tr>
</c:forEach>
After nesting, the formBean (fb) became a ProjectBean with tasks.
Accordingly, I changed the <c:forEach> to be:
<c:forEach var="row" items="${fb.tasks.displayList}">
This, of course, didn't work, so I changed the var to "tasks". This
gave me this:
<c:forEach var="tasks" items="${fb.tasks.displayList}">
<tr>
<td>
<c:url value="taskEdit" var ="url">
<c:param name="ID" value="${tasks.id}"/>
<c:param name="Dispatch" value="Edit"/>
etc.
This didn't work either, so I changed it to
<c:forEach var="tasks.row" items="${fb.tasks.displayList}">
At first, I didn't understand why this helped. Now, I do. This really
helped me to understand.
Unfortunately, I still had a problem with my "Edit" URL. It wasn't
populating the ID. Everything else worked. I tried many variations
such as:
<c:param name="ID" value="${tasks.row.id}"/>
I guess this doesn't work because "tasks.row" is not a valid variable
name.
Eventually, I got it working by using <bean:write>, as follows:
<c:param name="ID">
<bean:write name="tasks.row" property="id"/>
</c:param>
Given that we should avoid the bean tags in favor of JSTL, is there any
way to do this without using <bean:write>?
Thanks for any thoughts.
--Doug
_______________________________________________
MVC-Programmers mailing list
[EMAIL PROTECTED]
http://www.basebeans.net:8080/mailman/listinfo/mvc-programmers