3 Replies Latest reply on Jan 12, 2009 3:49 PM by ggbustos

    s:link performance problem

    ggbustos

      Hi all,


      I have a strange problem, maybe will be my mistake or a s:link bug.
      I used a s:link in a page that is a list of elements(h:datatable tag) with name requirementsList.xhtml, this page has a s:link like this:


      <s:link id=create value=#{messages['button.add.requirement']}
           action=#{requirementAction.beginCreate}
           propagation=join
           rendered=#{requirementListAction.createEnabled} />



      The link is used to create a new element for the requirements list, so must redirect to another page called requirementEdit that is returned by the method beginCreate.


      Now, the performance problem is the follow:
      When my jboss is running, I call the page requirementsList.xhtml, then I noticed a very long url in the final html that is rendered by s:link tag “http://localhost:8080/darwin/project/requirementList.seam?actionMethod=project%2FrequirementList.xhtml%3ArequirementAction.beginCreate”.


      When I click on the link the current page (requirementsList.xhtml) is called again, before passing to the requirementeEdit page returned by the method requirementAction.beginCreate (it is logical due to the final url that is rendered). So, my requirementsList fetches ‘n’ elements from my DB and is calling twice and fetching n elements again (I see this on my log files, the SQL sentences appear twice).


      Is it a normal process with s:link tag or my mistake? I need help with this, because my application has many s:links and the same problem occurs in all pages that it appears.


      regards,


      Gustavo Bustos.-

        • 1. Re: s:link performance problem
          stefanotravelli

          Use <h:commandLink> or, at least, specify the target view in the view attribute (maybe <s:link view="/requirementeEdit.xhtml" .... />).


          Using <s:link> with an action is often questionable (see this commend on another thread).


          <s:link> with action and no view definitely calls for a <h:commandLink>.


          stefano


          • 2. Re: s:link performance problem
            ggbustos

            hmmm, this solve my problem on my requirement screen, but not in other pages that I have. Because in some methods it's probably that return diferents pages, so i don't need a view hardcoded in my page. I tried with h:commandLink and the very long url was solved, but is calling twice the requirementList.xhtml I don't need that those links in JSF call twice my pages. I will know a better solution, probably I am doing something bad.


            thanks for you response!!


            Gustavo.-

            • 3. Re: s:link performance problem
              ggbustos

              I will apreciate any other response.


              Thanks!!!


              Gustavo.-