1 2 Previous Next 28 Replies Latest reply on Mar 2, 2006 3:10 PM by emsa Go to original post
      • 15. Re: Prevent @Factory method execution?
        emsa

        Well not really IMHO - I have #{list} and when entering the page in default mode I want the factory to be called picking up default vales for the list. Clicking on a link/button, invoking an action, the same page gets redisplayted but a parameter is provided to the action so that the contents of the #{list} can be somethings else than the factory-default ... this doesn't seem so far out to me.



        • 16. Re: Prevent @Factory method execution?
          gavin.king

          Right, but you are using the #{list} during the RESTORE_VIEW phase. And the thing about the restore view phase is that Seam doesn't really let you "do stuff" (eg. access databases) during that phase because the conversation id is not known.


          Well, if you know you don't need the conversation id, I guess you can try adding @Intercept(ALWAYS) to the top of the component with the @Factory method and then I guess it will work...

          • 17. Re: Prevent @Factory method execution?
            emsa

             

            "gavin.king@jboss.com" wrote:
            Right, but you are using the #{list} during the RESTORE_VIEW phase. And the thing about the restore view phase is that Seam doesn't really let you "do stuff" (eg. access databases) during that phase because the conversation id is not known.


            Ok - sorry for beeing a bit thick - I do use (with a binding) on the page. Just have to do a jstl loop or something instead.

            Thanks,
            /Magnus


            • 18. Re: Prevent @Factory method execution?
              lcoetzee

              Just in terms of the troubles I had (which is now resolved !). I also traced it to my rendered="#{foo}" attribute (when I removed it my whole app worked like a dream, with it in it broke). Anyway, the solution was to change my logic a bit of where I actually set foo to null (to force a reget of my page).

              Hmm.. still have a lot to learn re. JSF and when what gets built and evaluated.

              Later

              Louis

              • 19. Re: Prevent @Factory method execution?
                gavin.king

                In theory, I guess, it should be possible to solve this problem and somehow extract the conversation id from the request before restoring the whole component tree.

                I will try to solve this problem.

                • 20. Re: Prevent @Factory method execution?
                  gavin.king

                  Actually, can you guys tell me if adding @Intercept(ALWAYS) is an alternative solution to your problem?

                  It may have been a mistake to make @Intercept(AFTER_RESTORE_VIEW) the default.

                  • 21. Re: Prevent @Factory method execution?

                    Evaluating EL during the restore view phase is kind of like doing extra stuff in Object.finalize()-- a bad idea.

                    Can you paste a full stacktrace that goes into the actual UIComponent code? What Gavin is suggesting should work, but the fact that it's being invoked or requested that early within the UIComponent unmarshalling--

                    • 22. Re: Prevent @Factory method execution?
                      lcoetzee

                      I will try the Intercept.ALWAYS when I get to work.

                      In terms of the conversation id... I actually build a the url's containg the parameters (e.g. the id of the object I want to display through my get and @Factory) Part of the url contains the conversation id which I actually inject through @RequestParam.

                      L

                      • 23. Re: Prevent @Factory method execution?
                        gavin.king

                        yeah, in the case that the conversation id is a request param, it is certainly possible to restore the conversation context earlier.

                        But currently we are using an attribute of the UIViewRoot in the case of postbacks.

                        • 24. Re: Prevent @Factory method execution?
                          emsa

                           

                          "gavin.king@jboss.com" wrote:
                          Actually, can you guys tell me if adding @Intercept(ALWAYS) is an alternative solution to your problem?


                          Not for me, I'm getting an IllegalStateException "No Conversation Id"
                          (Just a quick test - I can give it another go tonight maybe (european time))

                          • 25. Re: Prevent @Factory method execution?
                            emsa

                            What I'm doing is that I have a dataTable that gets it data from a EVENT scoped bean. I have commandLinks outside as well as inside the table. When posting from the page the tree in reconstructed and I'm ending up with the situation discussed in this thread.

                            I am not using any DataModel featues so I really don't need the data from the bean in the RESTORE_VIEW phase. Using the dataTable in the same way in 'pure' JSF is not a problem.

                            I can probably (not tested yet) redo the page using some jstl to generate the table, or maybe write a new renderer to dataTable that does no deconding (again - not tested).

                            Maybe this is caused by a missuse of dataTable (and components like that)? But is it ever a good idea to invoke a factory in the RESTORE_VIEW phase? Is it not better just to leave the value null during this phase and call the factory in a later phase as needed?

                            • 26. Re: Prevent @Factory method execution?
                              lcoetzee

                              No... the Intercept.ALWAYS made no difference.

                              However, my application now works even though the @Factory is still beign called before the action in the other bean.


                              • 27. Re: Prevent @Factory method execution?
                                gavin.king

                                It would really help if you would actually post stack traces!

                                • 28. Re: Prevent @Factory method execution?
                                  emsa

                                  Sorry haven't got around to the traces yet, but I guess that one way to avoid the @Factory problem is to scope the affected component as @Page (or higher ...)

                                  /Magnus

                                  1 2 Previous Next