SelectItemGroup.........

Trying to write simple application to adjust with SelectItemGroup in JSF.

It seems that all alright… but I couldn’t even display my .jsp…. Tomcat throws exceptionCan't instantiate class..

Would you help me to deal with it?

--

my jsp page

<f:view>

<h1><h:outputText value="JavaServer Faces" /></h1>

<h:message id="error" for="addItemField" errorStyle="color:red"/>

<h:form id="addItemForm">

<h:outputLabel for="addItemField">

<h:outputText value="Add new item"/>

</h:outputLabel>

<h:inputText id="addItemField" required="true" value="#{bbean.newItem}"/>

<h:commandButton value="Add item" action="#{bbean.addNewItem}"/>

</h:form>

<h:selectOneListbox style="width:16%">

<f:selectItems value="#{bbean.itemsGroup}"/>

</h:selectOneListbox>

</f:view>

backing bean class

package backinbean;

import java.util.ArrayList;

import java.util.List;

import javax.faces.model.SelectItem;

import javax.faces.model.SelectItemGroup;

publicclass BackingBeanClass{

private List itemsList;

private String newItem;

private SelectItemGroup itemsGroup;

public BackingBeanClass(){

itemsList=new ArrayList();

itemsGroup =new SelectItemGroup("--registered items--",null, false, (SelectItem[])itemsList.toArray());

}

publicvoid setNewItem(String newItem){

this.newItem = newItem;

}

public String getNewItem(){

return newItem;

}

public SelectItemGroup getItemsGroup(){

return itemsGroup;

}

publicvoid setItemsGroup(SelectItemGroup itemsGroup){

this.itemsGroup = itemsGroup;

}

public List getItemsList(){

return itemsList;

}

publicvoid setItemsList(List itemsList){

this.itemsList = itemsList;

}

publicvoid addNewItem(){

SelectItem item=new SelectItem(new Integer(itemsList.size()),newItem);

}

}

faces-config.xml

<?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>bbean</managed-bean-name>

<managed-bean-class>backinbean.BackingBeanClass</managed-bean-class>

<managed-bean-scope>session</managed-bean-scope>

</managed-bean>

</faces-config>

[4632 byte] By [Tyblina] at [2007-11-26 15:13:52]
# 1
Actually im new to this tech but i faced the same problem... may be the JSP page ur using and the bean ur binding are to it are different as far as i know only one bean i bound to one jsp... so please check it ..may be this might hv helped u...
nairpravinga at 2007-7-8 9:05:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...