I am really stuck on this issue - maybe I am doing something wrong in the bean?

Greatful for any feedback:

  | @Stateful
  | @Scope(CONVERSATION)
  | @Name("userSpaces")
  | @TransactionAttribute(REQUIRED)
  | public class UserSpacesAction implements UserSpacesLocal, Serializable
  | {
  | 
  |     private static final long serialVersionUID = -3722438832731142648L;
  | 
  |     @PersistenceContext
  |     private EntityManager em;
  | 
  |     @In("currentUser")
  |     private User m_currentUser;
  | 
  |     private String m_spaceInput;
  | 
  |     @SuppressWarnings("unused")
  |     @DataModel("availableSpaces")
  |     private List<PublishingSpace> m_availableSpaces;
  | 
  |     @SuppressWarnings("unused")
  |     @DataModelSelection
  |     @Out(required = false)
  |     private PublishingSpace selectedSpace;
  | 
  |     @Logger
  |     private Log log;
  | 
  |     @SuppressWarnings("unchecked")
  |     @Factory("availableSpaces")
  |     public void getAvailableSpaces()
  |     {
  |             log.debug("Get User space for user #0", 
m_currentUser.getLogin());
  | 
  |             m_availableSpaces = em.createQuery(
  |                             "SELECT DISTINCT s.publishingSpace FROM 
SpaceAccess s WHERE s.theUser = :user").setParameter("user",
  |                             m_currentUser).getResultList();
  |             
  |             log.debug("Got a List back  empty=#0", 
Boolean.valueOf(m_availableSpaces.isEmpty()));
  |     }
  | 
  |     public String addSpace()
  |     {
  |             // create the full "public.xxx" name and check that it is a
  |             // valid space name
  |             //
  |             String tmpSpace = "public."+m_spaceInput;
  |             if(!SpaceNameValidator.isSpaceNameValid(tmpSpace))
  |             {
  |                     FacesMessages.instance().add("spaceInput", "Invalid 
space name");
  |                     return "error-space-add-invalid-name";
  |             }
  |             // Check if space exists
  |             //
  |             if(PublishingSpace.exists(em, tmpSpace))
  |             {
  |                     FacesMessages.instance().add("spaceInput", "Space name 
already taken - use something else.");
  |                     return "error-space-add-exists";
  |             }
  |                             
  |             // Add objects
  |             //
  |             log.debug("Adding space for public.#0", m_spaceInput);
  |             PublishingSpace p = new PublishingSpace("public."+m_spaceInput);
  |             p.setDateAdded(new Date());
  |             SpaceAccess sa = new SpaceAccess(m_currentUser,p, Boolean.TRUE);
  |             em.persist(p);
  |             em.persist(sa);
  |             log.info("Added space #0 for user #1", p.getSpaceName(), 
m_currentUser.getLogin());
  |             getAvailableSpaces();
  |             // Clear this value for new input
  |             m_spaceInput = "";
  |             return "ok-space-saved";
  |     }
  | 
  |     public void setSpaceInput(String space)
  |     {
  |             m_spaceInput = space;
  |     }
  | 
  |     public String getSpaceInput()
  |     {
  |             return m_spaceInput;
  |     }
  | 
  |     @Destroy
  |     @Remove
  |     public void destroy()
  |     {
  |     }
  | }
  | 

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

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

Reply via email to