I am developing an application with JSF and EJB 3.0.
Now I have got a question where I should  implement methods that manipulate my 
objects.

Example1: The EJB SessioBean only implements methods to get data from the 
database and to persist or merge objects:

EJB SessionBean courseHandler
public void createCourse(Course course){
  |             em.persist(course);
  | }

The managedBean courseBean manipulates the object:
managedBean JSF courseBean 


  | public void joinCourse(){
  |             currentUser = 
userHandler.getCmtUserByUserName(getRemoteUserName());
  |             currentCourse.getParticipants().add(currentUser);
  |             currentUser.getCourses().add(currentCourse);
  |             courseHandler.updateCourse(currentCourse);
  |             CustomMessage.createMessage("course_joined");
  | }


Or should example 2 be the better version:

The EJB SessionBean courseHandler manipulates the object and persists/merges it:

public void joinCourse(CmtUser user, Course course){
  |     course.getParticipants().add(user);
  |     user.getCourses().add(course);
  |         em.merge(course);
  | }

managedBean JSF courseBean

public void joinCourse(){
  |             currentUser = 
userHandler.getCmtUserByUserName(getRemoteUserName());
  | courseHandler.joinCourse(currentUser,currentCourse)
  |             CustomMessage.createMessage("course_joined");
  | }

Thank you for your answers!
NSchweig





View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4220512#4220512

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4220512
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to