[jboss-user] [JBoss Seam] - Re: Conceptual/Best Practice Question

tony.herstell@gmail.com do-not-reply at jboss.com
Tue Mar 27 18:35:25 EDT 2007

I also have a stateful page view that displays a list of xxxx as a @DataModel.

I also have conversations external to the page that manipulate entries int he model.

I call back from the conversations... and manipulate the mode.

In my code that requires to manipulate the model Inject it.

  |     /**
  |      * Biject the Find Users Controller which has to refine its list of Users 
  |      * When we update the Users then we have to laise with the FindUsersController to refine its list of users.
  |      */
  |     @In(create=true)
  |     private FindUserController findUserController;

then call back to it

  |     @End
  |     @TransactionAttribute(TransactionAttributeType.REQUIRED)
  |     public String create() {
  |         log.info("> create");
  |         user.getDates().setCreationDate(new Date());
  |         user.setPassword(encryptionController.encrypt(user.getPassword()));
  |         em.persist(user);
  |         em.flush();
  |         facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO, "user_create_successful");
  |         /*
  |          * We need to add this user to the list of users in the session scoped FindUserController
  |          */
  |         if (findUserController != null) {
  |             findUserController.addUserToExistingList(user);
  |         }
  |         log.info("< create");
  |         return "success";
  |     }

In my model, it doesn't have to re-read anything from the database.

I found this useful as I had problems managing to get my stateful model to "re-read" from the database as it only kept reading from the cache! and I didn't know how to invalidate the cache.

It did save any reads from the database.

However, I am sure Gavins way is better.

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

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4032237

More information about the jboss-user mailing list