jsf - Primefaces selectonemenu displaying data outside the input -
this question has answer here:
i'm new web programming , manage make work proper connections dropdown populate; i'm using eclipse, latest jdk, wildfly 10 server, mysql server 5.7, primefaces 5.3, javax.faces 2.2.
this page:
<?xml version='1.0' encoding='utf-8'?> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" > <head> <title>combobox</title> </head> <body> <h:form id="form1"> <p:panel header="ingreso" style="width: 600px;"> <h:panelgrid columns="2"> <h:outputtext value="provincia: " /> <p:selectonemenu value="#{usuario.provincia}" id="prov" valuechangelistener="#{usuario.processcant()}" > <f:selectitem itemlabel="seleccione" itemvalue="" /> <f:selectitems value="#{usuario.provincias}" /> <p:ajax update="cant" event="change" /> </p:selectonemenu> <h:outputtext value="cantón: " /> <p:selectonemenu value="#{usuario.canton}" id="cant" valuechangelistener="#{usuario.processparr()}"> <f:selectitem itemlabel="seleccione" itemvalue="" /> <f:selectitems value="#{usuario.cantones}"/> <p:ajax update="parr" event="change" /> </p:selectonemenu> <h:outputtext value="parroquia: " /> <p:selectonemenu value="#{usuario.parroquia}" id="parr"> <f:selectitem itemlabel="seleccione" itemvalue="" /> <f:selectitems value="#{usuario.parroquias}"/> </p:selectonemenu> </h:panelgrid> </p:panel> </h:form> </body> </html>
and java:
@managedbean(name="usuario") @sessionscoped public class usuario implements serializable { private static final long serialversionuid = 1l; private int id; private string nombre; private string apellido; private string fecha; private string lugar; private string numero; private string provincia; private list<selectitem> provincias; private string canton; private list<selectitem> cantones; private string parroquia; private list<selectitem> parroquias; public list<selectitem> getprovincias() { list<selectitem> catprovincias = new arraylist<selectitem>(); try { connection con = drivermanager.getconnection("jdbc:mysql://localhost:3306/schema", "root", "root"); statement st = con.createstatement(); resultset rs = null; string myquery = "select provincia `schema`.provincia;"; rs = st.executequery(myquery); while (rs.next()) { catprovincias.add(new selectitem(rs.getstring("provincia"))); } } catch (exception ex) { ex.printstacktrace(); } return catprovincias; } public list<selectitem> getcantones() { list<selectitem> catcantones = new arraylist<selectitem>(); try { connection con = drivermanager.getconnection("jdbc:mysql://localhost:3306/schema", "root", "root"); statement st = con.createstatement(); resultset rs = null; string myquery = "select canton `schema`.canton padre=(select provincia `schema`.provincia provincia='"+ provincia + "')"; rs = st.executequery(myquery); while (rs.next()) { catcantones.add(new selectitem(rs.getstring("canton"))); } } catch (exception ex) { ex.printstacktrace(); } return catcantones; } public list<selectitem> getparroquias() { list<selectitem> catparroquias = new arraylist<selectitem>(); try { connection con = drivermanager.getconnection("jdbc:mysql://localhost:3306/schema", "root", "root"); statement st = con.createstatement(); resultset rs = null; string myquery = "select parroquia `schema`.parroquia padre=(select canton `schema`.canton canton='"+ canton +"')"; rs = st.executequery(myquery); while (rs.next()) { catparroquias.add(new selectitem(rs.getstring("parroquia"))); } } catch (exception ex) { ex.printstacktrace(); } return catparroquias; } public void processcant() { getcantones(); } public void processparr() { getparroquias(); }
...
as can see data shows duplicated outside, there's unexisting inputtext shown , style primefaces @ all, have no idea happening, please advice.
you have replace <head></head>
tags jsf specific <h:head></h:head>
tags primefaces import necessary js , css files.
Comments
Post a Comment