Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Java EE (J2EE) и Spring > проблема с полем в SF SB


Автор: surly 17.10.2010, 16:30
Добрый день.
есть stateful bean.
Код

@Name("myStatefulBean")
@Stateful
@Interceptors(SeamInterceptor.class)
public class stSB implements stSBRemote, stSBLocal {
    @PersistenceContext
    private Session sessionH;
    @In(create=true)    @Out
    private cartElement cartEl;
    private List<Long> cart;
    
    
    public stSB() {
      cart = new ArrayList<Long>();
    }
    public void addItem()
    {
        try
        {
            sessionH.beginTransaction();
            sessionH.save(cartEl);
            sessionH.getTransaction().commit();
        }
        catch (HibernateException e) {
            sessionH.getTransaction().commit();
            System.out.println("saveItem exception");
        }
    }
    
    
    
    // getters - setters, @destroy @remove methods, other methods
}


cartElement
Код

@Entity
@Table(name="CARTELEMENTS")
@Name("cartEl")
public class cartElement implements Serializable{
    private Double price;
    private String name;
    private Date date;
    private Long pid;
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;
    public cartElement(){
        
    }
    public cartElement(Double price, String name, Date date){
        this.price = price;
        this.name = name;
        this.date = date;
    }
    @PostConstruct
    public void init()
    {
        System.out.println("cartElement INIT()");
    }
//getters setters
}


home.xhtml
Код

.....
                <h:panelGrid columns="2" rowClasses="prop" columnClasses="name,value">
                    <h:outputLabel for="name">Name</h:outputLabel>
                    <h:inputText id="name" value="#{cartEl.name}"/>
                 
                    <h:outputLabel for="date">Date</h:outputLabel>
                    <rich:calendar value="#{cartEl.date}"/>
                        
                    <h:outputLabel for="pid">PID</h:outputLabel>
                    <h:inputText id="pid" value="#{cartEl.pid}">
                     <f:validator validatorId="pidValidator"/>
                     <f:converter converterId="strToLongConverter"/>
                    </h:inputText>
                    
                    <h:outputLabel for="price">Price</h:outputLabel>
                    <h:inputText id="price" value="#{cartEl.price}">
        <f:converter converterId="strToDoubleConverter"/>
                    </h:inputText>
    
                </h:panelGrid>
      
            <h:commandButton id="submit" value="Add record" action="#{myStatefulBean.addItem()}"/>




вобщем, проблема - при выполнении метода addItem() стейтфул бина вознкает ошибка...дело в том, что ПОЧЕМУ-ТО не устанавливаются значения поля    @In(create=true)    @Out private cartElement cartEl;, хотя в дебаге в сеттеры заходит, и значения устанавлимваются, а при выполнении метода - все поля почему-то NULL.

Собственно, прошу помоч решить эту проблему.

Использую Seam framework 2.2.0, jBoss 5.1 AS.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)