Forums Register Login

f:selectItem

+Pie Number of slices to send: Send
hey guys ,
i'm getting this error message ..i'm trying to populate the dropdown using f:selectItem ..

javax.servlet.ServletException: Conversion Error setting value ''{0}'' for ''{1}''.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:827)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:763)
org.apache.jsp.welcomeJSF_jsp._jspService(welcomeJSF_jsp.java:127)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:105)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:336)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:297)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:247)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
sun.reflect.GeneratedMethodAccessor72.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
java.security.AccessController.doPrivileged(Native Method)
java.security.AccessController.doPrivileged(Native Method)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:326)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:132)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:248)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:194)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)


root cause

java.lang.IllegalArgumentException: Conversion Error setting value ''{0}'' for ''{1}''.
com.sun.faces.util.Util.getSelectItems(Util.java:650)
com.sun.faces.renderkit.html_basic.MenuRenderer.getOptionNumber(MenuRenderer.java:489)
com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:466)
com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:431)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:720)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:453)
com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:130)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:701)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:445)
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:609)
javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:546)
com.sun.faces.taglib.html_basic.PanelGridTag.doEndTag(PanelGridTag.java:460)
org.apache.jsp.welcomeJSF_jsp._jspx_meth_h_panelGrid_0(welcomeJSF_jsp.java:261)
org.apache.jsp.welcomeJSF_jsp._jspx_meth_h_form_0(welcomeJSF_jsp.java:200)
org.apache.jsp.welcomeJSF_jsp._jspx_meth_f_view_0(welcomeJSF_jsp.java:170)
org.apache.jsp.welcomeJSF_jsp._jspService(welcomeJSF_jsp.java:117)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:105)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:336)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:297)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:247)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
sun.reflect.GeneratedMethodAccessor72.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
java.security.AccessController.doPrivileged(Native Method)
java.security.AccessController.doPrivileged(Native Method)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:326)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:132)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:248)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:194)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)


here is the page

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<f:loadBundle basename="com.Instance" var="Instance"/>

<!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 bgcolor="pink">
<f:view>

<h:form id="formone">
<h:panelGrid columns="1" width="100%">
<h:panelGroup>
<h:outputLabel id ="instance" value="Instance Name"/>
<h:inputText id="instName" value="#{instance.instanceName}"/>
</h:panelGroup>
<br>

<h:panelGroup>
<h:outputLabel id="detailTitle" value="Instance Details : "/>
<h:inputTextarea id="detail" value="#{instance.details}" cols="30" />
</h:panelGroup>

<br>
<br>

<h:panelGroup>
<h:outputLabel id="role" value="Instance Role : "/>
<h:selectOneMenu id="rolelist" value="#{instance.deftValue}">
<f:selectItems value="#{instance.instanceRole}"/>
</h:selectOneMenu>
</h:panelGroup>

<br>
<br>
<h:panelGroup>
<h:outputLabel id="type" value="Instance Type : "/>
<h:selectOneMenu id="insttype" value="#{instance.deftValue}">
<f:selectItems value="#{instance.instanceType}"/>
</h:selectOneMenu>
</h:panelGroup>
<br><br>
<h:dataTable border="1" cellpadding="10">
<h:column>
<f:facet name="header">
<f:verbatim>Server</f:verbatim>
</f:facet>
<h:outputText id="server" value=""/>
</h:column>
<h:column>
<f:facet name="header">
<f:verbatim>Server Type</f:verbatim>
</f:facet>
<h:selectOneMenu id="serverlist" value="#{instance.deftValue}">
<f:selectItems value="#{instance.serverType}"/>
</h:selectOneMenu>
</h:column>
<h:column>
<f:facet name="header">
<f:verbatim>Comments</f:verbatim>
</f:facet>
<h:inputTextarea id="comment" value="#{instance.comment}" cols="20" />
</h:column>

</h:dataTable>

<h:panelGroup>
<h:commandButton id="save" value="Save" />
<h:commandButton id="cancel" value="Cancel"/>
</h:panelGroup>
</h:panelGrid>
</h:form>
</f:view>
</body>
</html>

