6 Replies Latest reply on Aug 17, 2006 4:20 PM by bfo81

    Design Question and Seam/JSF question

      I'm still working on my extension of the Seam CRUD app. I've been able to do everything I needed to so far, but have ran into a snag. My immediate question is how can you see the JSF outcome after hitting a button on a page? I think I know what it is, because of where the page flow goes, but it's not what I expected. I have it in debug, and the first time i hit that button it stops at my breakpoint, I can see what happens, and it proceeds normally. When i navigate back to this page by way of a button on the new page, then hit that same button, it skips my breakpoint that is in that action method for that button and goes to an unexpected page - I can't find what it's doing!

      The design question I have is this - my CRUD app is for 3 tables, table A is the parent, B is the child of A, and C is the child of B. I was playing with this to see how I could pass the key fields from A to B, and from B to C, so the user doesn't have to remember them. Right now when the user is on an A record, and clicks to create a B, i put an the instance of A as a conversation context variable. It does work, but I have a feeling this isn't the best way of doing things..? Maybe abusing biijection is causing some weird behavior?

      Thanks a bunch...

        • 1. Re: Design Question and Seam/JSF question

          Something else I just noticed, on the request that seems to go to the wrong page, the following line gets printed to the console:

          "[HtmlRendererUtils] There should always be a submitted value for an input if it is rendered, its form is submitted, and it is not disabled or read-only."

          Not sure if this has anything to do with it or not..

          Here's part of the code for the seam component, the Editor for what would be table B in the hierarchy:

          @Name("eTStatusEditor")
          @Stateful
          @Interceptors(SeamInterceptor.class)
          public class ETStatusEditorBean implements ETStatusEditor {
          
           @In(create = true)
           private EntityManager entityManager;
          
           @Valid
           private ETStatus instance = new ETStatus();
          
           @TransactionAttribute(NOT_SUPPORTED)
           @Out(scope=ScopeType.CONVERSATION, required = false, value="parentEtStatus")
           public ETStatus getInstance() {
          
           initStatus();
           return instance;
           }
          
           @TransactionAttribute(NOT_SUPPORTED)
           @Begin(join=true)
           private void initStatus() {
           if (parentEtMaster != null) {
           instance.getId().setPartkey(parentEtMaster.getPartkey());
           isChild = true;
           }
           else {
           isChild = false;
           }
           }
          
           public void setInstance(ETStatus instance) {
           this.instance = instance;
          
           }
          
           @Out(required = false, scope=ScopeType.CONVERSATION)
           @In(required = false, value="parentEtMaster", scope=ScopeType.CONVERSATION)
           private ETMaster parentEtMaster;
          
           @TransactionAttribute(NOT_SUPPORTED)
           public ETMaster getParentEtMaster() {
           return parentEtMaster;
           }
          
           public void setParentEtMaster(ETMaster eTMaster) {
           this.parentEtMaster = eTMaster;
           }
          
           private boolean isNew = true;
          
           @TransactionAttribute(NOT_SUPPORTED)
           public boolean isNew() {
           return isNew;
           }
          
           public void setNew(boolean isNew) {
           this.isNew = isNew;
           }
          
           private boolean isChild = true;
          
           @TransactionAttribute(NOT_SUPPORTED)
           public boolean isChild() {
           return isChild;
           }
          
           public void setChild(boolean isChild) {
           this.isChild = isChild;
           }
          
           private String doneOutcome = "find";
          
           public void setDoneOutcome(String outcome) {
           doneOutcome = outcome;
           }
          
           private String doneChildOutcome = "doneChild";
          
           public void setDoneChildOutcome(String outcome) {
           doneChildOutcome = outcome;
           }
          ...
          /*this is the action method that gets called the first time the button is hit, but seems to get skipped the second time it's hit...*/
           public String updateAndCreateChild() {
           refreshFinder();
           return "child";
           }
          ....
          


          Thanks again, I'm running out of ideas on this one...

          • 2. Re: Design Question and Seam/JSF question

            I'm really stuck on this. I keep coming back to the fact that the only reason I know its not working is that my action function is not being called when I hit the button that calls it.. I know it works the first time I hit it, but not the second time.

            Is there any other debugging I can do? Can I get the seam-debug page working that is in the booking example? Or should I try going through the Seam src code?

            Please help....

            • 3. Re: Design Question and Seam/JSF question

              Ah ha! I figured out the problem. When I finished doing whatever with Table C, I was ending the conversation. So I think I misunderstood how conversations work. I thought that when I was going back and forth from forms I was switching conversations, that it switched when I want to the new page/Seam component. But i guess what actually was happening was I was in a conversation from A to B to C, and that if I actually wanted to switch I would have had to use the switcher object...

              Am I correct here?

              So what would be the better approach here, to have one conversation from A to B to C, or seperate conversations for each and use switcher to jump btwn then?

              Thanks from a newbie..

              • 4. Re: Design Question and Seam/JSF question
                bfo81

                If I understood correctly that A, B and C are nested, then the comversations should be nested, too.

                As an example (I'm not sure if this is what you have), let's look at a quiz (who wants to be a millonaire *g*).

                I have an Entity class Question and an Entity class Answer.

                Question 1:n Answer

                So every question has multiple answers, and every answer belong to exactly one question.

                Now if I edit a question I begin a new conversation. That means I can edit multiple questions in multiple windows, and every edit process runs in its own conversation.

                And during editing a question, I can edit its answers (or add some), each in a new window, with its own NESTED "sub-"conversation.

                To begin a nested conversation just use @Begin(nested=true).

                If I misunderstood your scenario... sorry ;).

                • 5. Re: Design Question and Seam/JSF question

                  Ah ok I hadn't thought of using nested conversations. Could I still jump in and edit say table B or C without going through A?

                  Thanks.

                  • 6. Re: Design Question and Seam/JSF question
                    bfo81

                    You can start nested conversations even without having a parent conversation. It's just like a normal top-level conversation then.