depois no método vc pega o evento e pelo name vc pega o parameter correto:[code]
public String excluirAtividade(ActionEvent event) {
UIParameter parameter = (UIParameter) event.getComponent().findComponent("codigocidade");
Integer codigo = new Integer(parameter.getValue().toString());//transforma o value que é Object para um Integer
[/code]
depois disso vc pode usar o código pra fazer sua consulta…
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: java.lang.NullPointerException
javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
root cause
javax.faces.el.EvaluationException: java.lang.NullPointerException
com.sun.faces.application.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
javax.faces.component.UICommand.broadcast(UICommand.java:376)
org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:61)
org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:186)
org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:164)
org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:352)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
root cause
java.lang.NullPointerException
com.Lgweb.Tcc.Controller.ControlCliente.loadUf(ControlCliente.java:137)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.apache.el.parser.AstValue.invoke(AstValue.java:131)
org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
com.sun.faces.application.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
javax.faces.component.UICommand.broadcast(UICommand.java:376)
org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:61)
org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:186)
org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:164)
org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:352)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
note The full stack trace of the root cause is available in the JBossWeb/2.0.0.GA_CP01 logs.
--------------------------------------------------------------------------------
JBossWeb/2.0.0.GA_CP01
mais este no console:[code]
21:12:12,328 INFO [STDOUT] Hibernate: select cidade0_.cidadeid as cidadeid0_, cidade0_.cidadenome as cidadenome0_, cidade0_.estadoid as estadoid0_ from cidade cidade0_
21:12:12,406 INFO [STDOUT] Hibernate: select estado0_.estadoid as estadoid17_0_, estado0_.estado as estado17_0_, estado0_.sigla as sigla17_0_ from estado estado0_ where estado0_.estadoid=?
21:12:12,421 INFO [STDOUT] Hibernate: select cidade0_.cidadeid as cidadeid0_, cidade0_.cidadenome as cidadenome0_, cidade0_.estadoid as estadoid0_ from cidade cidade0_
21:12:12,421 INFO [STDOUT] Hibernate: select estado0_.estadoid as estadoid17_0_, estado0_.estado as estado17_0_, estado0_.sigla as sigla17_0_ from estado estado0_ where estado0_.estadoid=?
21:12:18,468 INFO [STDOUT] Hibernate: select cidade0_.cidadeid as cidadeid0_1_, cidade0_.cidadenome as cidadenome0_1_, cidade0_.estadoid as estadoid0_1_, estado1_.estadoid as estadoid17_0_, estado1_.estado as estado17_0_, estado1_.sigla as sigla17_0_ from cidade cidade0_ left outer join estado estado1_ on cidade0_.estadoid=estado1_.estadoid where cidade0_.cidadeid=?
21:12:18,484 INFO [STDOUT] Hibernate: select cidade0_.cidadeid as cidadeid0_, cidade0_.cidadenome as cidadenome0_, cidade0_.estadoid as estadoid0_ from cidade cidade0_
21:12:18,484 INFO [STDOUT] Hibernate: select estado0_.estadoid as estadoid17_0_, estado0_.estado as estado17_0_, estado0_.sigla as sigla17_0_ from estado estado0_ where estado0_.estadoid=?
21:12:18,484 INFO [STDOUT] 998
21:12:18,500 INFO [STDOUT] O objeto foi carregado
21:12:18,546 WARN [lifecycle] java.lang.NullPointerException
javax.faces.el.EvaluationException: java.lang.NullPointerException
at com.sun.faces.application.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
at javax.faces.component.UICommand.broadcast(UICommand.java:376)
at org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:61)
at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:186)
at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:164)
at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:352)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
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:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
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:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at com.Lgweb.Tcc.Controller.ControlCliente.loadUf(ControlCliente.java:137)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.el.parser.AstValue.invoke(AstValue.java:131)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
at com.sun.faces.application.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
… 31 more
21:12:18,546 WARN [lifecycle] executePhase(INVOKE_APPLICATION 5,com.sun.faces.context.FacesContextImpl@1f08b14) threw exception
javax.faces.FacesException: java.lang.NullPointerException
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:105)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
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:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
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:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException
at com.sun.faces.application.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
at javax.faces.component.UICommand.broadcast(UICommand.java:376)
at org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:61)
at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:186)
at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:164)
at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:352)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
… 25 more
Caused by: java.lang.NullPointerException
at com.Lgweb.Tcc.Controller.ControlCliente.loadUf(ControlCliente.java:137)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.el.parser.AstValue.invoke(AstValue.java:131)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
at com.sun.faces.application.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
… 31 more
21:12:18,546 INFO [STDOUT] 21:12:18,546 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
java.lang.NullPointerException
at com.Lgweb.Tcc.Controller.ControlCliente.loadUf(ControlCliente.java:137)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.el.parser.AstValue.invoke(AstValue.java:131)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
at com.sun.faces.application.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
at javax.faces.component.UICommand.broadcast(UICommand.java:376)
at org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:61)
at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:186)
at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:164)
at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:352)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
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:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
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:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
o parametro esta sendo capturado com sucesso mas o metodo no dao sempre retorna null,no banco eu executo o sql que utilizo no dao e ele retorna tranquilo sera que pode ser algo na meneira que eu executo o sql?
Não sei se já resolveu, mas tenta mudar um pouco a estrutura e a query do seu método, dessa forma:
public Estado findEstado(Integer id) {
Session session = HibernateUtil.getInstance();
tx = session.beginTransaction();
Query query =session.createQuery("select e.estadoid, e.sigla from Estado e, Cidade c where c.cidadeid = :id and c.estadoid = e.estadoid").setInteger("id", id);
Estado estado = (Estado) query.uniqueResult();
session.close();
return estado;
}
Ou pelo menos mude a query pois vc tá consultando classes e não tabelas, e pra isso o HQL é case sensitive, então o certo é “Estado, Cidade” e não tudo minúsculo.
Outra coisa, não precisa instanciar um Transaction pois vc não tá efetuando nenhuma transação que precise ser comitada, é somente uma consulta, use somente em transações (insert, delete, update).
Faça esse teste e diga depois se conseguiu resolver, posso até estar enganado mas acho que o problema é esse.