I have a Posts model, and each post also contains Blocks (also a model). I use the playback platform for this website, and what I want to do is show the X-number of the message with all its blocks on one page. JPA (or the implementation of the game framework, I donβt know which one) has a find() method with which I could request messages in my controller, and I would send a list of messages to my view as follows:
render(postList);
What I wanted to know is the best way to send blocks for each message to a view. I could add the getBlocks() method to my Post model, which sends a blockList back and calls it from the view, but that seems messy for me, and that will defeat the MVC goal, since the blocks will be selected from the view .. (or I'm wrong about this?)
Is there a JPA or Play! suggest some way to extract blocks along with messages?
This is what my Post model looks like right now, without getters and setters: @Entity
@Table(name="posts") public class Post extends GenericModel{ @Id @Column(name="post_id") private int id; @Column(name="post_situation") private String situation; @Column(name="post_date") private Date date; @Column(name="post_userid") private int userid; private List<Block> blockList; public List<Block> getBlocks() { List<Block> block = null; return blockList; } }
How can I do it?
source share