Hi,
I'm trying to create a combobox on a sean project and the sean tags are not recognizing my session bean method, but if i display the list in a simple table everything is ok.
My session bean PaisSB.java:
package br.com.logical.prepark.session;
import java.util.List; import javax.persistence.EntityManager;
import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Factory; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Logger; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Out; import org.jboss.seam.annotations.Scope; import org.jboss.seam.annotations.datamodel.DataModel; import org.jboss.seam.annotations.datamodel.DataModelSelection; import org.jboss.seam.faces.FacesMessages; import org.jboss.seam.log.Log;
import br.com.logical.prepark.entity.bean.Pais;
@Scope(ScopeType.APPLICATION) @Name("paisSB") public class PaisSB{
@DataModel private List lstPais;
@In (required=false) @Out (required=false) @DataModelSelection private Pais pais;
@In private EntityManager entityManager;
@Logger private static Log log;
@SuppressWarnings("unchecked") @Factory("lstPais") public String listar(){
lstPais = (List<Pais>) entityManager.createQuery("select pais from Pais pais").getResultList();
if (lstPais.size()==0 ){
return "/pages/parametro/consultarParametro.xhtml";
}else{
FacesMessages.instance().add("Pais #{pais.nome} teste");
return null;
}
}
}
My entitybean Pais.java:
package br.com.logical.prepark.entity.bean;
import java.util.List;
import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.Table;
import org.hibernate.validator.Length; import org.hibernate.validator.NotNull; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope;
@Name("pais") @Table(name="pais") @Entity @Scope(ScopeType.APPLICATION) public class Pais implements java.io.Serializable{
private static final long serialVersionUID = 1L;
@Id
private int id;
@NotNull @Length(min=5, max=45)
@Column(name="NM_PAIS")
private String nome;
@OneToMany(mappedBy="pais")
private List<Parametro> lstParametro;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public List getLstParametro() {
return lstParametro;
}
public void setLstParametro(List<Parametro> lstParametro) {
this.lstParametro = lstParametro;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + id;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Pais other = (Pais) obj;
if (id != other.id)
return false;
return true;
}
}
tags inpage parametros.xhtml
<h:selectOneMenu value="#{parametro.pais}" required="true">
<s:selectItems value="#{paisSB.listar}" var="pais" label="#{pais.nome}" noSelectionLabel="Please Select..."/>
<s:convertEntity />
</h:selectOneMenu>
stacktrace
javax.faces.FacesException: javax.el.PropertyNotFoundException: /pages/parametro/consultarParametro.xhtml @30,119 value="#{paisSB.listar}": Property 'listar' not found on type br.com.logical.prepark.session.PaisSB_$$_javassist_seam_2 at javax.faces.component.UISelectItems.getValue(UISelectItems.java:144) at org.jboss.seam.ui.component.UISelectItems.getValue(UISelectItems.java:161) at com.sun.faces.renderkit.RenderKitUtils.getSelectItems(RenderKitUtils.java:296) at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:801) at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:280) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861) at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:242) at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:178) at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:126) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837) at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282) at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262) at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:220) at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:215) at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936) at javax.faces.render.Renderer.encodeChildren(Renderer.java:148) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942) at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592) at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100) at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:109) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83) at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178) at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290) at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390) at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517) at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446) at java.lang.Thread.run(Thread.java:619) Caused by: javax.el.PropertyNotFoundException: /pages/parametro/consultarParametro.xhtml @30,119 value="#{paisSB.listar}": Property 'listar' not found on type br.com.logical.prepark.session.PaisSB_$$_javassist_seam_2 at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:73) at javax.faces.component.UISelectItems.getValue(UISelectItems.java:141) ... 68 more
Thanks!