faces-config.xml

<managed-bean>
<managed-bean-name>instance</managed-bean-name>
<managed-bean-class>com.InstanceBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>

here is the bean class

/*
* InstanceBean2.java
*
* Created on October 17, 2006, 5:50 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package com;

/**
*
* @author Administrator
*/
public class InstanceBean {
private String instanceName;
private String details;
private String instanceRole[];
private String instanceType[];
private String server;
private String serverType[];
private String comment;
private String deftValue;
/** Creates a new instance of InstanceBean2 */
public InstanceBean() {
}

public String getInstanceName() {
return instanceName;
}

public void setInstanceName(String instanceName) {
this.instanceName = instanceName;
}

public String getDetails() {
return details;
}

public void setDetails(String details) {
this.details = details;
}

public String[] getInstanceRole() {
return instanceRole;
}

public void setInstanceRole(String[] instanceRole) {
this.instanceRole = instanceRole;
}

public String[] getInstanceType() {
return instanceType;
}

public void setInstanceType(String[] instanceType) {
this.instanceType = instanceType;
}

public String getServer() {
return server;
}

public void setServer(String server) {
this.server = server;
}

public String[] getServerType() {
return serverType;
}

public void setServerType(String[] serverType) {
this.serverType = serverType;
}

public String getComment() {
return comment;
}

public void setComment(String comment) {
this.comment = comment;
}

public String getDeftValue() {
return deftValue;
}

public void setDeftValue(String deftValue) {
this.deftValue = deftValue;
}

}


i tried everywhere couldnt find the reason ..if anybody knows pls let me know what i am doing wrong..
Thank you in advance
+Pie Number of slices to send: Send
You should populate your <f:selectItems> with objects of type SelectItem and not String[]. So for instance your property instanceRole should not be of type String[], but of type SelectItem, which is usually placed inside a List (as it is <f:selectItems> and not <f:selectItem>).

In your bean, you should have something like this:



You can seperate the part that loads the values into your List in a seperate method, like loadInstanceRole(), as I usually do, but its up to you.

Hope this helps.
+Pie Number of slices to send: Send
hi Eugene Abarquez ,
i did like you suggested me.. here is my bean class..i'm still getting the same message
public class InstanceBean {


private static Logger _log = LogManager.getLogger(InstanceBean.class.getName());
private String instanceName;
private String details;
private ArrayList instanceRole;
private ArrayList instanceType;
private String server;
private ArrayList serverType;
private String comment;
private String deftValue="default value";

/** Creates a new instance of InstanceBean */
public InstanceBean(){}

public String getDeftValue() {
return deftValue;
}

public void setDeftValue(String deftValue) {
this.deftValue = deftValue;
}
public String getInstanceName() {
return instanceName;
}

public void setInstanceName(String instanceName) {
this.instanceName = instanceName;
}

public String getDetails() {
return details;
}

public void setDetails(String details) {
this.details = details;
}

public ArrayList getInstanceRole(){
instanceRole = new ArrayList();
instanceRole.add(new SelectItem("value0","production"));
instanceRole.add(new SelectItem("value1","QAT1"));
instanceRole.add(new SelectItem("value2","QAT2"));
instanceRole.add(new SelectItem("value3","UAT"));
instanceRole.add(new SelectItem("value4","development"));
return instanceRole;
}

/* public void setInstanceRole(ArrayList instanceRole) {
this.instanceRole = instanceRole;
}
*/
public ArrayList getInstanceType() {
instanceType = new ArrayList();
instanceType.add(new SelectItem("value0","production"));
instanceType.add(new SelectItem("value1","QAT1"));
instanceType.add(new SelectItem("value2","QAT2"));
instanceType.add(new SelectItem("value3","UAT"));
instanceType.add(new SelectItem("value4","development"));
return instanceType;
}

/* public void setInstanceType(ArrayList instanceType) {
this.instanceType = instanceType;
}
*/
public String getServer() {
return server;
}

public void setServer(String server) {
this.server = server;
}

public ArrayList getServerType() {
serverType = new ArrayList();
serverType.add(new SelectItem("value0","production"));
serverType.add(new SelectItem("value1","QAT1"));
serverType.add(new SelectItem("value2","QAT2"));
serverType.add(new SelectItem("value3","UAT"));
serverType.add(new SelectItem("value4","development"));
return serverType;
}

/* public void setServerType(ArrayList serverType) {
this.serverType = serverType;
}
*/
public String getComment() {
return comment;
}

public void setComment(String comment) {
this.comment = comment;


i dont know what to do ..thank you very much for replying
+Pie Number of slices to send: Send
The SelectItem value type must correspond with the valuebinding of the h:selectOneMenu.

If you use any other object instead of the String "value", then the selectedItem setter/getter type must correspond with it. You can use any object in it. The label have to be a String all the time anyway.
+Pie Number of slices to send: Send
hey guys.. i'm getting a new error now ..its something like this

javax.servlet.ServletException: java.lang.Error: Unresolved compilation problems:
The import javax.faces cannot be resolved
The import org.apache.log4j cannot be resolved
The import org.apache.log4j cannot be resolved
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type

org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:827)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:763)
org.apache.jsp.welcomeJSF_jsp._jspService(welcomeJSF_jsp.java:112)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:105)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:336)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:297)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:247)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
java.security.AccessController.doPrivileged(Native Method)
java.security.AccessController.doPrivileged(Native Method)
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)
sun.reflect.GeneratedMethodAccessor121.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)


