Package org.openblend.fejstbuk.ui

Source Code of org.openblend.fejstbuk.ui.NewPostAction

package org.openblend.fejstbuk.ui;

import java.util.Date;
import javax.ejb.Stateful;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.openblend.fejstbuk.domain.Status;
import org.openblend.fejstbuk.domain.User;
import org.openblend.fejstbuk.qualifiers.Current;
import org.openblend.fejstbuk.qualifiers.LoggedIn;

/**
* @author <a href="mailto:tomaz.cerar@redhat.com">Tomaz Cerar</a>
*/
@RequestScoped
@Named
@Stateful
public class NewPostAction {
    @PersistenceContext
    EntityManager em;


    @LoggedIn
    @Current
    @Inject
    private User user;

    private String text;

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public void post() {
        Status s = new Status();
        s.setTimestamp(new Date());
        s.setStatus(text);
        s.setUser(em.find(User.class, user.getId()));
        em.persist(s);
    }
}
TOP

Related Classes of org.openblend.fejstbuk.ui.NewPostAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.