Announcement Announcement Module
Collapse
No announcement yet.
binding & rendering lists in JSP Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • binding & rendering lists in JSP

    Hi,

    i am having an issue I cant resolve here:

    I have an ArrayList that gets populated and added to the model:

    Code:
    ArrayList<WorkOrder> includedWorkOrders = new ArrayList<WorkOrder>();
    ...
    ...
    myModel.put("openWorkOrders", includedWorkOrders.toArray(new WorkOrder[0]));
    return new ModelAndView("viewStreetlight", myModel);
    I am using a custom PropertyEditor (binder.registerCustomEditor(()) for several GregorianDate fields in WorkOrder, and therefore found that the <spring:bind> tag is the right thing to use:



    Code:
    <c:forEach items="${openWorkOrders}" varStatus="loop">
          <spring:bind path="openWorkOrders[${$loop.index}].checkoutAt">
             <c:out value="${status.value}"/>
          </spring:bind>
    </c:forEach>
    This yields:
    Neither Errors instance nor plain target object for bean name 'openWorkOrders[]' available as request attribute



    I also tried doing it by refering them directly via ${} in the JSP, but then the PropertyEditor never gets triggered and I get ugly .toString() versions instead:

    Code:
    .....
    ....
    <c:forEach items="${openWorkOrders}" var="workOrder">
    <td><c:out value="${workOrder.dateDeadline}" /></td>
    ....
    ....

    What am I doing wrong here ?

    Kind regards,

    Oyvind

  • #2
    You can only bind to a form backing object. You cannot bind to whatever you like. Checkout chapter 13 of the reference guide and the included samples of the Spring Framework.

    Comment


    • #3
      Thanks,
      thats what I suspected.

      In my case, I am interested in displaying several bean properties outside the form itself, from several beans. I guess the answer to my problem would be to make an own command-bean containing the others, or is there a way for the JSP to trigger the PropertyEditor using ${}-references ?

      again, thanks


      Oyvind

      Comment

      Working...
      X