root cause

javax.faces.el.EvaluationException: java.lang.Error: Unresolved compilation problems:
The import javax.faces cannot be resolved
The import org.apache.log4j cannot be resolved
The import org.apache.log4j cannot be resolved
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type

com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:206)
com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:154)
com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:386)
javax.faces.webapp.UIComponentTag.createComponent(UIComponentTag.java:1009)
javax.faces.webapp.UIComponentTag.createChild(UIComponentTag.java:1036)
javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:749)
javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:429)
com.sun.faces.taglib.html_basic.SelectOneMenuTag.doStartTag(SelectOneMenuTag.java:487)
org.apache.jsp.welcomeJSF_jsp._jspx_meth_h_selectOneMenu_0(welcomeJSF_jsp.java:425)
org.apache.jsp.welcomeJSF_jsp._jspx_meth_h_panelGroup_2(welcomeJSF_jsp.java:387)
org.apache.jsp.welcomeJSF_jsp._jspx_meth_h_panelGrid_0(welcomeJSF_jsp.java:224)
org.apache.jsp.welcomeJSF_jsp._jspx_meth_h_form_0(welcomeJSF_jsp.java:185)
org.apache.jsp.welcomeJSF_jsp._jspx_meth_f_view_0(welcomeJSF_jsp.java:155)
org.apache.jsp.welcomeJSF_jsp._jspService(welcomeJSF_jsp.java:102)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:105)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:336)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:297)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:247)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
java.security.AccessController.doPrivileged(Native Method)
java.security.AccessController.doPrivileged(Native Method)
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)
sun.reflect.GeneratedMethodAccessor121.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)


here is the bean class

package com;
import java.util.List;
import java.util.ArrayList;
import javax.faces.model.SelectItem;


