-
1. Re: Understanding @Conversational
mirko27 May 23, 2006 6:07 AM (in response to mirko27)Any ideas? Why does it report but does not take action
-
2. Re: Understanding @Conversational
elgamal May 23, 2006 6:51 AM (in response to mirko27)You should at least post the necessary code parts so we know what you are actually doing.
-
3. Re: Understanding @Conversational
mirko27 May 23, 2006 6:55 AM (in response to mirko27)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>
-
4. Re: Understanding @Conversational
ido_tamir May 23, 2006 8:32 AM (in response to mirko27)And you do have a navigation rule defined for categorys?
best wishes
ido -
5. Re: Understanding @Conversational
mirko27 May 23, 2006 8:36 AM (in response to mirko27)Yes I do, in faces-config like this:
<navigation-case>
<from-outcome>categorys</from-outcome>
<to-view-id>/haldus/categorys.xhtml</to-view-id>
</navigation-case> -
6. Re: Understanding @Conversational
norman.richards May 23, 2006 11:37 AM (in response to mirko27)@Conversational only works when your methods return a String result. I don't know if that is the intended functionality or if it is just a bug we haven't gotten around to fixing yet. In the meantime, change loadData to return a String (just return a null value) and your example will work.
-
7. Re: Understanding @Conversational
gavin.king May 23, 2006 11:50 AM (in response to mirko27)@Conversational works by having an interceptor munge the outcome, so it can only work for a String-valued action method.
Unfortunately JSF does not give me quite enough control during the INVOKE_APPLICATION phase. -
8. Re: Understanding @Conversational
mirko27 May 23, 2006 12:25 PM (in response to mirko27)Yeah, I already show it from Seam code. It just so irrlogical. If I`m always like returning null... OKay, thanks for reply anyway:)