[jboss-user] [JBoss Seam] - Re: Stateless Injection

ovidiucn do-not-reply at jboss.com
Thu Jul 27 03:56:34 EDT 2006


Ok... I think i forgot something. I'm using also facelets and i have also overriden the default suffix property in web.xml file; that is:

  | 	<context-param>
  | 		<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
  | 		<param-value>.xhtml</param-value>
  | 	</context-param>
  | 
so calling for *.xhtml files works.

The part in which i'm calling the local interface looks like this:

  | @Name("userCBTModel")
  | @Scope(ScopeType.SESSION)
  | public class UserCBTModel implements CBTModel {
  | 	
  |     @In(value = "userManagement", create = true, required = true)
  |     private UserManagementLocal userManagement;
  | 
  |     public CBTPage getPage(CBTPageInfo pInfo) {
  |     	PageImpl page = new PageImpl();
  |         PageInfoImpl pInfoImpl = (PageInfoImpl) pInfo;
  |         int startIndex = pInfoImpl.getPageNumber() * pInfoImpl.getDefaultPageSize();
  |         int count = pInfoImpl.getDefaultPageSize();
  |     	
  |         boolean useFilter = ((pInfo == null) ? false
  |                 : ((pInfo.getFilter() == null) ? false : true));
  |     	
  |         List<SSUser> users = new ArrayList<SSUser> ();
  |         try {
  |         	users.addAll(userManagement.getUsers());
  |         } catch (NullPointerException npe) {
  |             logger.error("Userul logat nu are rol pentru a vedea userii:");
  |             users.clear();
  |         }
  | 
  |         /* prepare a new page */
  |      
  |         return page;
  |     }
  | }
  | 

And the presentation markup is as follows:

  | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  | <html xmlns="http://www.w3.org/1999/xhtml"
  | 	xmlns:ui="http://java.sun.com/jsf/facelets"
  | 	xmlns:h="http://java.sun.com/jsf/html"
  | 	xmlns:f="http://java.sun.com/jsf/core">
  | <head>
  | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  | <link rel="stylesheet" type="text/css" href="css/style.css" />
  | <title>Checkbox table template</title>
  | </head>
  | <body>
  | 
  | <ui:composition>
  | <f:view>
  | <h:form id="dataForm" rendered="#{userCBTModel.page.size != 0}">
  |    <h:dataTable id="items" value="#{userCBTModel.page.items}" var="item"
  | 	rowClasses="list-row-odd, list-row-even" styleClass="tData" columnClasses="tData" rows="#{cbtBean.page.size}">
  | 
  | 	<ui:insert name="tColumns">Table columns</ui:insert>
  | 
  |    </h:dataTable>
  | </h:form>
  | </f:view>
  | </ui:composition>
  | </body>
  | </html>
  | 

The overall behaviour can be described as:
* the userManagement component (either is a stateless bean or just a pojo) it gets injected into userCBTModel bean - always;
* if the userManagement component is a stateless bean, its attributes  are not injected;
* if the userManagement component is not a stateless bean (i.e. done by just removing the @Stateless annotation) works fine - all its attributes are injected; if i'm removing the stateless annotation it is treated as a simple java bean and its scope is EVENT.

Thank you.

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

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



More information about the jboss-user mailing list