• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem when working with selectOneListbox

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all

i have a problem when working with <h:selectOneListbox>
or <h:selectOneMenu>.
When i select one item and submit it, it just work well ,but after using another

<h:selectOneListbox>
or <h:selectOneMenu> in another page, and making two or three page navigation,
the first page's <h:selectOneListbox>
or <h:selectOneMenu> doesn't remember its selected value.







---------------------------------------------testHandler.java----------------



import javax.faces.component.*;
import javax.faces.model.*;


import java.util.*;

public class testHandler {


private List list = new LinkedList();
private Integer ival;
private Object oval;

public testHandler() {
list.add(new SelectItem(new Integer(1), "1"));
list.add(new SelectItem(new Integer(2), "two"));
list.add(new SelectItem(new Integer(3), "three"));
list.add(new SelectItem(new Integer(4), "four"));
}

public Object getOval() {
return oval;

}


public void setOval(Object oval) {
this.oval = oval;
}

public Integer getIval() {
return ival;
}

public void setIval(Integer ival) {

this.ival = ival;

}


public void setList(List list) {
this.list = list;
}

public List getList() {
return list;
}

}


--------------------------------------------------------







-----file2.jsp---------------------------------

<%@ page contentType="text/html; charset=utf-8"%>
<%request.setCharacterEncoding("utf8");%>


<%@ page import ="VE.*"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>



<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x"%>

<jsp:useBean id="bean2" scope="session" class="testHandler" />

<f:view>

<h:form >
<h:selectOneListbox id="s5" value="#{bean2.oval}" >

<f:selectItems value="#{bean2.list}"/>

</h:selectOneListbox>

<h:commandButton value="save"/>
</br>

</h:form>
<a href="file.faces">file</a>




</f:view>

------------------------------------------



------------------------------------------






------------------file.jsp------------------------




<%@ page contentType="text/html; charset=utf-8"%>
<%request.setCharacterEncoding("utf8");%>


<%@ page import ="VE.*"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>



<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x"%>

<jsp:useBean id="bean1" scope="session" class="testHandler" />

<f:view>









<h:form >
<h:selectOneListbox id="s5" value="#{bean1.oval}" >

<f:selectItems value="#{bean1.list}"/>

</h:selectOneListbox>

<h:commandButton value="save"/>
</br>

</h:form>



<a href="file2.faces">file2</a>



</f:view>
-----------------------------------


please HELP ME!!!
THANK YOU
[ June 18, 2007: Message edited by: mohammad ghasemi hamed ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic