openwebbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Struberg <strub...@yahoo.de>
Subject Re: Servlet 3.0 not injeting bean
Date Sat, 14 Jun 2014 10:48:31 GMT
it should if you use our openwebbeans-tomcat7 module.
Or if you use Apache TomEE which comes pre-packaged and perfectly setup with OpenWebBeans
as CDI container. In this case you can also leverage multiple other cool EE features like
JTA, etc. This is kind of a perfectly integrated setup of MyFaces and OpenWebBeans into tomcat7. 
It comes with OpenJPA as well in case you need JPA. Of course you can optionally also use
Hibernate and EclipseLink with TomEE as well.

Might be easier for you than to setup all our internal container modules yourself. Of course
you are welcome to do so and report back if you need more help.

LieGrue,
strub


On Saturday, 14 June 2014, 4:49, Felipe Pina <fop.net@gmail.com> wrote:
 

>
>
>Why cdi OWB injection do not works only by servlet url ?
>
>
>
>
>My java beans below.
>
>
>
>
>@WebServlet( urlPatterns = {"/tarifas"})
>public class Tarifas extends HttpServlet {
>/**
> *  Atributo '<code>serialVersionUID</code>' do tipo long
> */
>private static final long serialVersionUID = 1L;
>
>
>@javax.inject.Inject 
>private TarifaBean tarifaBean;  -> This injection do not works, when access by servlet
url tarifas
>
>
>@Override
>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
>try {
>            
>tarifaBean.setSession(request.getSession());
>request.setAttribute("valorTarifa", tarifaBean.getValorUnitario());
>getServletContext().getRequestDispatcher("/WEB-INF/pages/tarifas.jsp").forward(request,
response);
>} catch (GrowUpException e) {
>throw new ServletException(e);
>//getServletContext().getRequestDispatcher("error.jsp").forward(request, response);
>}
>}
>
>
>}
>
>
>
>
>
>
>----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
>@javax.inject.Named(value="tarifaBean")
>@javax.enterprise.context.SessionScoped
>public class TarifaBean implements Serializable {
>/**
> *  Atributo '<code>serialVersionUID</code>' do tipo long
> */
>private static final long serialVersionUID = 1L;
>
>
>@javax.inject.Inject
>
>private GrowUpFacadeAdapter facade;  -> This injection works fine, when access by
jsf page.
>private Double valorUnitario;
>
>
>public TarifaBean() {}
>
>
>/**
> * @return the valorUnitario
> * @throws GrowUpException 
> */
>public Double getValorUnitario() throws Exception {
>if (valorUnitario==null)
>valorUnitario = buscarValorPedido();
>return valorUnitario;
>}
>
>
>/**
> * @return
> */
>
>private Double buscarValorPedido() throws Exception {
>VariavelDTO var = (VariavelDTO) facade.executarComando(session, 
>GCS.MAPA_VARIAVEL, 
>GCS.BUSCAR_VALOR_UNITARIO);
>if (!isCodigoValido(var))
>throw new IllegalArgumentException("Não foi possível encontrar o valor Unitário do
pedido."); 
>return var.getValorAsDouble();
>}
>
>
>}
>
>
>
>
>
>
>
>-- 
>Atenciosamente,
>Felipe Pina
>
>
>
Mime
View raw message