fabiozoroastro 10 de ago. de 2011
Tiago,
Não tenho certeza(e estou com preguiça de olhar na doc do SEAM), mas acho que o componente UISelectItems não aceita um Map<String, T> como argumento.
Confirme se aceita. =)
Até mais.
kimtiago 10 de ago. de 2011
Acho que é algum problema com o binding do seam.
Tentei fazer o binding de uma simples string imprimindo no xhtml. E ele não retorna nada.
Alguem sabe se tem q configurar alguma coisa no Seam pra ativar o binding?
kimtiago 11 de ago. de 2011
pessoal,
realmente toh precisando de ajuda.
descobri que na verdade, o que está aocntecendo, é que não está sendo feito o bind.
Não sei o que pode ser. Alguem já passou por isso?
fabiozoroastro 11 de ago. de 2011
Tiago,
quando você coloca um atributo no seu managed-bean e o referencia em seu XHTML qual é o resultado?
Poste aqui o resultado, o código do XHTML, do ManagedBean e também o código fonte gerado no browser.
Abraço.
kimtiago 11 de ago. de 2011
Removi a parte do SelectItem e coloquei um simples bind de String. Pois descobri que o problema está aí.
Meu XHTML
& lt ;! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" & gt ;
& lt ; 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 : ui = "http://java.sun.com/jsf/facelets"
xmlns : s = "http://jboss.com/products/seam/taglib"
xmlns : rich = "http://richfaces.org/rich" & gt ;
& lt ; ui : composition template = "/layout/template.xhtml" & gt ;
& lt ; ui : define name = "body" & gt ;
& lt ; h1 & gt ; Cadastro de Trechos & lt ;/ h1 & gt ;
& lt ; h : form & gt ;
& lt ; h : outputText value = "#{localidadesHandler.origem}" /& gt ;
& lt ;! -- & lt ; h : selectOneMenu & gt ;
& lt ; f : selectItems value = "#{localidadesHandler.localidades}" /& gt ;
& lt ;/ h : selectOneMenu & gt ;
Destino :
& lt ; h : selectOneMenu & gt ;
& lt ; f : selectItems value = "#{localidadesHandler.localidades}" /& gt ;
& lt ;/ h : selectOneMenu & gt ;
-- & gt ;
& lt ;/ h : form & gt ;
& lt ;/ ui : define & gt ;
& lt ;/ ui : composition & gt ;
& lt ;/ html & gt ;
Codigo fonte da tela apresentada
& lt ; ! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" & gt ;
& lt ; html xmlns = "http://www.w3.org/1999/xhtml" & gt ;
& lt ; head & gt ;
& lt ; meta http - equiv = "Content-Type" content = "text/html; charset=UTF-8" /& gt ;
& lt ; title & gt ; aeris & lt ; / title & gt ;
& lt ; link class = "component" href = "/aeris/a4j/s/3_3_3.Finalorg/richfaces/renderkit/html/css/basic_classes.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__;jsessionid=9E88C6CBEE7FA027DDBD9ACE6C8F0EE6" rel = "stylesheet" type = "text/css" /& gt ; & lt ; link class = "component" href = "/aeris/a4j/s/3_3_3.Finalorg/richfaces/renderkit/html/css/extended_classes.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__;jsessionid=9E88C6CBEE7FA027DDBD9ACE6C8F0EE6" media = "rich-extended-skinning" rel = "stylesheet" type = "text/css" /& gt ; & lt ; link class = "component" href = "/aeris/a4j/s/3_3_3.Finalcss/toolBar.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__;jsessionid=9E88C6CBEE7FA027DDBD9ACE6C8F0EE6" rel = "stylesheet" type = "text/css" /& gt ; & lt ; script src = "/aeris/a4j/g/3_3_3.Finalorg.ajax4jsf.javascript.AjaxScript" type = "text/javascript" & gt ; & lt ; / script & gt ; & lt ; script type = "text/javascript" & gt ; window . RICH_FACES_EXTENDED_SKINNING_ON = true ; & lt ; / script & gt ; & lt ; script src = "/aeris/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/skinning.js" type = "text/javascript" & gt ; & lt ; / script & gt ; & lt ; link class = "user" href = "/aeris/stylesheet/theme.xcss;jsessionid=9E88C6CBEE7FA027DDBD9ACE6C8F0EE6" rel = "stylesheet" type = "text/css" /& gt ; & lt ; link class = "user" href = "/aeris/stylesheet/theme.css;jsessionid=9E88C6CBEE7FA027DDBD9ACE6C8F0EE6" rel = "stylesheet" type = "text/css" /& gt ; & lt ; link rel = "shortcut icon" href = "/aeris/favicon.ico" /& gt ;
& lt ; / head & gt ;
& lt ; body & gt ; & lt ; table border = "0" cellpadding = "0" cellspacing = "0" class = "rich-toolbar " id = "j_id5" width = "100%" & gt ; & lt ; tr valign = "middle" & gt ; & lt ; td class = "rich-toolbar-item " style = ";" & gt ; aeris : & lt ; / td & gt ; & lt ; td class = "rich-toolbar-item " style = ";" & gt ; < a > Home </ a >& lt ; / td & gt ; & lt ; td class = "rich-toolbar-item " & gt ;
& lt ; !-- @ newMenuItem @ --& gt ; & lt ; / td & gt ; & lt ; td style = "width:100%" & gt ; & lt ; / td & gt ; & lt ; td class = "rich-toolbar-item " style = ";" & gt ; < a > Login </ a >& lt ; / td & gt ; & lt ; / tr & gt ; & lt ; / table & gt ;
& lt ; div class = "body" & gt ;
& lt ; h1 & gt ; Cadastro de Trechos & lt ; / h1 & gt ;
& lt ; form id = "j_id12" name = "j_id12" method = "post" action = "/aeris/trechos.seam;jsessionid=9E88C6CBEE7FA027DDBD9ACE6C8F0EE6" enctype = "application/x-www-form-urlencoded" & gt ;
& lt ; input type = "hidden" name = "j_id12" value = "j_id12" /& gt ;
& lt ; !-- & lt ; h : selectOneMenu & gt ;
& lt ; f : selectItems value = "" /& gt ;
& lt ; / h : selectOneMenu & gt ;
Destino :
& lt ; h : selectOneMenu & gt ;
& lt ; f : selectItems value = "" /& gt ;
& lt ; / h : selectOneMenu & gt ; --& gt ; & lt ; input type = "hidden" name = "javax.faces.ViewState" id = "javax.faces.ViewState" value = "j_id1" autocomplete = "off" /& gt ;
& lt ; / form & gt ;
& lt ; / div & gt ;
& lt ; div class = "footer" & gt ;
< p > Powered by < a href = "http://seamframework.org" > Seam </ a > 2.2 . 2. Final and < a href = "http://www.jboss.org/jbossrichfaces" > RichFaces </ a >. Generated by seam - gen .</ p >& lt ; script id = "j_id17" type = "text/javascript" & gt ; LOG . registerPopup ( 'D' , 'LogWindow' , 800 , 600 , LOG . ALL ); & lt ; / script & gt ;
< p >
Conversation : id = 1 , temporary
-
Ajax4jsf Log ( Ctrl + Shift + D )
- < a target = "debugConsole" > Debug console </ a >
- < a > Terminate session </ a >
</ p >
& lt ; / div & gt ;
& lt ; / body & gt ;
& lt ; / html & gt ;
Meu managed Bean
package br.com.caelum.aeris.logic ;
import java.util.HashMap ;
import java.util.Map ;
import org.jboss.seam.annotations.Name ;
import br.com.caelum.aeris.entities.Localidade ;
@Name ( "localidadesHandler" )
public class LocalidadesHandler {
public Map & lt ; String , Localidade & gt ; getLocalidades () {
System . out . println ( "Iniciando Localidades" );
Map & lt ; String , Localidade & gt ; opcoes = new HashMap & lt ; String , Localidade & gt ;();
for ( Localidade l : Localidade . values ()) {
opcoes . put ( l . getNome (), l );
}
return opcoes ;
}
//atributo de teste
private String origem = "Origem" ;
public String getOrigem () { return origem ;}
public void setOrigem ( String origem ) { this . origem = origem ;}
}
Meu Entity
package br.com.caelum.aeris.entities ;
import java.io.Serializable ;
public enum Localidade implements Serializable {
SAO_PAULO ( "São Paulo" ), RIO_DE_JANEIRO ( "Rio de Janeiro" ), NOVA_IORQUE (
"Nova Iorque" ), PARIS ( "Paris" ), LONDRES ( "Londres" ), MOSCOU ( "Moscou" );
private final String nome ;
private Localidade ( String nome ) {
this . nome = nome ;
}
public String getNome () {
return nome ;
}
}
fabiozoroastro 11 de ago. de 2011
Se você colocar um breakpoint no getOrigem ele para?
Coloca um escopo qualquer no seu ManagedBean apenas para não deixar o padrão(“unspecified”).
kimtiago 11 de ago. de 2011
Coloquei o @Scope para APPLICATION
Coloquei um breakpoint, Ele nem entra no getOrigem
tentei colocar System.out.println ali tambem, e nada…
fabiozoroastro 11 de ago. de 2011
Como vc acessa sua URL?
Posta o link que você está usando para testes.
kimtiago 11 de ago. de 2011
O nome do xhtml é trechos.xhtml
A url que eu estou utiliznando é esta aki
http://localhost:8080/aeris/trechos.seam
Aí vai uma copia do meu faces-config
& lt ;? xml version = "1.0" encoding = "UTF-8" ?& gt ;
& lt ; faces-config
xmlns = "http://java.sun.com/xml/ns/javaee"
xmlns : xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi : schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
version = "1.2" & gt ;
& lt ; application & gt ;
& lt ; view-handler & gt ; com . sun . facelets . FaceletViewHandler & lt ;/ view-handler & gt ;
& lt ; locale-config & gt ;
& lt ; default-locale & gt ; en & lt ;/ default-locale & gt ;
& lt ; supported-locale & gt ; bg & lt ;/ supported-locale & gt ;
& lt ; supported-locale & gt ; de & lt ;/ supported-locale & gt ;
& lt ; supported-locale & gt ; en & lt ;/ supported-locale & gt ;
& lt ; supported-locale & gt ; fr & lt ;/ supported-locale & gt ;
& lt ; supported-locale & gt ; tr & lt ;/ supported-locale & gt ;
& lt ;/ locale-config & gt ;
& lt ;/ application & gt ;
& lt ;/ faces-config & gt ;
e do web.xml
& lt ; ? xml version = "1.0" encoding = "UTF-8" ? & gt ;
& lt ; web - app xmlns : xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns = "http://java.sun.com/xml/ns/javaee" xmlns : web = "http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi : schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id = "WebApp_ID" version = "2.5" & gt ;
& lt ; display - name & gt ; aeris & lt ; / display - name & gt ;
& lt ; welcome - file - list & gt ;
& lt ; welcome - file & gt ; index . html & lt ; / welcome - file & gt ;
& lt ; welcome - file & gt ; index . htm & lt ; / welcome - file & gt ;
& lt ; welcome - file & gt ; index . jsp & lt ; / welcome - file & gt ;
& lt ; welcome - file & gt ; default . html & lt ; / welcome - file & gt ;
& lt ; welcome - file & gt ; default . htm & lt ; / welcome - file & gt ;
& lt ; welcome - file & gt ; default . jsp & lt ; / welcome - file & gt ;
& lt ; / welcome - file - list & gt ;
& lt ; servlet & gt ;
& lt ; servlet - name & gt ; Faces Servlet & lt ; / servlet - name & gt ;
& lt ; servlet - class & gt ; javax . faces . webapp . FacesServlet & lt ; / servlet - class & gt ;
& lt ; load - on - startup & gt ; 1 & lt ; / load - on - startup & gt ;
& lt ; / servlet & gt ;
& lt ; servlet - mapping & gt ;
& lt ; servlet - name & gt ; Faces Servlet & lt ; / servlet - name & gt ;
& lt ; url - pattern & gt ; *. seam & lt ; / url - pattern & gt ;
& lt ; / servlet - mapping & gt ;
& lt ; context - param & gt ;
& lt ; param - name & gt ; org . jboss . jbossfaces . JSF_CONFIG_NAME & lt ; / param - name & gt ;
& lt ; param - value & gt ; Mojarra - 1.2 & lt ; / param - value & gt ;
& lt ; / context - param & gt ;
& lt ; context - param & gt ;
& lt ; param - name & gt ; org . richfaces . SKIN & lt ; / param - name & gt ;
& lt ; param - value & gt ; blueSky & lt ; / param - value & gt ;
& lt ; / context - param & gt ;
& lt ; listener & gt ;
& lt ; listener - class & gt ; org . jboss . seam . servlet . SeamListener & lt ; / listener - class & gt ;
& lt ; / listener & gt ;
& lt ; filter & gt ;
& lt ; filter - name & gt ; Seam Filter & lt ; / filter - name & gt ;
& lt ; filter - class & gt ; org . jboss . seam . servlet . SeamFilter & lt ; / filter - class & gt ;
& lt ; / filter & gt ;
& lt ; filter - mapping & gt ;
& lt ; filter - name & gt ; Seam Filter & lt ; / filter - name & gt ;
& lt ; url - pattern & gt ; /*& lt ; / url - pattern & gt ;
& lt ; / filter - mapping & gt ;
& lt ; servlet & gt ;
& lt ; servlet - name & gt ; Seam Resource Servlet & lt ; / servlet - name & gt ;
& lt ; servlet - class & gt ; org . jboss . seam . servlet . SeamResourceServlet & lt ; / servlet - class & gt ;
& lt ; / servlet & gt ;
& lt ; servlet - mapping & gt ;
& lt ; servlet - name & gt ; Seam Resource Servlet & lt ; / servlet - name & gt ;
& lt ; url - pattern & gt ; / seam / resource /*& lt ; / url - pattern & gt ;
& lt ; / servlet - mapping & gt ;
& lt ; context - param & gt ;
& lt ; param - name & gt ; facelets . DEVELOPMENT & lt ; / param - name & gt ;
& lt ; param - value & gt ; true & lt ; / param - value & gt ;
& lt ; / context - param & gt ;
& lt ; context - param & gt ;
& lt ; param - name & gt ; javax . faces . DEFAULT_SUFFIX & lt ; / param - name & gt ;
& lt ; param - value & gt ; . xhtml & lt ; / param - value & gt ;
& lt ; / context - param & gt ;
& lt ; security - constraint & gt ;
& lt ; display - name & gt ; Restrict raw XHTML Documents & lt ; / display - name & gt ;
& lt ; web - resource - collection & gt ;
& lt ; web - resource - name & gt ; XHTML & lt ; / web - resource - name & gt ;
& lt ; url - pattern & gt ; *. xhtml & lt ; / url - pattern & gt ;
& lt ; / web - resource - collection & gt ;
& lt ; auth - constraint /& gt ;
& lt ; / security - constraint & gt ;
& lt ; / web - app & gt ;
fabiozoroastro 11 de ago. de 2011
Tiago,
ainda não consegui identificar nenhum problema.
Faça um teste:
Deixe o seu XHTML o mais limpo possível, ou seja, não inclua nenhum template.
Apenas deixe o cabeçalho do XHTML e o outputText.
Mais ou menos assim:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< f:view xmlns = "http://www.w3.org/1999/xhtml"
xmlns:ui = "http://java.sun.com/jsf/facelets"
xmlns:f = "http://java.sun.com/jsf/core" xmlns:h = "http://java.sun.com/jsf/html"
xmlns:rich = "http://richfaces.org/rich"
xmlns:s = "http://jboss.com/products/seam/taglib"
xmlns:a4j = "http://richfaces.org/a4j"
contentType = "text/html" >
< html >
< body >
ABC ( < h:outputText value = "#{localidadesHandler.origem}" /> ) DEF...
</ body >
</ html >
</ f:view >
Veja o resultado.
Poste o código-fonte gerado aí…
Até mais.
kimtiago 11 de ago. de 2011
fabio
Muito obrigado pela sua ajuda.
Consegui descobrir o problema.
Ao criar o projeto no eclipse, o seam cria 4 projetos.
aeris
aeris-ear
aeris-ejb
aeris-test
Na apostila que eu estou utilizando, fala para criar a classe LocalidadesHandler dentro do projeto “aeris”
Junto com um amigo aki do trampo, tivemos a ideia de colocar esta classe dentro do “aeris-ejb”, e funcionou. A apostila estava errada.
Fica aí a solução para quem futuramente cair nessa armadilha.
Mais uma vez, obrigado!
fernando_franzim 20 de ago. de 2011
Obrigado, colocar a solução tb me ajudou.