This is the code>

  | package ee.digizone.ejb;
  | 
  | import java.io.Serializable;
  | import java.util.List;
  | import java.util.Map;
  | import java.util.TreeMap;
  | 
  | import javax.ejb.Remove;
  | import javax.ejb.Stateful;
  | import javax.persistence.EntityManager;
  | 
  | import org.jboss.seam.ScopeType;
  | import org.jboss.seam.annotations.Begin;
  | import org.jboss.seam.annotations.Conversational;
  | import org.jboss.seam.annotations.Create;
  | import org.jboss.seam.annotations.Destroy;
  | import org.jboss.seam.annotations.End;
  | import org.jboss.seam.annotations.In;
  | import org.jboss.seam.annotations.Name;
  | import org.jboss.seam.annotations.Out;
  | import org.jboss.seam.annotations.RequestParameter;
  | import org.jboss.seam.annotations.Scope;
  | 
  | 
  | import ee.digizone.entity.Category;
  | import org.jboss.logging.Logger;
  | 
  | @Stateful
  | @Name("cateditor")
  | @Conversational(ifNotBegunOutcome="categorys")
  | public class CategoryEditorBean implements CategoryEditor,Serializable {
  | 
  |     @In(create=true,value="digizoneDatabase")
  |     EntityManager em;
  | 
  |     @Out(required=false)
  |     @In(required=false)
  |     private Category category;
  |     
  |     Logger logger = Logger.getLogger(CategoryEditorBean.class);
  |     
  |     @RequestParameter
  |     String catid;
  | 
  |     Map<String,Category> categoryMap;       
  |     List<Category>       categories;
  |     
  |     
  |     public void loadData() {
  |             logger.info("Stepped here");
  |             categories = em.createQuery("from Category c")
  |          .setHint("org.hibernate.cacheable", true)
  |          .getResultList();
  |     Map<String,Category> results = new TreeMap<String,Category>();
  |    
  |     for (Category category: categories) {
  |        results.put(category.getName(),category);
  |     }
  |    
  |     categoryMap = results;
  |     }
  |     
  |     public void create() {
  |             em.persist(category);
  |     }
  |     public void save() {
  |             em.refresh(category);
  |     }
  |     @Begin(join=true)
  |     public void selectCreate() {
  |         category = new Category();
  |         
logger.info(em.find(Category.class,Integer.parseInt(catid)).getName());
  |         category.setHead(em.find(Category.class,Integer.parseInt(catid)));
  |         
  |     }
  |     @Begin(join=true)
  |     public void selectModify() {
  |             category = em.find(Category.class,catid);
  |     }
  |     
  |     @End
  |     public String delete() {
  |             category  = em.find(Category.class,catid);
  |             em.remove(category);
  |             return null;
  |     }
  | 
  |     public Map<String,Category> getCategories() {
  |         return categoryMap;
  |     }
  |     public Category getCategory() {
  |             return this.category;
  |     }
  |     
  |     @Destroy @Remove
  |     public void destroy() {}
  | }
  | 
  | 
  | <pages>
  |     <page view-id="/haldus/cuser.xhtml" action="#{conversation.begin}"/>
  |     <page view-id="/haldus/ccategory.xhtml" action="#{cateditor.loadData}"/>
  | </pages>
  | 

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

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


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to