/*
* InstanceBean.java
*
* Created on October 11, 2006, 11:08 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

/**
*
* @author Administrator
*/
public class InstanceBean {
private String instanceName = "RSSESN001";
private String details;
private List listinstanceRole;
private String instanceRole;
private List listinstanceType;
private String instanceType;
private String server;
private List listserverType;
private String serverType;
private String comment;
private String deftValue="default value";

/** Creates a new instance of InstanceBean */
public InstanceBean(){
System.out.print("hey this is in the instance bean const.......Akshatha");
}

public String getDeftValue() {
return deftValue;
}

public void setDeftValue(String deftValue) {
this.deftValue = deftValue;
}
public String getInstanceName() {
return instanceName;
}

public void setInstanceName(String instanceName) {
this.instanceName = instanceName;
}

public String getDetails() {
return details;
}

public void setDetails(String details) {
this.details = details;
}

public List getListinstanceRole(){
listinstanceRole = new ArrayList();
listinstanceRole.add(new SelectItem("value0","production"));
listinstanceRole.add(new SelectItem("value1","QAT1"));
listinstanceRole.add(new SelectItem("value2","QAT2"));
listinstanceRole.add(new SelectItem("value3","UAT"));
listinstanceRole.add(new SelectItem("value4","development"));
return listinstanceRole;
}

public void setInstanceRole(String instanceRole) {
this.instanceRole = instanceRole;
}
public String getInstanceRole(){
return instanceRole;
}

public List getListinstanceType() {
listinstanceType = new ArrayList();
listinstanceType.add(new SelectItem("value0","production"));
listinstanceType.add(new SelectItem("value1","QAT1"));
listinstanceType.add(new SelectItem("value2","QAT2"));
listinstanceType.add(new SelectItem("value3","UAT"));
listinstanceType.add(new SelectItem("value4","development"));
return listinstanceType;
}

public void setInstanceType(String instanceType) {
this.instanceType = instanceType;
}
public String getInstanceType() {
return instanceType;
}

public String getServer() {
return server;
}

public void setServer(String server) {
this.server = server;
}

public List getListserverType() {
listserverType = new ArrayList();
listserverType.add(new SelectItem("value0","production"));
listserverType.add(new SelectItem("value1","QAT1"));
listserverType.add(new SelectItem("value2","QAT2"));
listserverType.add(new SelectItem("value3","UAT"));
listserverType.add(new SelectItem("value4","development"));
return listserverType;
}

public void setServerType(String serverType) {
this.serverType = serverType;
}
public String getServerType() {
return serverType;
}
public String getComment() {
return comment;
}

public void setComment(String comment) {
this.comment = comment;
}


}

here is my page
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<f:loadBundle basename="com.Instance" var="Instance"/>

<!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 bgcolor="pink">
<f:view>

<h:form id="formone">
<h:panelGrid columns="1" width="100%">
<h:panelGroup>
<h:outputLabel id ="instance" value="#{Instance.InstanceName}"/>
<h:inputText id="instName" value="#{InstanceBean.instanceName}"/>
</h:panelGroup>
<br>

<h:panelGroup>
<h:outputLabel id="detailTitle" value="#{Instance.InstanceDetails}"/>
<h:inputTextarea id="detail" value="#{InstanceBean.details}" cols="30" />
</h:panelGroup>

<br>
<br>

<h:panelGroup>
<h:outputLabel id="role" value="#{Instance.InstanceRole}"/>
<h:selectOneMenu id="rolelist" binding="#{InstanceBean.instanceRole}">
<f:selectItems value="#{InstanceBean.listinstanceRole}"/>
</h:selectOneMenu>
</h:panelGroup>

<br>
<br>
<h:panelGroup>
<h:outputLabel id="type" value="#{Instance.InstanceType}"/>
<h:selectOneMenu id="insttype" binding="#{InstanceBean.instanceType}">
<f:selectItems value="#{InstanceBean.listinstanceType}"/>
</h:selectOneMenu>
</h:panelGroup>
<br><br>

<h:panelGroup>
<h:commandButton id="save" value="#{Instance.Save}" />
<h:commandButton id="cancel" value="#{Instance.Cancel}"/>
</h:panelGroup>
</h:panelGrid>
</h:form>
</f:view>


can anyone pls help in finding whatz wrong now ..
thankx in advance
+Pie Number of slices to send: Send
Make sure you have included all the necessary jsf jars in your lib folder.
+Pie Number of slices to send: Send
yeah all the jar files are there in
Test Libraries
Libraries
WEB-INF/lib
+Pie Number of slices to send: Send
Then it should work. Just double check evreything. I think this might be a configuration issue. Check your web.xml if you added all the necessary jsf servlet mappings, if you've added all the jsf jars in your build path, etc ...

