0 Replies Latest reply on Aug 13, 2008 9:20 AM by goompas goompas

    A4j:repeat and rich:menuItem from SQL query

    goompas goompas Newbie

      Hello
      I wanna make menu thath have positions from SQL query.
      I made bean that return ArrayList of strings from interesed database.
      Now i wanna make menu with items equals to that arraylist.
      returned arraylist from bean is
      [Wybierz..., Antyczna, Demoniczna, Jadowita, Kasajaca, Kosciana, Krysztalowa, Lekka, Mistyczna, Okrutna, Opiekuncza, Ostra, Przekleta, Przyjacielska, Szybka, Wzmacniajaca, Zabojcza, Zatruta, Zebata, Zwinna, swiecaca]

      When i use

      <a4j:repeat id="detail" value="#{BeanListy.tprefixy}" var="detail">
       <h:outputText value="#{BeanListy.tprefixy}"/>
      
      </a4j:repeat>
      


      i have on site

      [Wybierz..., Antyczna, Demoniczna, Jadowita, Kasajaca, Kosciana, Krysztalowa, Lekka, Mistyczna, Okrutna, Opiekuncza, Ostra, Przekleta, Przyjacielska, Szybka, Wzmacniajaca, Zabojcza, Zatruta, Zebata, Zwinna, swiecaca][Wybierz..., Antyczna, Demoniczna, Jadowita, Kasajaca, Kosciana, Krysztalowa, Lekka, Mistyczna, Okrutna, Opiekuncza, Ostra, Przekleta, Przyjacielska, Szybka, Wzmacniajaca, Zabojcza, Zatruta, Zebata, Zwinna, swiecaca][Wybierz..., Antyczna, Demoniczna, Jadowita, Kasajaca, Kosciana, Krysztalowa, Lekka, Mistyczna, Okrutna, Opiekuncza, Ostra, Przekleta, Przyjacielska, Szybka, Wzmacniajaca, Zabojcza, Zatruta, Zebata, Zwinna, swiecaca][Wybierz..., Antyczna, Demoniczna, Jadowita, Kasajaca, Kosciana, Krysztalowa, Lekka, Mistyczna, Okrutna, Opiekuncza, Ostra, Przekleta, Przyjacielska, Szybka, Wzmacniajaca, Zabojcza, Zatruta, Zebata, Zwinna, swiecaca][Wybierz..., Antyczna, Demoniczna, Jadowita, Kasajaca, Kosciana, Krysztalowa, Lekka, Mistyczna, Okrutna, Opiekuncza, Ostra, Przekleta, Przyjacielska, Szybka, Wzmacniajaca, Zabojcza, Zatruta, Zebata, Zwinna, swiecaca][Wybierz..., Antyczna, Demoniczna, Jadowita, Kasajaca, Kosciana, Krysztalowa, Lekka, Mistyczna, Okrutna, Opiekuncza, Ostra, Przekleta, Przyjacielska, Szybka, Wzmacniajaca, Zabojcza, Zatruta, Zebata, Zwinna, swiecaca]

      etc

      when i use
       <a4j:repeat id="detail" value="#{BeanListy.tprefixy}" var="detail">
       <h:outputText value="#{detail.tprefixy}"/>
      
      </a4j:repeat>
      

      i have this error:

      javax.servlet.ServletException: The class 'java.lang.String' does not have the property 'tprefixy'


      Its seems that iterator work protertly but how print on the screen one string from this arraylist not whole arraylist?

      c:foreach dont work, i get empty page.

      Here are my files:

      konkretnepolaczenie.jsp
      <%--
       Document : konkretnepolaczenie
       Created on : 2008-08-13, 12:56:38
      
      
      --%>
      
      <%@taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
      <%@taglib uri="http://richfaces.org/rich" prefix="rich"%>
      
      <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
      <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
      <%@taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
      
      <%@page contentType="text/html" pageEncoding="UTF-8"%>
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
      
      <html>
       <head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
       <title>JSP Page</title>
       </head>
       <body>
       <jsp:useBean class="org.my.richfaces.BeanListy" id="data">
      </jsp:useBean>
       <h:form>
      
       <h:panelGrid>
      
       <rich:dropDownMenu value="Option1"
       submitMode="none" direction="bottom-right" jointPoint="tr">
       <c:forEach items="#{data.tprefixy}" var="zm">
      <c:out value="1111 #{zm}"/>
      <h:outputText value="222 #{zm}" />
      <rich:menuItem value="#{zm}" />
      </c:forEach>
       <rich:menuItem value="Suboption1-1" />
       <rich:menuItem value="Suboption1-2" />
       <rich:menuItem value="Suboption1-3" />
       </rich:dropDownMenu>
      
      
      
       <a4j:repeat id="detail" value="#{BeanListy.tprefixy}" var="detail">
       <h:outputText value="#{BeanListy.tprefixy}"/>
      
      </a4j:repeat>
      
      
       </h:panelGrid>
       </h:form>
      
      
       </body>
      </html>
      


      BeanListy.java
      /*
       * To change this template, choose Tools | Templates
       * and open the template in the editor.
       */
      
      package org.my.richfaces;
      
      import com.midnightcookies.taghandlers.*;
      import java.beans.*;
      import java.io.Serializable;
      import java.util.ArrayList;
      
      /**
       * @author Paweł
       */
      public class BeanListy extends Object implements Serializable {
      
       public static final String PROP_SAMPLE_PROPERTY = "sampleProperty";
      
       private PropertyChangeSupport propertySupport;
       protected String jakatablica;
      
      
      
      
       protected ArrayList tprefixy;
      
       /**
       * Get the value of tprefixy
       *
       * @return the value of tprefixy
       */
       public ArrayList getTprefixy() {
       return tprefixy;
       }
      
       /**
       * Set the value of tprefixy
       *
       * @param tprefixy new value of tprefixy
       */
       public void setTprefixy(ArrayList tprefixy) {
       this.tprefixy = tprefixy;
       }
      
      
       public BeanListy() {
       ArrayList tmp = new ArrayList();
       propertySupport = new PropertyChangeSupport(this);
       listy dane = new listy();
       tmp=dane.PobierziPosortuj();
       setTprefixy(tmp);
      
       }
      
      
      
       public void addPropertyChangeListener(PropertyChangeListener listener) {
       propertySupport.addPropertyChangeListener(listener);
       }
      
       public void removePropertyChangeListener(PropertyChangeListener listener) {
       propertySupport.removePropertyChangeListener(listener);
       }
      
      }
      


      faces-config.xml
      <?xml version='1.0' encoding='UTF-8'?>
      
      <!-- =========== FULL CONFIGURATION FILE ================================== -->
      
      <faces-config version="1.2"
       xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
      
       <managed-bean>
       <managed-bean-name>richFacesBean</managed-bean-name>
       <managed-bean-class>org.my.richfaces.RichFacesBean</managed-bean-class>
       <managed-bean-scope>session</managed-bean-scope>
      </managed-bean>
       <managed-bean>
       <managed-bean-name>BeanListy</managed-bean-name>
       <managed-bean-class>org.my.richfaces.BeanListy</managed-bean-class>
       <managed-bean-scope>session</managed-bean-scope>
      </managed-bean>
      <navigation-rule>
      <from-view-id>faces/strony/wstep1.xhtml</from-view-id>
      <navigation-case>
      <from-outcome>next</from-outcome>
      <to-view-id>faces/strony/wstep1.xhtml</to-view-id>
      </navigation-case>
      </navigation-rule>
      </faces-config>
      


      web.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"><context-param><param-name>com.sun.faces.verifyObjects</param-name><param-value>false</param-value></context-param><context-param><param-name>com.sun.faces.validateXml</param-name><param-value>true</param-value></context-param><context-param><param-name>javax.faces.STATE_SAVING_METHOD</param-name><param-value>client</param-value></context-param>
       <filter>
       <display-name>RichFaces Filter</display-name>
       <filter-name>richfaces</filter-name>
       <filter-class>org.ajax4jsf.Filter</filter-class>
       </filter>
       <filter-mapping>
       <filter-name>richfaces</filter-name>
       <servlet-name>Faces Servlet</servlet-name>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>INCLUDE</dispatcher>
       </filter-mapping>
       <servlet><servlet-name>Faces Servlet</servlet-name><servlet-class>javax.faces.webapp.FacesServlet</servlet-class><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>Faces Servlet</servlet-name><url-pattern>/faces/*</url-pattern></servlet-mapping><session-config><session-timeout>
       30
       </session-timeout></session-config>
       <context-param>
       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
       <param-value>server</param-value>
      </context-param>
      <context-param>
       <param-name>org.richfaces.SKIN</param-name>
       <param-value>blueSky</param-value>
      </context-param>
      
       <welcome-file-list>
       <welcome-file>faces/index.jsp</welcome-file>
       </welcome-file-list>
       </web-app>