Boa noite!!
Eu queria que vcs dessem uma olhada no meu código e me informem o que eu estou fazendo errado por favor.
MEU XHTML<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:component xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Sistema Academico - Cadastro Aluno</title>
</h:head>
<h:body >
<p:dialog id="dlgaluno" header="Cadastrar Aluno" widgetVar="dlgAluno" width="450"
modal="true" >
<fieldset style="border: #036fab; border-style: outset;">
<legend>Sistema Academico - Cadastro Aluno</legend>
<h:form>
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel style="width: 170px; height: 20px" for="nome" value="Código: *" />
<h:inputText style="width: 220px; height: 20px" id="codigo" readonly="" value="#{Aluno.codigo}" />
<h:outputLabel style="width: 170px; height: 20px" for="nome" value="Nome Completo: *" />
<h:inputText style="width: 220px; height: 20px" value="#{Aluno.nome}" />
<h:outputLabel style="width: 170px; height: 20px" for="nome" value="Email: *" />
<h:inputText style="width: 220px; height: 20px" value="#{Aluno.email}" />
<h:outputLabel style="width: 170px; height: 20px" for="nome" value="Senha: *" />
<h:inputSecret style="width: 220px; height: 20px" value="#{Aluno.senha}" />
<f:facet name="footer">
<p:commandButton style="width: 100px; align: right;" value="Salvar" update="growl"
actionListener="#{Aluno.save}" />
<p:commandButton style="width: 100px; align: right;" value="Excluir" update="growl"
actionListener="#{Aluno.excluir}" />
</f:facet>
</h:panelGrid>
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel style="width: 170px; height: 20px" for="nome" value="Código: " />
<h:inputText style="width: 220px; height: 20px" id="codigo1" readonly="" value="#{Aluno.codigo}" />
<h:outputLabel style="width: 170px; height: 20px" for="nome" value="Nome: " />
<h:inputText style="width: 220px; height: 20px" value="#{Aluno.nome}" />
<h:outputLabel style="width: 170px; height: 20px" for="nome" value="Lista Alunos" />
<h:selectOneListbox style="width: 170px; height: 30px" value="#{Aluno.selectedItem}" size="1">
<f:selectItems id="selectItem" value="#{Aluno.selectItems}"/>
</h:selectOneListbox>
<f:facet name="footer">
<p:commandButton style="width: 100px; align: right;" value="Localizar" update="selectItem"
actionListener="#{Aluno.localiza}" />
<p:commandButton style="width: 100px;" value="Editar" update="growl"
actionListener="#{Aluno.save}" />
</f:facet>
</h:panelGrid>
</h:form>
</fieldset>
</p:dialog>
</h:body>
</ui:component>
package br.com.SistemaAcademico.Bean;
import br.com.SistemaAcademico.ManageBean.AlunoManageBean;
import java.util.ArrayList;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.event.ActionEvent;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
*/
@ManagedBean(name="Aluno")
@SessionScoped
public class Aluno {
private Integer codigo;
private String nome;
private String email;
private String senha;
private String selectedItem;
private ArrayList<String> selectItems;
public String getSelectedItem() {
return selectedItem;
}
public void setSelectedItem(String selectedItem) {
this.selectedItem = selectedItem;
}
public Integer getCodigo() {
return codigo;
}
public void setCodigo(Integer codigo) {
this.codigo = codigo;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
public ArrayList<String> getSelectItems() {
return selectItems;
}
public void setSelectItems(ArrayList<String> selectItems) {
this.selectItems = selectItems;
}
public void save(ActionEvent event){
AlunoManageBean user = new AlunoManageBean();
user.salvar(this);
}
public void localiza(ActionEvent event){
AlunoManageBean bean = new AlunoManageBean();
setSelectItems(bean.buscar(this));
System.out.println("TESTANDO: "+selectItems.get(0));
System.out.println("TESTANDO: "+selectItems.get(1));
}
public void editar(ActionEvent e){
//EIS A MINHA DUVIDA MAIOR COMO CARREGAR OS CAMPOS DA PAGINA WEB AO AO CLICAR NO BOTAO EDITAR
}
public void excluir(ActionEvent e){
}
}
Como voces podem ver eu coloquei 2 println ali pra conferir se o arraylist está mesmo sendo carregado.
Ao pesquisar com a palavra "teste" obtive 2 retornos, ou seja, esta carregando perfeitamente ... por tanto o erro esta dai pra frente.
INFO: TESTANDO: teste
INFO: TESTANDO: teste3
Por fim eu gostaria de saber. Ao selecionar o item no selectItem como eu carrego os dados da tabela nos campos do xhtml ?
Desde já. Obrigado!!