Problem calling SFSB
diablo341 Nov 16, 2006 11:23 AMI'm stuck and need help. I've got a simple page that has a panelGrid backed by an entity bean. When the page first loads, i'm assuming the entity bean is created (in the request context) and the default values are displayed. I have a commandButton that calls a method on my SFSB to retrieve a particular entity. The entity is annotated with @Out, but my page reloads with the same default values. How do I know the SFSB is even being called? I see that it's loaded during startup via the deployment scanner. I've been banging my head since last night.
Entity bean:
package com.myco.workforce;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import org.jboss.seam.annotations.Name;
@Entity
@Name("revModel")
@Table(name="RevenuePlanningModel", uniqueConstraints = {@UniqueConstraint(columnNames={"profitCenterId","startingQuarter","startingYear"})})
public class RevenuePlanningModel implements Serializable {
private long id;
private long sapProfilingId;
private Date lastModified;
private String profitCenterId;
private short startingQuarter;
private short startingYear;
private long plannedPersonnelPriorYear = 41560l;
private long plannedPersonnel1 = 10000l;
private long plannedPersonnel2;
private long plannedPersonnel3;
private long plannedPersonnel4;
private long plannedPersonnel5;
private long plannedPersonnel6;
private double revenuePriorYear = 12158412;
private double revenue1;
private double revenue2;
private double revenue3;
private double revenue4;
private double revenue5;
private double revenue6;SFSB:
package com.myco.workforce;
import static javax.persistence.PersistenceContextType.EXTENDED;
import javax.ejb.Remove;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.Destroy;
import org.jboss.seam.annotations.End;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.core.Events;
import org.jboss.seam.core.FacesMessages;
import org.jboss.seam.log.Log;
@Stateful
@Name("revPlan")
//@LoggedIn
public class RevenuePlanningAction implements RevenuePlanning {
@PersistenceContext(type=EXTENDED)
private EntityManager em;
/*
@In
private User user;
*/
@In(required=false) @Out
private RevenuePlanningModel revModel;
@In(create=true)
private FacesMessages facesMessages;
@In(create=true)
private Events events;
@Logger
private Log log;
@Begin
public void getRevenuePlanningModel() {
revModel = (RevenuePlanningModel) em.createQuery(
"select r from revenueplanningmodel r where r.id=:id")
.setParameter("id", 1)
.getSingleResult();
//revModel = em.find(RevenuePlanningModel.class, 1);
}
@End
public String saveRevenuePlanningModel() {
em.persist(revModel);
}
@End
public String deleteRevenuePlanningModel() {
return null;
}
@End
public String cancel() {
return null;
}xhtml page:
<div class="section">
<h:form>
<h:panelGrid columns="9">
<h:outputLabel styleClass="entry">
<h:outputText value=""/>
</h:outputLabel>
<h:outputLabel styleClass="entry">
<h:outputText value="PY"/>
</h:outputLabel>
<h:outputLabel styleClass="entry">
<h:outputText value="Q1"/>
</h:outputLabel>
<h:outputLabel styleClass="entry">
<h:outputText value="Q2"/>
</h:outputLabel>
<h:outputText value="Planned Personnel"/>
<h:outputText value="#{revModel.plannedPersonnelPriorYear}">
<f:convertNumber pattern="#,###,##0"/>
</h:outputText>
<h:inputText id="plannedPersonnel1" value="#{revModel.plannedPersonnel1}" required="true">
<f:convertNumber pattern="#,###,##0"/>
</h:inputText>
<h:inputText id="plannedPersonnel2" value="#{revModel.plannedPersonnel2}" required="true">
<f:convertNumber pattern="#,###,##0"/>
</h:inputText>
<h:outputText value="Revenue"/>
<h:inputText id="revenuePriorYear" value="#{revModel.revenuePriorYear}" required="true">
<f:convertNumber pattern="#,###,##0"/>
</h:inputText>
<h:inputText id="revenue1" value="#{revModel.revenue1}" required="true">
<f:convertNumber pattern="#,###,##0"/>
</h:inputText>
<h:inputText id="revenue2" value="#{revModel.revenue2}" required="true">
<f:convertNumber pattern="#,###,##0"/>
</h:inputText>
</h:panelGrid>
<div class="entry errors">
<h:messages globalOnly="true"/>
</div>
<div class="input">
<h:commandButton value="Proceed" action="#{revPlan.getRevenuePlanningModel}" class="button"/>
<h:commandButton value="Save" action="#{revPlan.saveRevenuePlanningModel}" class="button"/>
</div>
</h:form>
</div>Note, I'm working off of the Booking app example, so my setup is sound and I'm using a lot of existing framework.
I appreciate the help.
John