edvaldo.santiago 20 de jul. de 2006
Bom kamikazeishida
Esse exemplo que eu fiz utiliza um link para entrar no detalhe da página
Cara eu tentei usar o seu exemplo e não funcionou…
o que estou fazendo de errado.
Aqui está o meu codigo:
<%@ taglib uri=“http://java.sun.com/jsf/core ” prefix=“f”%>
<%@ taglib uri=“http://java.sun.com/jsf/html ” prefix=“h”%>
<%@ taglib uri=“http://myfaces.apache.org/tomahawk ” prefix=“t”%>
Exemplo JSF
<h:commandLink action= "#{exemplo.lista}" >
<f:param name= "nome" value= "#{lista.nome}" />
<h:outputText value= "detalhes do Usuario" />
</h:commandLink>
</h:column>
</t:dataTable>
</h:form>
</f:view>
edvaldo.santiago 20 de jul. de 2006
Meu velho aí vai:
public class Exemplo {
private String nome ;
private String endereco ;
private String Cidade ;
private String telefone ;
private ResultSet rs ;
private List listaUsuario ;
public String getNome () {
return nome ;
}
public void setNome ( String nome ) {
this . nome = nome ;
}
public String getCidade () {
return Cidade ;
}
public String getEndereco () {
return endereco ;
}
public String getTelefone () {
return telefone ;
}
public void setCidade ( String cidade ) {
Cidade = cidade ;
}
public void setEndereco ( String endereco ) {
this . endereco = endereco ;
}
public void setTelefone ( String telefone ) {
this . telefone = telefone ;
}
public List getListaUsuario () {
return listaUsuario ;
}
public void setListaUsuario ( List listaUsuario ) {
this . listaUsuario = listaUsuario ;
}
public String lista () throws SQLException {
String retorno = new String ( "falha" );
Conexao cn = new Conexao ();
rs = cn . listaUser ();
if ( rs != null ){
listaUsuario = new ArrayList ();
while ( rs . next ()) {
Exemplo ex = new Exemplo ();
ex . nome = rs . getString ( 1 );
ex . endereco = rs . getString ( 2 );
ex . Cidade = rs . getString ( 3 );
listaUsuario . add ( ex );
}
retorno = "chCadastro" ;
}
return retorno ;
}
public String detalhe () throws SQLException {
String retorno = new String ( "falha" );
Conexao cn = new Conexao ();
rs = cn . pesquisalinha ( nome );
if ( rs . next ()) {
nome = rs . getString ( 1 );
endereco = rs . getString ( 2 );
Cidade = rs . getString ( 3 );
telefone = rs . getString ( 4 );
retorno = "chCadastro" ;
}
return retorno ;
}
}
edvaldo.santiago 20 de jul. de 2006
Cara estou com a cabeça quente…
o que seria esses Métodos por favor me desculpe… é pq estou zuado e não consigo mais pensar:
getContexto()
getHttpRequest()
edvaldo.santiago 20 de jul. de 2006
Meu velho… é o seguinte…
Quando eu crio o ServerFacesUtil do jeito que vc passou dá um erro
nos métodos e não consigo arrumar…
tem como passar o que devo fazer… se possível.
Kamikaze 20 de jul. de 2006
O link vai para uma pagina contendo a lista? Ou para uma pagina contendo o conteúdo do usuario?
Bom ai vai um exemplo:
<t:dataTable id=“lista"
rowId=”#{lista.idEnquete}“
forceIdIndexFormula=”#{lista.idEnquete}"
headerClass=“txtLabel”
columnClasses="txtGrupo"
cellpadding="1"
cellspacing="1"
rowClasses="txtTexto"
align="left"
var="lista"
width=“100%“
value=”#{enqueteController.listaEnquete}” >
<h:column id= "estrutura" >
<f:facet name= "header" >
<h:outputText value= "#{msg.msg_enquete_view_enquete_ESTRUTURA}" id= "titEstrutura" />
</f:facet>
<h:selectOneMenu value= "#{lista.idEmpresa}" tabindex= "1" disabled= "true" >
<f:selectItem id= "empresa0" itemLabel= "<SELECIONE>" itemValue= "0" />
<f:selectItem id= "empresa1" itemLabel= "Servopa Matriz" itemValue= "1" />
<f:selectItem id= "empresa2" itemLabel= "Corujonda Motos" itemValue= "2" />
<f:selectItem id= "empresa3" itemLabel= "Servopa Irati" itemValue= "3" />
<f:selectItem id= "empresa4" itemLabel= "Prixx" itemValue= "20" />
<f:selectItem id= "empresa5" itemLabel= "Servopa Ponta Grossa" itemValue= "21" />
<f:selectItem id= "empresa6" itemLabel= "Servopa Caminhoes" itemValue= "22" />
<f:selectItem id= "empresa7" itemLabel= "AutoPlus" itemValue= "23" />
<f:selectItem id= "empresa8" itemLabel= "Munich Plaza" itemValue= "24" />
<f:selectItem id= "empresa9" itemLabel= "Sevec" itemValue= "25" />
<f:selectItem id= "empresa10" itemLabel= "Servopa Vicente Machado" itemValue= "26" />
<f:selectItem id= "empresa11" itemLabel= "Servopa Motos" itemValue= "27" />
<f:selectItem id= "empresa12" itemLabel= "Vecodil" itemValue= "28" />
<f:selectItem id= "empresa13" itemLabel= "Teste" itemValue= "30" />
<f:attribute name= "label" value= "#{msg.msg_enquete_view_enquete_ESTRUTURA}" />
</h:selectOneMenu>
</h:column>
<h:column id= "titulo" >
<f:facet name= "header" >
<h:outputText value= "#{msg.msg_enquete_view_enquete_TITULO}" id= "titTitulo" />
</f:facet>
<h:outputText value= "#{lista.titulo}" id= "txtTitulo" />
</h:column>
<h:column id= "validade" >
<f:facet name= "header" >
<h:outputText value= "#{msg.msg_enquete_view_enquete_VALIDADE}" id= "titValidade" />
</f:facet>
<t:inputDate value= "#{lista.inicio}" alt= "Vencimento Inicio" disabled= "true" /><h:outputText value= " a " />
<t:inputDate value= "#{lista.fim}" alt= "Vencimento Fim" disabled= "true" />
</h:column>
<h:column id= "opcoes" >
<f:facet name= "header" >
<h:outputText value= "#{msg.msg_enquete_view_enquete_OPCOES}" id= "titOpcoes" />
</f:facet>
<h:commandLink action= "#{enqueteController.resultadoEnquete}" >
<f:param name= "idEnquete" value= "#{lista.idEnquete}" />
<h:outputText value= "Resultado" />
</h:commandLink>
</t:dataTable>
Kamikaze 20 de jul. de 2006
Bom vamos por parte
Crie uma classe chamada ServerFacesUtil.
contendo o seguintes metodos
/**
* Metodo estático usado para recuperar o mapa de parametros enviados ao
* servidor pela camada de apresentação
*
* @ return Map mapa contento parametros
*
*/
public static Map getParametros () {
return getContexto (). getExternalContext (). getRequestParameterMap ();
}
public static String getParametro ( String parametro ) {
return getHttpRequest (). getParameter ( parametro );
}
e dentro da classe Controller coloque o seguinte codigo
String nome=
String.decode(ServerFacesUtil.getParametro("nome"));
Se puder colar o codigo da classe Exemplo
Kamikaze 20 de jul. de 2006
getContexto()
getHttpRequest()
Retornam valores enviados ao servidor
Kamikaze 20 de jul. de 2006
O codigo do metodo Detalhe ficou assim
public String detalhe () throws SQLException {
//Pega o valor passado por <f:param name="nome" value="#{lista.nome}" />
String nome = String . decode ( ServerFacesUtil . getParametro ( "nome" ));
String retorno = new String ( "falha" );
Conexao cn = new Conexao ();
rs = cn . pesquisalinha ( nome );
if ( rs . next ()) {
nome = rs . getString ( 1 );
endereco = rs . getString ( 2 );
Cidade = rs . getString ( 3 );
telefone = rs . getString ( 4 );
retorno = "chCadastro" ;
}
return retorno ;
}
}
Kamikaze 20 de jul. de 2006
Kamikaze 20 de jul. de 2006
Bom me passe o projetinho por emai
[email removido]
mande zipado que eu vejo o que eu posso fazer e te mando amanha
flw