8 Replies Latest reply on May 23, 2006 12:25 PM by mirko27

    Understanding @Conversational

    mirko27

      I have not started conversation and in that case I would like that user would be redirected. I`m using this @Conversational. I put call to my bean in pages.xhtml and it gets called. When user hits the page I get following infO:
      01:35:47,481 INFO [ConversationInterceptor] no long-running conversation for @Conversational bean: cateditor
      But do not get redirected, how come?

        • 1. Re: Understanding @Conversational
          mirko27

          Any ideas? Why does it report but does not take action

          • 2. Re: Understanding @Conversational
            elgamal

            You should at least post the necessary code parts so we know what you are actually doing.

            • 3. Re: Understanding @Conversational
              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

                And you do have a navigation rule defined for categorys?

                best wishes
                ido

                • 5. Re: Understanding @Conversational
                  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

                    @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

                      @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

                        Yeah, I already show it from Seam code. It just so irrlogical. If I`m always like returning null... OKay, thanks for reply anyway:)