2 Replies Latest reply on Oct 6, 2009 10:39 AM by Andrea Abbiati

    rich:columns foreach_bad_items error

    Andrea Abbiati Newbie

      Hi,
      sorry for long post....

      i'm trying to use rich:columns under weblogic 10.3 (the same code works fine under Tomcat6) and get this error:

      javax.servlet.jsp.JspTagException: FOREACH_BAD_ITEMS
      at org.richfaces.iterator.SimpleForEachIterator.toForEachIterator(SimpleForEachIterator.java:135)
      at org.richfaces.iterator.SimpleForEachIterator.supportedTypeForEachIterator(SimpleForEachIterator.java:98)
      at org.richfaces.taglib.ColumnsTag.prepare(ColumnsTag.java:539)
      at org.richfaces.taglib.ColumnsTag.doStartTag(ColumnsTag.java:299)
      at jsp_servlet.__dincols._jsp__tag9(__dincols.java:586)
      at jsp_servlet.__dincols._jsp__tag4(__dincols.java:375)
      at jsp_servlet.__dincols._jsp__tag1(__dincols.java:221)
      at jsp_servlet.__dincols._jsp__tag0(__dincols.java:165)
      at jsp_servlet.__dincols._jspService(__dincols.java:124)
      at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
      at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
      at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
      at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
      at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:408)
      at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:318)
      at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
      at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:502)
      at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:251)
      at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:422)
      at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:447)
      at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:116)
      at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
      at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:248)
      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
      at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
      at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
      at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
      at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
      at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
      at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:341)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
      at weblogic.servlet.utils.FastSwapFilter.doFilter(FastSwapFilter.java:66)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
      at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      at weblogic.security.service.SecurityManager.runAs(Unknown Source)
      at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
      at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
      at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
      at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
      at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

      here is the code:
      dinCols.jsp

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>






      <f:view>
      <h3>Test Jsp</h3>

      <h:form id="_form">

      <h:selectBooleanCheckbox value="#{bean.description}">
      <a4j:support event="onclick" actionListener="#{bean.apply}" reRender="_data"></a4j:support>
      </h:selectBooleanCheckbox>
      <rich:dataTable id="_data" value="#{bean.data}" var="row">
      <rich:column>
      <f:facet name="header">
      <h:outputText value="#"></h:outputText>
      </f:facet>
      <h:outputText value="#{row[0]}"></h:outputText>
      </rich:column>
      <rich:columns value="#{bean.columns}" var="column" index="index" begin="2"
      sortBy="#{row[index]}" sortOrder="#{column.ordering}"
      filterBy="#{row[index]}" filterValue="#{column.filterValue}" filterEvent="onkeyup">
      <f:facet name="header">
      <h:outputText value="#{column.name}"></h:outputText>
      </f:facet>
      <h:outputText value="#{row[index]}" rendered="#{column.name != 'Description'}"></h:outputText>
      <h:inputText value="#{row[index]}" rendered="#{column.name eq 'Description'}"></h:inputText>
      </rich:columns>
      </rich:dataTable>
      <a4j:commandLink value="Ajax Submit" reRender="_data"></a4j:commandLink>
      <h:commandLink value="Form Submit" action="jsp"></h:commandLink>


      </h:form>



      </f:view>





      Bean.java

      /*
      * Bean.java Date created: 08.10.2008
      * Last modified by: $Author$
      * $Revision$ $Date$
      */

      package it.sipam.beans.test;


      import java.io.Serializable;
      import java.util.ArrayList;
      import java.util.Arrays;
      import java.util.List;

      import javax.faces.event.ActionEvent;

      /**
      * Sample session bean
      * @author Andrey
      *
      */
      public class Bean implements Serializable{

      List columns;

      List<List> data;
      List<List> dataComplex;

      Integer rowsCount;

      Boolean name;

      Boolean type;

      Boolean description;

      Integer maxValue;

      public Bean() {
      rowsCount = 5;
      name = true;
      type = true;
      description = true;
      maxValue = 15;
      init();
      }

      public void apply(ActionEvent event) {
      init();
      }

      private void init() {
      // Init columns
      columns = new ArrayList();
      columns.add(new Column("#"));

      if (name) {
      columns.add(new Column("Name"));
      }
      if (type) {
      columns.add(new Column("Type"));
      }
      if (description) {
      columns.add(new Column("Description"));
      }

      //Init model
      data = new ArrayList<List>();
      dataComplex = new ArrayList<List>();

      for (int i = 0; i < rowsCount; i++) {
      data.add(getRow(i));
      dataComplex.add(getComplexList(i));
      }
      }

      private List getRow(int row) {
      List list = new ArrayList();
      list.add(String.valueOf(row));
      if (name) {
      list.add(String.valueOf(Math.random()));
      }

      if (type) {
      int i = new Double(Math.random() * 10.0).intValue();
      if (i <= 3) {
      list.add("txt");
      }else if (i <= 6) {
      list.add("jpeg");
      }else if (i <= 10) {
      list.add("xml");
      }
      }

      if (description) {
      list.add("");
      }

      return list;
      }

      private List getComplexList(int row) {
      List list = new ArrayList();

      Column c = new Column("andrea" +row);
      list.add(c);

      return list;
      }

      public List<Integer[]> getInrementData() {
      List<Integer[]> list = new ArrayList<Integer[]>();
      for (int i = 0; i < 15; i++) {
      list.add(new Integer[] {i});
      }
      return list;
      }

      public boolean filterMethod(Object o) {
      Integer [] i = (Integer [])o;
      if (i[0] > maxValue) {
      return false;
      }
      return true;
      }

      public List getColumns() {
      return columns;
      }

      public List<List> getData() {
      return data;
      }

      public Boolean getName() {
      return name;
      }

      public void setName(Boolean name) {
      this.name = name;
      }

      public Boolean getType() {
      return type;
      }

      public void setType(Boolean type) {
      this.type = type;
      }

      public Boolean getDescription() {
      return description;
      }

      public void setDescription(Boolean description) {
      this.description = description;
      }

      public Integer getRowsCount() {
      return rowsCount;
      }

      public void setRowsCount(Integer rowsCount) {
      this.rowsCount = rowsCount;
      }

      public Integer getMaxValue() {
      return maxValue;
      }

      public void setMaxValue(Integer maxValue) {
      this.maxValue = maxValue;
      }

      public List<List> getDataComplex() {
      return dataComplex;
      }

      public void setDataComplex(List<List> dataComplex) {
      this.dataComplex = dataComplex;
      }

      }


      Column.java
      /*
      * Column.java Date created: 08.10.2008
      * Last modified by: $Author$
      * $Revision$ $Date$
      */

      package it.sipam.beans.test;

      import org.richfaces.model.Ordering;

      /**
      * Column sample model
      * @author Andrey
      *
      */
      public class Column {

      String name;

      Ordering ordering;

      String filterValue;

      public Column(String name) {
      this.name = name;
      }

      public String getName() {
      return name;
      }

      public void setName(String name) {
      this.name = name;
      }

      public Ordering getOrdering() {
      return ordering;
      }

      public void setOrdering(Ordering ordering) {
      this.ordering = ordering;
      }

      public String getFilterValue() {
      return filterValue;
      }

      public void setFilterValue(String filterValue) {
      this.filterValue = filterValue;
      }

      }


      the problems occurs with richfaces 3.3.0 and 3.3.2.

      what i'm worng?

      thanks in advance
      Andrea