Hi,

I'm not sure if this is a basic JSP question or a Stripes Layout
question. I'd just explain:

In my application I try to simplify the use of indexed properties. The
basic pattern is described here:
http://www.stripesframework.org/display/stripes/Indexed+Properties

Now, looking at the pattern it consists of the following blocks:

(for)
  (input fields 0...n)
(endfor)
(input fields n+1)

Means: First all existing items are shown with the respective input
fields and then in the end there are empty fields for new entries.

This approach is highly redundant:
- It requires to repeat (in the example) "people[${loop.index}]" a lot
- The same fields are repeated outside the loop

My approach was to use templating in combination with conventions for
my ActionBeans, such as:

All action beans should implement this interface:
public interface Indexed<T> {
  public List<T> getItems();
  public void setItems(List<T> items);
}

<stripes:layout-definition>
  <c:forEach items="${actionBean.items}" var="item" varStatus="loop">
    <c:set var="i" value="${loop.index}" scope="page"/>
    <stripes:hidden name="items[${i}].id" value="${item.id}"/>
    <stripes:layout-component name="contents"/>
  </c:forEach>
  <c:set var="i" value="${f:length(actionBean.items)}"/>
  <stripes:layout-component name="contents"/>
</stripes:layout-definition>

and then the layout can be used:

<stripes:layout-render name="/layout/default.jsp">
  <stripes:layout-component name="contents">
    <stripes:text name="items[${i}].firstName" value="${item.firstName}"/>
    ...
  </stripes:layout-component>
</stripes:layout-render>

But the problemis: The variable ${i} is undefined in when using the
template. This throws an exception.

Is there any workaround for this? Or am I missing something?

Regards,
Moritz

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to