/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tk.vovanok.beans;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.faces.bean.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import tk.vovanok.data.Comment;
/**
*
* @author vovan_000
*/
@Named
@ApplicationScoped
public class CommentsBean {
@Inject
LoginBean loginBean;
private List<Comment> allComments;
private String text;
@PostConstruct
public void init(){
allComments = new ArrayList<>();
}
public void addComment(){
Comment c = new Comment();
c.setText(getText());
c.setDate(new Date());
c.setName(loginBean.getLogin());
System.out.println("TEXT: "+text);
getAllComments().add(c);
}
/**
* @return the allComments
*/
public List<Comment> getAllComments() {
return allComments;
}
/**
* @param allComments the allComments to set
*/
public void setAllComments(List<Comment> allComments) {
this.allComments = allComments;
}
/**
* @return the text
*/
public String getText() {
return text;
}
/**
* @param text the text to set
*/
public void setText(String text) {
this.text = text;
}
}