6 Replies Latest reply on Feb 26, 2008 11:26 PM by gus888

    Strange page reload when click link on the page

    gus888

      Hi all,


      I don't know whether it is wrong with my code or it is Seam bug. I have a list page. Every time when I click on Edit link to edit an instance or click on other link on this page, the loadDoc method in the Bean is always called before redirect. Any help is appreciative.

      <ice:dataTable value="#{myDocList}" var="doc"\>
      
           <ice:commandLink value="Edit Doc"
                          action="#{docEditor.editInstance}"\>
                <f:param name="docId" value="#{doc.id}"/>
           </ice:commandLink>
           ...
      
      @Name("myDocLister")
      @Stateful
      @Scope(ScopeType.EVENT)
      public class MyDocListerBean extends implements MyDocLister {
      
           @Out(required=false, scope=ScopeType.PAGE)
           private List<Doc> myDocList;
      
           @Factory(value="myDocList")
           public void loadDoc() {
                ... retrieve doc from database...
      
           }
      }


        • 1. Re: Strange page reload when click link on the page
          nickarls

          If you are using the event scope then it has to repopulate every action since it disappears after every request.

          • 2. Re: Strange page reload when click link on the page
            gus888

            Thanks your reply, Nicklas. However, in my case, when I click on a link to redirect to another page, this clicking should not invoke the current page loading method before redirecting to other page. Anybody can give a help again? Thanks.

            • 3. Re: Strange page reload when click link on the page
              keithnaas

              What is the reason for using a Stateful Event scoped component?  I thought Event scope was synonomous with an HttpRequest.


              Also, Factory methods are called whenever the object identified by the factory is first referenced and it hasn't been initialized.


              This is likely what is happening:


              Since the scope is Event and the #{myDocList} is being referenced by the restore view, validation, or some other such JSF phase, the myDocList Factory method is being called on each and every HttpRequest.


              Would Conversation or Page scope be appropriate instead?  Or possibly not using a Factory method.

              • 4. Re: Strange page reload when click link on the page
                gus888

                Thanks, Keith.


                My request is very much typical, just load data from database, display, create new, update old, delete old. Since Seam is very new, it is very hard to find a enterprise pattern for this scenario. When I change EVENT to CONVERSATION (not long run), the situation is the same. If I don't use Factory in EVENT scope, when I click browser REFRESH, all data is gone. Anybody can recommend a enterprise pattern/methodology to implement the typical CRUD. It will be very appreciatively.

                • 5. Re: Strange page reload when click link on the page
                  nickarls

                  Hmmm, If the outjected variable is page-scoped, shouldn't it stick around even if the bean is in a shorter scope?


                  When you say the browser refresh kills the data, can you see the conversation ID change as you naviate in the app?

                  • 6. Re: Strange page reload when click link on the page
                    gus888

                    Nicklas Karlsson wrote on Feb 26, 2008 10:09 PM:


                    When you say the browser refresh kills the data, can you see the conversation ID change as you naviate in the app?

                    Hi, Nicklas,
                    I said that when I used EVENT SFSB and no Factory (just get...), browser Refresh will kill data. No CONVERSATION bean here.