[jboss-user] [JBoss Seam] - Re: @Factory is not working
maykellff
do-not-reply at jboss.com
Tue Nov 20 09:40:06 EST 2007
Hi all
anonymous wrote :
| Make sure you have a seam.properties file in your classes directory.
| Are all other SEAM operations working?
|
Yes, seam.properties is rigth and other Seam stuff work well, i'm sure of this.
anonymous wrote :
| @Factory will be called when you call it from a page (or wherever) and Seam will place the value into the context variable so that it isn't called again for the life of the context.
|
This is exactly my idea, that's whay i don't understand whay my code is not executing the @Factory annotated method.
this is the jsf page that is calling a variable which is refrenced by the @Factory, the variable is "tipoAcusadoList":
anonymous wrote :
| <f:subview id="kk" >
| <h:form id="turnarExpForm">
| <h:outputLabel value="Esta es la pagina de Registro" />
| <h:panelGrid columns="2" border="2" >
| <h:outputLabel value="Número de Expediente"/>
| <h:inputText value="#{expediente.nroExpediente}" id="lblNroExpediente"/>
| <h:outputLabel value="Tipo de acusado"/>
| <h:selectOneMenu value="#{expedienteFacadeStateless.tipoAcusadoSelected}">
| <f:selectItems value="#{expedienteFacadeStateless.tipoAcusadoList}"/>
| </h:selectOneMenu>
| <h:outputLabel value="Fecha de turnado" rendered=""/>
| <h:inputText value="#{expediente.fechaTurnado}" id="lblFechaTurnado" rendered=""/>
| </h:panelGrid>
|
| <a4j:commandButton action="#{expedienteFacadeStateless.turnarExpediente}" value="Ir a ...." />
| </h:form>
| </f:subview>
|
This is my stateless session bean:
anonymous wrote :
| package com.facade.impl;
|
| import java.util.List;
|
| import javax.ejb.Stateless;
| import javax.faces.model.SelectItem;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
| import javax.persistence.Query;
|
| import org.jboss.seam.annotations.Factory;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Out;
| import org.jboss.seam.core.PersistenceContexts;
|
| import com.domain.Expediente;
| import com.domain.nomenclador.NTipoAcusado;
| import com.facade.ExpedienteFacadeStateless;
|
| @Stateless
| @Name("expedienteFacadeStateless")
| public class ExpedienteFacadeStatelessImpl implements ExpedienteFacadeStateless {
|
| @In @Out
| private Expediente expediente;
|
| @PersistenceContext
| private EntityManager em;
|
|
| private SelectItem[] tipoAcusadoList;
|
| private NTipoAcusado tipoAcusadoSelected;
|
|
| @Factory("tipoAcusadoList")
| public void loadTipoAcusadoList()
| {
| Query query = em.createQuery("Select f from NTipoAcusado f");
| List tempList = query.getResultList();
| int size = tempList.size();
| tipoAcusadoList = new SelectItem[size];
| for (int i=0;i<size;i++)
| tipoAcusadoList = new SelectItem(tempList.get(i),tempList.get(i).getValor());
| }
|
| public EntityManager getEm() {
| return em;
| }
|
| public void setEm(EntityManager em) {
| this.em = em;
| }
|
| public Expediente getExpediente() {
| return expediente;
| }
|
| public void setExpediente(Expediente expediente) {
| this.expediente = expediente;
| }
|
| public String turnarExpediente(Expediente Exp) {
| // TODO Auto-generated method stub
| return null;
| }
|
| public SelectItem[] getTipoAcusadoList() {
| return tipoAcusadoList;
| }
|
| public void setTipoAcusadoList(SelectItem[] tipoAcusadoList) {
| this.tipoAcusadoList = tipoAcusadoList;
| }
|
| public NTipoAcusado getTipoAcusadoSelected() {
| return tipoAcusadoSelected;
| }
|
| public void setTipoAcusadoSelected(NTipoAcusado tipoAcusadoSelected) {
| this.tipoAcusadoSelected = tipoAcusadoSelected;
| }
|
| }
|
|
and this is the interface:
anonymous wrote :
| package com.facade;
|
| import javax.faces.model.SelectItem;
|
| import com.domain.Expediente;
| import com.domain.nomenclador.NTipoAcusado;
|
| public interface ExpedienteFacadeStateless {
|
| public String turnarExpediente(Expediente Exp);
| public SelectItem[] getTipoAcusadoList();
| public NTipoAcusado getTipoAcusadoSelected();
| public void loadTipoAcusadoList();
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4106399#4106399
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4106399
More information about the jboss-user
mailing list