wood burning stoves 2.0*
The moose likes JSF and the fly likes while using SelectItems tag, I am getting IllegalArgumentException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "while using SelectItems tag, I am getting IllegalArgumentException" Watch "while using SelectItems tag, I am getting IllegalArgumentException" New topic
Author

while using SelectItems tag, I am getting IllegalArgumentException

Mansingh Shitole
Greenhorn

Joined: Jun 10, 2008
Posts: 4
Now I am trying with different approach...lets I will give you detail..

My Bean:
package org.jbpm.identity;

import javax.faces.model.SelectItem;
import java.util.*;

public class SelectItemsBean {

protected List<SelectItem> plList = null;

public SelectItemsBean(){

}

public void setOptions(List<SelectItem> options) {
this.plList = options;
System.out.println("SelectItemsBeanClass = "+options);
}

public List<SelectItem> getOptions() {
return plList;
}
}

My faces.config.xml
<managed-bean>
<managed-bean-name>selectItemsBean</managed-bean-name>
<managed-bean-class>org.jbpm.identity.SelectItemsBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>

My UIform..
form.leaveapplication.xhtml
<h:selectOneMenu value="#{var['pl']}">
<f:selectItems value="#{selectItemsBean.plList}" />
</h:selectOneMenu>

Now I am getting error:
javax.servlet.ServletException: Expected a child component type of UISelectItem/UISelectItems for component type javax.faces.SelectOne(j_id214). Found null.
javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

root cause

java.lang.IllegalArgumentException: Expected a child component type of UISelectItem/UISelectItems for component type javax.faces.SelectOne(j_id214). Found null.
com.sun.faces.renderkit.RenderKitUtils.getSelectItems(RenderKitUtils.java:357)
com.sun.faces.renderkit.html_basic.MenuRenderer.getOptionNumber(MenuRenderer.java:644)
com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:762)
com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:304)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:829)
org.jboss.gravel.common.renderer.RendererBase.doEncode(RendererBase.java:88)
org.jboss.gravel.common.renderer.RendererBase.doEncode(RendererBase.java:96)
org.jboss.gravel.common.renderer.RendererBase.doEncode(RendererBase.java:86)
org.jboss.gravel.common.renderer.RendererBase$ElementImpl.doEncode(RendererBase.java:337)
org.jbpm.jsf.taskformlayout.renderer.DataFormRenderer.encodeCells(DataFormRenderer.java:148)
org.jbpm.jsf.taskformlayout.renderer.DataFormRenderer.encodeChildren(DataFormRenderer.java:116)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:810)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:884)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:890)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:890)
javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:810)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:884)
javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:810)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:884)
javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:810)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:884)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:890)
com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:571)
javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:178)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:248)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
please help me to resolve this problem, I will be highly grateful to you

Thanking you,
Mansingh Shitole
Zack Marrapese
Greenhorn

Joined: Jul 02, 2008
Posts: 27
two problems:

1.) your setter for select items is never actually getting called. You could probably fix the problem by calling that setter in your constructor.

2.) you are binding the value of f:selectItems to plList, but your getter is for options. You can either change the getter to getPlList, or you can change the value binding to selectItemsBean.options

Hope this helps
~Zack
 
jQuery in Action, 2nd edition
 
subject: while using SelectItems tag, I am getting IllegalArgumentException