Regards,
+Pie Number of slices to send: Send
these are the jar that are there

jsf-facelets.jar
jsf-impl.jar
jsf-api.jar
jsf-impl.jar
common-logging.jar
common-beanutil.jar
common-collections.jar
common-digester.jar
jstl-standard.jar
jstl.jar
log4j.jar
el-ri.jar
el-api.jar

here is faces-config.xml
<faces-config>
<managed-bean>
<managed-bean-name>InstanceBean</managed-bean-name>
<managed-bean-class>com.InstanceBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
</faces-config>

i really dont know whatz wrong .. i'm using Netbean& sun app server .. is there somthing i should change.
Thank you very much for your reply
+Pie Number of slices to send: Send
Your web.xml should have something like this:

+Pie Number of slices to send: Send
this is what i have web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<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.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<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><welcome-file-list><welcome-file>
index.jsp
</welcome-file></welcome-file-list></web-app>
+Pie Number of slices to send: Send
 

The import org.apache.log4j cannot be resolved
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type
SelectItem cannot be resolved to a type


Looks to me like a classpath issue. Delete all your class files and do a clean build.
+Pie Number of slices to send: Send
hey guys ,
i tried to create a new project & re-do it.. now i am getting this error ..dont know whatz wrong..


javax.servlet.ServletException: java.lang.IllegalArgumentException: argument type mismatch
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:827)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:763)
org.apache.jsp.welcomeJSF_jsp._jspService(welcomeJSF_jsp.java:113)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:105)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:336)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:297)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:247)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
java.security.AccessController.doPrivileged(Native Method)
java.security.AccessController.doPrivileged(Native Method)
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)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)


root cause

javax.faces.el.EvaluationException: java.lang.IllegalArgumentException: argument type mismatch
com.sun.faces.el.ValueBindingImpl.setValue(ValueBindingImpl.java:273)
com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:393)
javax.faces.webapp.UIComponentTag.createComponent(UIComponentTag.java:1009)
javax.faces.webapp.UIComponentTag.createChild(UIComponentTag.java:1036)
javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:749)
javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:429)
com.sun.faces.taglib.html_basic.SelectOneMenuTag.doStartTag(SelectOneMenuTag.java:487)
org.apache.jsp.welcomeJSF_jsp._jspx_meth_h_selectOneMenu_0(welcomeJSF_jsp.java:426)
org.apache.jsp.welcomeJSF_jsp._jspx_meth_h_panelGroup_2(welcomeJSF_jsp.java:388)
org.apache.jsp.welcomeJSF_jsp._jspx_meth_h_panelGrid_0(welcomeJSF_jsp.java:225)
org.apache.jsp.welcomeJSF_jsp._jspx_meth_h_form_0(welcomeJSF_jsp.java:186)
org.apache.jsp.welcomeJSF_jsp._jspx_meth_f_view_0(welcomeJSF_jsp.java:156)
org.apache.jsp.welcomeJSF_jsp._jspService(welcomeJSF_jsp.java:102)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:105)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:336)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:297)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:247)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
java.security.AccessController.doPrivileged(Native Method)
java.security.AccessController.doPrivileged(Native Method)
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)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)


if any body knows or has come across this problem pls let me know the solution
thankx in advance
+Pie Number of slices to send: Send
hey guys ,
some how that error is gone & now i have different one..
javax.servlet.ServletException: javax.faces.FacesException: javax.faces.FacesException: Can't instantiate class: 'InstanceBean'.. InstanceBean
i dont really see whatz could be the problem..
+Pie Number of slices to send: Send
Thank you very much guys ..i have finally done it.. Thank you very much for all you replies .
It was the best of times. It was the worst of times. It was a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 9767 times.
Similar Threads
Nested loops
PropertyNotFoundException exception
Unable to call Action Methof
Unable to compile class for JSP
Struts - Error - "Cannot find ActionMappings or ActionFormBeans collection"
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 08:10:51.