I ended up overriding the 'evaluateExtraParams()' method and performing the 
exact same logic that is in the ListUIBean.evaluateExtraParams() to set a new 
parameter called 'listCopy' to use in the extra iterator.

Code:
@Override 
public void evaluateExtraParams() { 
    super.evaluateExtraParams();
    //This is the same logic as in 'evaluateExtraParams()' but I need a copy of 
the 'list'.
    Object value = null;
    if (list == null) {
        list = parameters.get("list");
    }
    if (list instanceof String) {
        value = findValue((String) list);
    } else if (list instanceof Collection) {
        value = list;
    } else if (MakeIterator.isIterable(list)) {
        value = MakeIterator.convert(list);
    }
    if (value == null) {
        if (throwExceptionOnNullValueAttribute) {
            // will throw an exception if not found
            value = findValue((list == null) ? (String) list : list.toString(), 
"list",
               "The requested list key '" + list + "' could not be resolved as 
a collection/array/map/enumeration/iterator"+
               " type. " +
                    "Example: people or people.{name}");
        } else {
            // ww-1010, allows value with null value to be compatible with ww
            // 2.1.7 behavior
            value = findValue((list == null)?(String) list:list.toString());
        }
    }
    if (value instanceof Collection) {
        addParameter("listCopy", value);
    } else {
        addParameter("listCopy", MakeIterator.convert(value));
    }
}
 




Matt


 
On Wednesday, June 4, 2014 2:45 AM, Lukasz Lenart <lukaszlen...@apache.org> 
wrote:
2014-06-03 19:17 GMT+02:00 Matt Williams <mattwms1998...@yahoo.com.invalid>:
>
> I am using struts 2.1.8.  I am extending the 
> "org.apache.struts2.components.Select" tag and writing my own "select.ftl" 
> (freemarker template).
>
> I need to iterate over the parameter "parameters.list" twice.
>
> Example:
> <@s.iterator value="parameters.list">
>    <div>loop1</div>
> </@s.iterator>
> <@s.iterator value="parameters.list">
>     <div>loop2</div>
> </@s.iterator>
>
> However, the second iterator doesn't loop.  I think the "parameters.list" is 
> an Iterator object so it is already at the end (created by 
> org.apache.struts2.util.MakeIterator.convert(Object)).
>
> Is there a way?

Use <#assign> and create a copy?


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to