satangoss 7 de nov. de 2011
Olá Vivi use o setPropertyActionListener para setar o valor assim:
<h:dataTable value= "#{buscaPorTipoMaisVotado.listaProdutos}" var= "movel" border= "1" >
<h:column>
<h:graphicImage id= "img" value= "/imagens/#{movel.idProduto}.jpg" width= "100" height= "100" />
<f:setPropertyActionListener target= "#{seuOutroBean.variavelSetada}" value= "#{movel.idProduto}" />
</h:column>
</h:dataTable>
Assim quando o cara clicar na imagem o idProduto será enviado para a variavelSetada da sua classe, simples assim
Vivis.sf 7 de nov. de 2011
Coloquei do jeito que você me falou, mas acho que estou fazendo mais alguma coisa errada, pois está retornando erro:
& lt ; html & gt ;
& lt ; body & gt ;
& lt ; f : view & gt ;
& lt ; h : outputText value = "Moveis mais votados dos tipos selecionados: " /& gt ;
& lt ; h : panelGrid columns = "1" border = "1" & gt ;
& lt ; h : dataTable value = "#{buscaPorTipoMaisVotado.listaProdutos}"
var = "movel" border = "1" & gt ;
& lt ; h : column & gt ;
& lt ; h : graphicImage id = "img" value = "/imagens/#{movel.idProduto}.jpg"
width = "100" height = "100" /& gt ;
& lt ; f : setPropertyActionListener target = "#{mostrarMovel.idProduto}" value = "#{movel.idProduto}" /& gt ;
& lt ; / h : column & gt ;
& lt ; / h : dataTable & gt ;
& lt ; / h : panelGrid & gt ;
& lt ; / f : view & gt ;
& lt ; / body & gt ;
& lt ; / html & gt ;
Em “mostrarMovel” tenho o atributo idProduto, com seu devido getter e setter.
javax . servlet . jsp . JspException : null MessageFactory
at com . sun . faces . taglib . jsf_core . SetPropertyActionListenerTag . doStartTag ( SetPropertyActionListenerTag . java : 155 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspx_meth_f_005fsetPropertyActionListener_005f0 ( buscaPorTipoMaisVotado_jsp . java : 405 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspx_meth_h_005fcolumn_005f0 ( buscaPorTipoMaisVotado_jsp . java : 342 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspx_meth_h_005fdataTable_005f0 ( buscaPorTipoMaisVotado_jsp . java : 296 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspx_meth_h_005fpanelGrid_005f0 ( buscaPorTipoMaisVotado_jsp . java : 248 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspx_meth_h_005fform_005f0 ( buscaPorTipoMaisVotado_jsp . java : 178 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspx_meth_f_005fview_005f0 ( buscaPorTipoMaisVotado_jsp . java : 131 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspService ( buscaPorTipoMaisVotado_jsp . java : 94 )
at org . apache . jasper . runtime . HttpJspBase . service ( HttpJspBase . java : 70 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 722 )
at org . apache . jasper . servlet . JspServletWrapper . service ( JspServletWrapper . java : 433 )
at org . apache . jasper . servlet . JspServlet . serviceJspFile ( JspServlet . java : 389 )
at org . apache . jasper . servlet . JspServlet . service ( JspServlet . java : 333 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 722 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 304 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 210 )
at org . apache . catalina . core . ApplicationDispatcher . invoke ( ApplicationDispatcher . java : 684 )
at org . apache . catalina . core . ApplicationDispatcher . processRequest ( ApplicationDispatcher . java : 471 )
at org . apache . catalina . core . ApplicationDispatcher . doForward ( ApplicationDispatcher . java : 402 )
at org . apache . catalina . core . ApplicationDispatcher . forward ( ApplicationDispatcher . java : 329 )
at com . sun . faces . context . ExternalContextImpl . dispatch ( ExternalContextImpl . java : 408 )
at com . sun . faces . application . ViewHandlerImpl . executePageToBuildView ( ViewHandlerImpl . java : 439 )
at com . sun . faces . application . ViewHandlerImpl . renderView ( ViewHandlerImpl . java : 114 )
at com . sun . faces . lifecycle . RenderResponsePhase . execute ( RenderResponsePhase . java : 106 )
at com . sun . faces . lifecycle . LifecycleImpl . phase ( LifecycleImpl . java : 251 )
at com . sun . faces . lifecycle . LifecycleImpl . render ( LifecycleImpl . java : 144 )
at javax . faces . webapp . FacesServlet . service ( FacesServlet . java : 266 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 304 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 210 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 224 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 169 )
at org . apache . catalina . authenticator . AuthenticatorBase . invoke ( AuthenticatorBase . java : 472 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 168 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 100 )
at org . apache . catalina . valves . AccessLogValve . invoke ( AccessLogValve . java : 929 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 118 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 405 )
at org . apache . coyote . http11 . AbstractHttp11Processor . process ( AbstractHttp11Processor . java : 964 )
at org . apache . coyote . AbstractProtocol$AbstractConnectionHandler . process ( AbstractProtocol . java : 515 )
at org . apache . tomcat . util . net . JIoEndpoint$SocketProcessor . run ( JIoEndpoint . java : 304 )
at java . util . concurrent . ThreadPoolExecutor$Worker . runTask ( Unknown Source )
at java . util . concurrent . ThreadPoolExecutor$Worker . run ( Unknown Source )
at java . lang . Thread . run ( Unknown Source )
07 / 11 / 2011 18 : 27 : 04 com . sun . faces . lifecycle . LifecycleImpl phase
AVISO : executePhase ( RENDER_RESPONSE 6 , com . sun . faces . context . FacesContextImpl @16 ea7549 ) threw exception
javax . faces . FacesException : org . apache . jasper . JasperException : An exception occurred processing JSP page / buscaPorTipoMaisVotado . jsp at line 17
14 : & lt ; h : column & gt ;
15 : & lt ; h : graphicImage id = "img" value = "/imagens/#{movel.idProduto}.jpg"
16 : width = "100" height = "100" /& gt ;
17 : & lt ; f : setPropertyActionListener target = "#{mostrarMovel.idProduto}" value = "#{movel.idProduto}" /& gt ;
18 : & lt ; / h : column & gt ;
19 : & lt ; / h : dataTable & gt ;
20 : & lt ; / h : panelGrid & gt ;
Stacktrace :
at com . sun . faces . context . ExternalContextImpl . dispatch ( ExternalContextImpl . java : 413 )
at com . sun . faces . application . ViewHandlerImpl . executePageToBuildView ( ViewHandlerImpl . java : 439 )
at com . sun . faces . application . ViewHandlerImpl . renderView ( ViewHandlerImpl . java : 114 )
at com . sun . faces . lifecycle . RenderResponsePhase . execute ( RenderResponsePhase . java : 106 )
at com . sun . faces . lifecycle . LifecycleImpl . phase ( LifecycleImpl . java : 251 )
at com . sun . faces . lifecycle . LifecycleImpl . render ( LifecycleImpl . java : 144 )
at javax . faces . webapp . FacesServlet . service ( FacesServlet . java : 266 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 304 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 210 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 224 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 169 )
at org . apache . catalina . authenticator . AuthenticatorBase . invoke ( AuthenticatorBase . java : 472 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 168 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 100 )
at org . apache . catalina . valves . AccessLogValve . invoke ( AccessLogValve . java : 929 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 118 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 405 )
at org . apache . coyote . http11 . AbstractHttp11Processor . process ( AbstractHttp11Processor . java : 964 )
at org . apache . coyote . AbstractProtocol$AbstractConnectionHandler . process ( AbstractProtocol . java : 515 )
at org . apache . tomcat . util . net . JIoEndpoint$SocketProcessor . run ( JIoEndpoint . java : 304 )
at java . util . concurrent . ThreadPoolExecutor$Worker . runTask ( Unknown Source )
at java . util . concurrent . ThreadPoolExecutor$Worker . run ( Unknown Source )
at java . lang . Thread . run ( Unknown Source )
Caused by : org . apache . jasper . JasperException : An exception occurred processing JSP page / buscaPorTipoMaisVotado . jsp at line 17
14 : & lt ; h : column & gt ;
15 : & lt ; h : graphicImage id = "img" value = "/imagens/#{movel.idProduto}.jpg"
16 : width = "100" height = "100" /& gt ;
17 : & lt ; f : setPropertyActionListener target = "#{mostrarMovel.idProduto}" value = "#{movel.idProduto}" /& gt ;
18 : & lt ; / h : column & gt ;
19 : & lt ; / h : dataTable & gt ;
20 : & lt ; / h : panelGrid & gt ;
Stacktrace :
at org . apache . jasper . servlet . JspServletWrapper . handleJspException ( JspServletWrapper . java : 567 )
at org . apache . jasper . servlet . JspServletWrapper . service ( JspServletWrapper . java : 456 )
at org . apache . jasper . servlet . JspServlet . serviceJspFile ( JspServlet . java : 389 )
at org . apache . jasper . servlet . JspServlet . service ( JspServlet . java : 333 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 722 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 304 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 210 )
at org . apache . catalina . core . ApplicationDispatcher . invoke ( ApplicationDispatcher . java : 684 )
at org . apache . catalina . core . ApplicationDispatcher . processRequest ( ApplicationDispatcher . java : 471 )
at org . apache . catalina . core . ApplicationDispatcher . doForward ( ApplicationDispatcher . java : 402 )
at org . apache . catalina . core . ApplicationDispatcher . forward ( ApplicationDispatcher . java : 329 )
at com . sun . faces . context . ExternalContextImpl . dispatch ( ExternalContextImpl . java : 408 )
... 22 more
Caused by : javax . servlet . ServletException : javax . servlet . jsp . JspException : null MessageFactory
at org . apache . jasper . runtime . PageContextImpl . doHandlePageException ( PageContextImpl . java : 911 )
at org . apache . jasper . runtime . PageContextImpl . handlePageException ( PageContextImpl . java : 840 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspService ( buscaPorTipoMaisVotado_jsp . java : 104 )
at org . apache . jasper . runtime . HttpJspBase . service ( HttpJspBase . java : 70 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 722 )
at org . apache . jasper . servlet . JspServletWrapper . service ( JspServletWrapper . java : 433 )
... 32 more
Caused by : javax . servlet . jsp . JspException : null MessageFactory
at com . sun . faces . taglib . jsf_core . SetPropertyActionListenerTag . doStartTag ( SetPropertyActionListenerTag . java : 155 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspx_meth_f_005fsetPropertyActionListener_005f0 ( buscaPorTipoMaisVotado_jsp . java : 405 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspx_meth_h_005fcolumn_005f0 ( buscaPorTipoMaisVotado_jsp . java : 342 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspx_meth_h_005fdataTable_005f0 ( buscaPorTipoMaisVotado_jsp . java : 296 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspx_meth_h_005fpanelGrid_005f0 ( buscaPorTipoMaisVotado_jsp . java : 248 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspx_meth_h_005fform_005f0 ( buscaPorTipoMaisVotado_jsp . java : 178 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspx_meth_f_005fview_005f0 ( buscaPorTipoMaisVotado_jsp . java : 131 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspService ( buscaPorTipoMaisVotado_jsp . java : 94 )
... 35 more
07 / 11 / 2011 18 : 27 : 04 org . apache . catalina . core . StandardWrapperValve invoke
GRAVE : Servlet . service () for servlet [ Faces Servlet ] in context with path [ / tcc ] threw exception [ An exception occurred processing JSP page / buscaPorTipoMaisVotado . jsp at line 17
14 : & lt ; h : column & gt ;
15 : & lt ; h : graphicImage id = "img" value = "/imagens/#{movel.idProduto}.jpg"
16 : width = "100" height = "100" /& gt ;
17 : & lt ; f : setPropertyActionListener target = "#{mostrarMovel.idProduto}" value = "#{movel.idProduto}" /& gt ;
18 : & lt ; / h : column & gt ;
19 : & lt ; / h : dataTable & gt ;
20 : & lt ; / h : panelGrid & gt ;
Stacktrace :] with root cause
javax . servlet . jsp . JspException : null MessageFactory
at com . sun . faces . taglib . jsf_core . SetPropertyActionListenerTag . doStartTag ( SetPropertyActionListenerTag . java : 155 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspx_meth_f_005fsetPropertyActionListener_005f0 ( buscaPorTipoMaisVotado_jsp . java : 405 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspx_meth_h_005fcolumn_005f0 ( buscaPorTipoMaisVotado_jsp . java : 342 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspx_meth_h_005fdataTable_005f0 ( buscaPorTipoMaisVotado_jsp . java : 296 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspx_meth_h_005fpanelGrid_005f0 ( buscaPorTipoMaisVotado_jsp . java : 248 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspx_meth_h_005fform_005f0 ( buscaPorTipoMaisVotado_jsp . java : 178 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspx_meth_f_005fview_005f0 ( buscaPorTipoMaisVotado_jsp . java : 131 )
at org . apache . jsp . buscaPorTipoMaisVotado_jsp . _jspService ( buscaPorTipoMaisVotado_jsp . java : 94 )
at org . apache . jasper . runtime . HttpJspBase . service ( HttpJspBase . java : 70 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 722 )
at org . apache . jasper . servlet . JspServletWrapper . service ( JspServletWrapper . java : 433 )
at org . apache . jasper . servlet . JspServlet . serviceJspFile ( JspServlet . java : 389 )
at org . apache . jasper . servlet . JspServlet . service ( JspServlet . java : 333 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 722 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 304 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 210 )
at org . apache . catalina . core . ApplicationDispatcher . invoke ( ApplicationDispatcher . java : 684 )
at org . apache . catalina . core . ApplicationDispatcher . processRequest ( ApplicationDispatcher . java : 471 )
at org . apache . catalina . core . ApplicationDispatcher . doForward ( ApplicationDispatcher . java : 402 )
at org . apache . catalina . core . ApplicationDispatcher . forward ( ApplicationDispatcher . java : 329 )
at com . sun . faces . context . ExternalContextImpl . dispatch ( ExternalContextImpl . java : 408 )
at com . sun . faces . application . ViewHandlerImpl . executePageToBuildView ( ViewHandlerImpl . java : 439 )
at com . sun . faces . application . ViewHandlerImpl . renderView ( ViewHandlerImpl . java : 114 )
at com . sun . faces . lifecycle . RenderResponsePhase . execute ( RenderResponsePhase . java : 106 )
at com . sun . faces . lifecycle . LifecycleImpl . phase ( LifecycleImpl . java : 251 )
at com . sun . faces . lifecycle . LifecycleImpl . render ( LifecycleImpl . java : 144 )
at javax . faces . webapp . FacesServlet . service ( FacesServlet . java : 266 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 304 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 210 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 224 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 169 )
at org . apache . catalina . authenticator . AuthenticatorBase . invoke ( AuthenticatorBase . java : 472 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 168 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 100 )
at org . apache . catalina . valves . AccessLogValve . invoke ( AccessLogValve . java : 929 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 118 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 405 )
at org . apache . coyote . http11 . AbstractHttp11Processor . process ( AbstractHttp11Processor . java : 964 )
at org . apache . coyote . AbstractProtocol$AbstractConnectionHandler . process ( AbstractProtocol . java : 515 )
at org . apache . tomcat . util . net . JIoEndpoint$SocketProcessor . run ( JIoEndpoint . java : 304 )
at java . util . concurrent . ThreadPoolExecutor$Worker . runTask ( Unknown Source )
at java . util . concurrent . ThreadPoolExecutor$Worker . run ( Unknown Source )
at java . lang . Thread . run ( Unknown Source )
Vivis.sf 10 de nov. de 2011
Arrumei e coloquei o seguinte código:
& lt ; h : dataTable value = "#{buscaPorTipoMaisVotado.listaProdutos}"
var = "movel" border = "1" & gt ;
& lt ; h : column & gt ;
& lt ; h : commandLink value = "Imgagem #{movel.idProduto}" action = "#{mostrarMovel.mostrarMovel}" & gt ;
& lt ; f : setPropertyActionListener
target = "#{mostrarMovel.idProduto}" value = "#{movel}" /& gt ;
& lt ; / h : commandLink & gt ;
& lt ; / h : column & gt ;
& lt ; / h : dataTable & gt ;
mas ele simplesmente não faz nada, o que estou fazendo de errado?