Newsgroup: it.comp.java
Titolo: Problemi con SelectOneMenu....

Salve ragazzi,
avrei da chiedervi un aiuto su un tag da usare nella mia applicazione
jsf.
Parlo di selectonemenu che dalla documentazione dovrebbe mostrarmi un
menu a tendina che io intendo popolare con dati prelevati da db usando
un bean.
Sicuramente mi sfugge qualcosa in quanto è la prima volta che faccio
questa operazione,perdonatemi per questo...
Vi posto prima il problema
codice:
javax.servlet.ServletException: javax.servlet.jsp.JspException:
Conversion Error setting value ''{0}'' for ''{1}''.
	org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:821)
	org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
	org.apache.jsp.pages.login_jsp._jspService(login_jsp.java:108)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
	com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
	com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
	com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
	com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
	org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:670)
	org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:637)
	org.apache.jsp.index_jsp._jspService(index_jsp.java:50)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause
java.lang.IllegalArgumentException: Conversion Error setting value
''{0}'' for ''{1}''.
	com.sun.faces.util.Util.getSelectItems(Util.java:628)
	com.sun.faces.renderkit.html_basic.MenuRenderer.getOptionNumber(MenuRenderer.java:488)
	com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:465)
	com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:430)
	javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:720)
	com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:443)
	com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:233)
	javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:701)
	com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:435)
	com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:233)
	javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:701)
	javax.faces.webapp.UIComponentTag.encodeChildren(UIComponentTag.java:607)
	javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:544)
	com.sun.faces.taglib.html_basic.PanelGridTag.doEndTag(PanelGridTag.java:460)
	org.apache.jsp.pages.login_jsp._jspx_meth_h_panelGrid_0(login_jsp.java:243)
	org.apache.jsp.pages.login_jsp._jspx_meth_h_form_0(login_jsp.java:204)
	org.apache.jsp.pages.login_jsp._jspx_meth_f_view_0(login_jsp.java:156)
	org.apache.jsp.pages.login_jsp._jspService(login_jsp.java:99)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
	com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
	com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
	com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
	com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
	org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:670)
	org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:637)
	org.apache.jsp.index_jsp._jspService(index_jsp.java:50)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
Io ho agito così.
Ho un backing bean Authenticationbean che mi carica da un db una serie
di gruppi di studio(studente,docente....),che mi restituisce con un
arraylist
codice:private ArrayList teams;
public ArrayList teamList() throws SQLException {
		Statement stm = connection.createStatement();
		ResultSet rst = stm
				.executeQuery("select * from research_Team order by team_name");
		ArrayList teams = new ArrayList();
		while (rst.next())
			teams.add(rst.getString("team_name"));
		return teams;
	}
	public ArrayList getTeams() {
		return teams;
	}
	public void setTeams(ArrayList teams) {
		this.teams = teams;
	}
questo è quanto presente nel mio bean.
Questa è la mia pagina jsp,cioè la parte interessante,dove sbaglio?
Grazie mille.
P.S.Devo per caso inizializzare l'arraylist nel faces-config.xml?
Se sì,come?
codice:<h:outputLabel for="TeamNameInput">
           <h:outputText value="Enter your TeamName:"/>
          </h:outputLabel>
          <h:selectOneMenu id="team"
 			value="Teams List" style=" width : 141px; height : 22px;">
  			<f:selectItems
  				 value="#{authenticationBean.teams}" />
			</h:selectOneMenu>
Ecco il mio faces-config.xml
codice:<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD
JavaServer Faces Config 1.1//EN"
"
http://java.sun.com/dtd/web-facesconfig_1_1.dtd
">
<faces-config>
 <managed-bean>
  <managed-bean-name>myBean</managed-bean-name>
  <managed-bean-class>giu.MyBean</managed-bean-class>
  <managed-bean-scope>request</managed-bean-scope>
 </managed-bean>
 <managed-bean>
  <managed-bean-name>authenticationBean</managed-bean-name>
  <managed-bean-class>util.AuthenticationBean</managed-bean-class>
  <managed-bean-scope>request</managed-bean-scope>
  <managed-property>
   <property-name>password</property-name>
   <property-class>java.lang.String</property-class>
   <value/>
  </managed-property>
  <managed-property>
   <property-name>teamName</property-name>
   <property-class>java.lang.String</property-class>
   <value/>
  </managed-property>
  <managed-property>
   <property-name>username</property-name>
   <property-class>java.lang.String</property-class>
   <value/>
  </managed-property>
 </managed-bean>
 <navigation-rule>
  <from-view-id>/pages/Upload.jsp</from-view-id>
  <navigation-case>
   <from-outcome>ok</from-outcome>
   <to-view-id>/pages/MyResult.jsp</to-view-id>
  </navigation-case>
 </navigation-rule>
 <navigation-rule>
  <from-view-id>/pages/MenuUser.jsp</from-view-id>
  <navigation-case>
   <from-outcome>upload</from-outcome>
   <to-view-id>/pages/Upload.jsp</to-view-id>
  </navigation-case>
  <navigation-case>
   <from-outcome>admin</from-outcome>
   <to-view-id>/pages/Administration.jsp</to-view-id>
  </navigation-case>
  <navigation-case>
   <from-outcome>search</from-outcome>
   <to-view-id>/pages/Search.jsp</to-view-id>
  </navigation-case>
 </navigation-rule>
 <navigation-rule>
  <from-view-id>/pages/login.jsp</from-view-id>
  <navigation-case>
   <from-outcome>login</from-outcome>
   <to-view-id>/pages/MenuUser.jsp</to-view-id>
  </navigation-case>
  <navigation-case>
   <from-outcome>failure</from-outcome>
   <to-view-id>/pages/login.jsp</to-view-id>
  </navigation-case>
 </navigation-rule>
</faces-config>

Ciao,  prova queste due cose, assieme o separatamente :
1° #{authenticationBean.teams}" dovrebe tornare una List nella quale
si
trova ojetti del tipo javax.faces.model.SelectItem
2° #{authenticationBean.teams}" forse tornanto una List al posto di un
ArrayList