Hi Chris, not really sure how to find that code... Anyway this has been my steps: $ for lib in /opt/struts-2.3.7/lib/* ; do jar tvf $lib | grep tld && echo $lib; done
  3349 Wed Aug 10 12:51:32 CEST 2005 META-INF/sitemesh-decorator.tld
  3013 Sat May 15 11:55:14 CEST 2004 META-INF/sitemesh-page.tld
/opt/struts-2.3.7/lib/sitemesh-2.4.2.jar
346038 Tue Nov 06 08:13:06 CET 2012 META-INF/struts-tags.tld
/opt/struts-2.3.7/lib/struts2-core-2.3.7.jar
136496 Tue Nov 06 08:24:22 CET 2012 META-INF/struts-dojo-tags.tld
/opt/struts-2.3.7/lib/struts2-dojo-plugin-2.3.7.jar
   752 Tue Nov 06 08:27:06 CET 2012 META-INF/tags/JsonPlugin.tld
/opt/struts-2.3.7/lib/struts2-json-plugin-2.3.7.jar
     0 Tue May 13 21:39:54 CEST 2008 META-INF/tld/
 27808 Tue May 13 21:39:54 CEST 2008 META-INF/tld/tiles-jsp.tld
/opt/struts-2.3.7/lib/tiles-jsp-2.0.6.jar

$ jar xvf /opt/struts-2.3.7/lib/struts2-core-2.3.7.jar META-INF/struts-tags.tld
 \decompresso: META-INF/struts-tags.tld

$ grep -n "<name>iterator</name>" META-INF/struts-tags.tld
4881:    <name>iterator</name>

and the tag definition in the tld file is:

<tag>
    <description><![CDATA[Iterate over a iterable value]]></description>
    <name>iterator</name>
<tag-class>org.apache.struts2.views.jsp.IteratorTag</tag-class>
    <body-content>JSP</body-content>
    <!-- here a lot of not interesting attributes-->
</tag>

$ find src -name IteratorTag.java
src/core/src/main/java/org/apache/struts2/views/jsp/IteratorTag.java

$ cat src/core/src/main/java/org/apache/struts2/views/jsp/IteratorTag.java
/*
 * $Id: IteratorTag.java 741179 2009-02-05 16:55:14Z musachy $
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.struts2.views.jsp;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;

import org.apache.struts2.components.Component;
import org.apache.struts2.components.IteratorComponent;

import com.opensymphony.xwork2.util.ValueStack;

/**
 * @see IteratorComponent
 */
public class IteratorTag extends ContextBeanTag {

    private static final long serialVersionUID = -1827978135193581901L;

    protected String statusAttr;
    protected String value;
    protected String begin;
    protected String end;
    protected String step;

public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
        return new IteratorComponent(stack);
    }

    protected void populateParams() {
        super.populateParams();

        IteratorComponent tag = (IteratorComponent) getComponent();
        tag.setStatus(statusAttr);
        tag.setValue(value);
        tag.setBegin(begin);
        tag.setEnd(end);
        tag.setStep(step);
    }

    public void setStatus(String status) {
        this.statusAttr = status;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public void setBegin(String begin) {
        this.begin = begin;
    }

    public void setEnd(String end) {
        this.end = end;
    }

    public void setStep(String step) {
        this.step = step;
    }

    public int doEndTag() throws JspException {
        component = null;
        return EVAL_PAGE;
    }

    public int doAfterBody() throws JspException {
        boolean again = component.end(pageContext.getOut(), getBody());

        if (again) {
            return EVAL_BODY_AGAIN;
        } else {
            if (bodyContent != null) {
                try {
bodyContent.writeOut(bodyContent.getEnclosingWriter());
                } catch (Exception e) {
                    throw new JspException(e.getMessage());
                }
            }
            return SKIP_BODY;
        }
    }

}

Thanks a lot for your help.





Il 11/01/2013 20:21, Chris Pratt ha scritto:
Can you cut and paste your <s:iterator> code into the email so we can see?
   (*Chris*)


On Fri, Jan 11, 2013 at 11:12 AM, fusillator <fusilla...@gmail.com> wrote:

Hi all, I'm new to struts2/java matters, so be sympathetic please.

I've a question about <s:iterator> tag

I recently used it to loop on a Iterable collection of type
java.util.TreeMap$Values retrieved by the method java.util.TreeMap.values()

getting the following cast exception:

2013-01-11 18:45:00,520 DEBUG org.apache.struts.tutorial.**
wildcard.service.**PersonService.getPeople:33 [Person [1: Paolino
Paperino], Person [2: Paperon De Paperoni], Person [3: Archimede
Pitagorica]]
2013-01-11 18:45:00,523 DEBUG org.apache.struts.tutorial.**
wildcard.service.**PersonService.getPeople:34 class
java.util.TreeMap$Values
2013-01-11 18:45:00,523 DEBUG org.apache.struts.tutorial.**
wildcard.service.**PersonService.getPeople:34 class
java.util.TreeMap$Values
gen 11, 2013 6:45:01 PM org.apache.jasper.compiler.**TldLocationsCache
tldScanJar
WARNING: Caught an exception while evaluating expression 'people.isEmpty'
against value stack
java.lang.ClassCastException: java.util.TreeMap$Values cannot be cast to
java.util.Set
         at ognl.SetPropertyAccessor.**getProperty(**
SetPropertyAccessor.java:47)
         at com.opensymphony.xwork2.ognl.**accessor.**
XWorkCollectionPropertyAccesso**r.getProperty(**
XWorkCollectionPropertyAccesso**r.java:93)
         at ognl.OgnlRuntime.getProperty(**OgnlRuntime.java:2300)

The used variable is reported by log4j.
Is there any restriction on the iterator tags?
Could someone suggest me a tutorial/howto about ognl/value stack?

Best regards



------------------------------**------------------------------**---------
To unsubscribe, e-mail: 
user-unsubscribe@struts.**apache.org<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