"sbryzak2" wrote : Injection should work just fine.  Can you post a code sample?

Here is the Session Bean


  | package org.seam.ejemplo.login.session;
  | 
  | import java.util.List;
  | 
  | import javax.ejb.Stateless;
  | import javax.persistence.EntityManager;
  | import javax.persistence.PersistenceContext;
  | 
  | import org.jboss.seam.annotations.In;
  | import org.jboss.seam.annotations.Logger;
  | import org.jboss.seam.annotations.Name;
  | import org.jboss.seam.core.FacesMessages;
  | import org.jboss.seam.log.Log;
  | import org.seam.ejemplo.login.beans.Cliente;
  | 
  | /**
  |  * @author gllambi
  |  * 
  |  */
  | @Stateless
  | @Name("login")
  | public class LoginAction implements Login {
  | 
  |     @In
  |     private Cliente cliente;
  | 
  |     @PersistenceContext
  |     private EntityManager em;
  | 
  |     @Logger
  |     private Log log;
  | 
  |     public String login() {
  |             List existing = em.createQuery(
  |                             "select usuario from Cliente where 
usuario=:usuarioParam")
  |                             .setParameter("usuarioParam", 
cliente.getUsuario())
  |                             .getResultList();
  |             if (!existing.isEmpty()) {
  |                     log.info("Se logueo el client #{cliente.usuario}");
  |                     return "exito";
  |             } else {
  |                     log.info("No existe el cliente");
  |                     FacesMessages.instance().add("El cliente 
#{cliente.usuario} no fue registrado. Regístrese");
  |                     return null;
  |             }
  |     }
  | }
  | 

Here is the interface


  | package org.seam.ejemplo.login.session;
  | 
  | import javax.ejb.Local;
  | 
  | import org.jboss.seam.annotations.WebRemote;
  | 
  | /**
  |  * @author gllambi
  |  *
  |  */
  | @Local
  | public interface Login {
  | 
  |     
  |     /**
  |      * Se valida el cliente y su contraseña
  |      * @return
  |      */
  |     @WebRemote
  |     public String login();
  | 
  | }
  | 

Here is the page

  | <%@ taglib uri="http://java.sun.com/jsf/html"; prefix="h"%>
  | <%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f"%>
  | <%@ taglib uri="https://ajax4jsf.dev.java.net/ajax"; prefix="a4j"%>
  | 
  | <html>
  | <head>
  | <link href="<%=request.getContextPath()%>/estilos/estilo.css"
  |     rel="stylesheet" type="text/css">
  | <f:loadBundle basename="mensajes" var="msg" />
  | <title>Login</title>
  | <script type="text/javascript"
  |     src="<%=request.getContextPath()%>/seam/remoting/resource/remote.js">
  | <!--
  | // This space intentionally left blank
  | //-->
  | </script>
  | <script type="text/javascript"
  |     src="<%=request.getContextPath()%>/seam/remoting/interface.js?login"> 
  | <!--
  | // This space intentionally left blank
  | //-->
  | </script>
  | <script type="text/javascript"> 
  |     //<![CDATA[
  |     function login() {
  |             Seam.Component.getInstance("login").login(loginCallback);
  |     }
  |     function loginCallback(result) {
  |             alert('El resultado de la operación es '+result);
  |     }
  |     // ]]>
  | </script>
  | </head>
  | <body>
  | <center><f:view>
  |             <h:form id="loginForm">
  |                     <h:messages styleClass="error" id="mensajesError" />
  |                     <h:panelGrid columns="2">
  |                             <h:outputText id="etiquetaUsuario" 
value="#{msg.user}" />
  |                             <h:inputText id="usuario" 
value="#{cliente.usuario}" />
  |                             <h:outputText id="etiquetaPassword" 
value="#{msg.password}" />
  |                             <h:inputText id="password" 
value="#{cliente.password}" />
  |                     </h:panelGrid>
  |                     <h:commandButton onclick="javascript:login()"
  |                             value="Remoting #{msg.login} Button" />
  |                             <a4j:commandButton action="#{login.login}"
  |                             value="Ajax #{msg.login} Button">               
                        
  |                             </a4j:commandButton>
  |                     <h:commandButton action="#{login.login}"
  |                             value="Seam #{msg.login} Button" />
  |             </h:form>
  | </f:view></center>
  | </body>
  | </html>
  | 

And here is the web.xml


  | <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee";
  |     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  |     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";>
  |     <display-name>Login</display-name>
  |     <context-param>
  |             <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
  |             <param-value>client</param-value>
  |     </context-param>
  |     <context-param>
  |             <description>
  |                     This parameter tells MyFaces if javascript code should 
be
  |                     allowed in the rendered HTML output. If javascript is
  |                     allowed, command_link anchors will have javascript code 
that
  |                     submits the corresponding form. If javascript is not
  |                     allowed, the state saving info and nested parameters 
will be
  |                     added as url parameters. Default: "true"
  |             </description>
  |             <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
  |             <param-value>true</param-value>
  |     </context-param>
  |     <context-param>
  |             <description>
  |                     This parameter tells MyFaces if javascript code should 
be
  |                     allowed in the rendered HTML output. If javascript is
  |                     allowed, command_link anchors will have javascript code 
that
  |                     submits the corresponding form. If javascript is not
  |                     allowed, the state saving info and nested parameters 
will be
  |                     added as url parameters. Default: "false"
  | 
  |                     Setting this param to true should be combined with
  |                     STATE_SAVING_METHOD "server" for best results.
  | 
  |                     This is an EXPERIMENTAL feature. You also have to 
enable the
  |                     detector filter/filter mapping below to get JavaScript
  |                     detection working.
  |             </description>
  |             <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
  |             <param-value>false</param-value>
  |     </context-param>
  |     <context-param>
  |             <description>
  |                     If true, rendered HTML code will be formatted, so that 
it is
  |                     "human readable". i.e. additional line separators and
  |                     whitespace will be written, that do not influence the 
HTML
  |                     code. Default: "true"
  |             </description>
  |             <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
  |             <param-value>true</param-value>
  |     </context-param>
  |     <context-param>
  |             <description>
  |                     If true, a javascript function will be rendered that is 
able
  |                     to restore the former vertical scroll on every request.
  |                     Convenient feature if you have pages with long lists 
and you
  |                     do not want the browser page to always jump to the top 
if
  |                     you trigger a link or button action that stays on the 
same
  |                     page. Default: "false"
  |             </description>
  |             <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
  |             <param-value>true</param-value>
  |     </context-param>
  |     <filter>
  |             <filter-name>Seam Redirect Filter</filter-name>
  |             <filter-class>
  |                     org.jboss.seam.servlet.SeamRedirectFilter
  |             </filter-class>
  |     </filter>
  |     <filter>
  |             <filter-name>extensionsFilter</filter-name>
  |             <filter-class>
  |                     org.apache.myfaces.webapp.filter.ExtensionsFilter
  |             </filter-class>
  |             <init-param>
  |                     <description>
  |                             Set the size limit for uploaded files. Format: 
10 - 10
  |                             bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB
  |                     </description>
  |                     <param-name>uploadMaxFileSize</param-name>
  |                     <param-value>100m</param-value>
  |             </init-param>
  |             <init-param>
  |                     <description>
  |                             Set the threshold size - files below this limit 
are
  |                             stored in memory, files above this limit are 
stored on
  |                             disk.
  | 
  |                             Format: 10 - 10 bytes 10k - 10 KB 10m - 10 MB 
1g - 1 GB
  |                     </description>
  |                     <param-name>uploadThresholdSize</param-name>
  |                     <param-value>100k</param-value>
  |             </init-param>
  |     </filter>
  |     <filter>
  |             <display-name>Ajax4jsf Filter</display-name>
  |             <filter-name>ajax4jsf</filter-name>
  |             <filter-class>org.ajax4jsf.Filter</filter-class>
  |     </filter>
  |     <filter-mapping>
  |             <filter-name>Seam Redirect Filter</filter-name>
  |             <url-pattern>*.seam</url-pattern>
  |     </filter-mapping>
  |     <filter-mapping>
  |             <filter-name>extensionsFilter</filter-name>
  |             <url-pattern>*.seam</url-pattern>
  |     </filter-mapping>
  |     <filter-mapping>
  |             <filter-name>extensionsFilter</filter-name>
  |             <url-pattern>/faces/*</url-pattern>
  |     </filter-mapping>
  |     <filter-mapping>
  |             <filter-name>ajax4jsf</filter-name>
  |             <servlet-name>Faces Servlet</servlet-name>
  |             <dispatcher>REQUEST</dispatcher>
  |             <dispatcher>FORWARD</dispatcher>
  |             <dispatcher>INCLUDE</dispatcher>
  |     </filter-mapping>
  |     <!-- Listener, that does all the startup work (configuration, init). -->
  |     <listener>
  |             <listener-class>
  |                     org.apache.myfaces.webapp.StartupServletContextListener
  |             </listener-class>
  |     </listener>
  |     <listener>
  |             <listener-class>
  |                     org.jboss.seam.servlet.SeamListener
  |             </listener-class>
  |     </listener>
  |     <!-- Faces Servlet -->
  |     <servlet>
  |             <servlet-name>Faces Servlet</servlet-name>
  |             <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  |             <load-on-startup>1</load-on-startup>
  |     </servlet>
  |     <servlet>
  |             <servlet-name>Seam Remoting</servlet-name>
  |             <servlet-class>
  |                     org.jboss.seam.remoting.SeamRemotingServlet
  |             </servlet-class>
  |     </servlet>
  |     <!-- Faces Servlet Mapping -->
  |     <servlet-mapping>
  |             <servlet-name>Faces Servlet</servlet-name>
  |             <url-pattern>*.seam</url-pattern>
  |     </servlet-mapping>
  |     <servlet-mapping>
  |             <servlet-name>Seam Remoting</servlet-name>
  |             <url-pattern>/seam/remoting/*</url-pattern>
  |     </servlet-mapping>
  |     <!-- Welcome files -->
  |     <welcome-file-list>
  |             <welcome-file>index.jsp</welcome-file>
  |     </welcome-file-list>
  |     <login-config>
  |             <auth-method>BASIC</auth-method>
  |     </login-config>
  | </web-app>
  | 

Thanks

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3985548#3985548

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3985548

_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to