File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes What's the problem?Can anybody help me? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "What Watch "What New topic
Author

What's the problem?Can anybody help me?

huang qiang
Greenhorn

Joined: Dec 11, 2006
Posts: 2
In my jsf page,I had two selectOneMenu,everyone of the selectItem which had something assinged in the first selectOneMenu. when I chose from the first one,than something show in the second one.so I can chose from the second one.
But when i run it,it show
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException
javax.faces.webapp.FacesServlet.service(FacesServlet.java:209)


root cause

java.lang.IllegalArgumentException
javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:124)
javax.faces.component.UISelectOne.matchValue(UISelectOne.java:141)
javax.faces.component.UISelectOne.validateValue(UISelectOne.java:114)
javax.faces.component.UIInput.validate(UIInput.java:634)
javax.faces.component.UIInput.executeValidate(UIInput.java:838)
javax.faces.component.UIInput.processValidators(UIInput.java:412)
javax.faces.component.UIForm.processValidators(UIForm.java:170)
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:904)
javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:342)
com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:78)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)



and my code is :
<h:selectOneMenu value="#{user.selection}" onchange="submit()" valueChangeListener="#{user.ChangeItem}"styleClass="inputtext_css">
<f:selectItem itemValue="1" itemLabel="test1"/>
<f:selectItem itemValue="2" itemLabel="test2"/>
</h:selectOneMenu>
<h:selectOneMenu value="#{user.userName}">
<f:selectItems value="#{user.condiments}"/>
</h:selectOneMenu>

the bean 's code is :

private String userName;
private String password;
private String selection;
private Map condiments = new HashMap();

public void ChangeItem(ValueChangeEvent event){
if(!condiments.isEmpty()){
condiments.clear();
}
condiments.put("test", new Integer(1));
condiments.put("hq",new Integer(2));
}
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
I guess the problem is in this code



I think you should have List<SelectItem> in the value attribute of <f:selectItems> tag instead of a HashMap as user.condiments is a HashMap.
[ December 12, 2006: Message edited by: Ali Gohar ]
huang qiang
Greenhorn

Joined: Dec 11, 2006
Posts: 2
Thank you !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What's the problem?Can anybody help me?