4 Replies Latest reply on Sep 20, 2012 5:33 PM by Brendan Healey

    a4j commandlink re-renders the view

    Clinton Murdoch Newbie

      I'm trying to use an a4j:commandlink to send a value from a rich:datagrid into an a4j:outputpanel. This aspect is working, but the view is being re-rendered each time.

       

      The problem this causes is that the f:viewParam that I am using to get the query string value is activated and gets a null value for the parameter. this makes all subsequent rendering fail.

       

      The commandlink is inside an a4j region but i also tried it with a form.

       

      <f:viewParam name="gameid" value="#{gamePageHandler.gameId}" converter="#{ParseInt}" converterMessage="Game ID must be numeric" required="true" requiredMessage="Bad request. Please use a link from within the system." />
      

       

       

      <a4j:commandLink render="innspanel" execute="@region">
      <h:graphicImage value="/resources/images/arrow-right.gif" style="border:0" />
      <f:setPropertyActionListener target="#{gamePageHandler.currentInns}" value="#{inns.inningsId}" />
      </a4j:commandLink>
      
        • 1. Re: a4j commandlink re-renders the view
          Clinton Murdoch Newbie

          the workaround i have put in place (which for all intents and purposes does work) is to remove the required parameter from the viewParam and then check for null in setting the bean field.

           

          in terms of the framework though, should an ajax request re-render the view? isn't the idea of using ajax to avoid re-rendering?

          • 2. Re: a4j commandlink re-renders the view
            Brendan Healey Master

            It shouldn't be doing a full submit for sure. You've not posted enough code for me to be able to see what is going wrong

            really but you don't need a view parameter. You're not navigating to a different view or invoking an action, simply updating

            an area on the same page? keep the setPropertyActionListener and lose the f:viewParam, that should do it.

             

             

            Regards,

            Brendan.

             

             

             


            Freelance Java Enterprise Developer


            JSF Richfaces Ajax Java 6/7 (scjp) EE 6 HTML CSS JavaScript jQuery MySQL JPA Hibernate Eclipselink

            Spring Oracle SQL JPQL Sybase EJB CDI Glassfish Apache JAX-RS Primefaces UNIX Paypal and more..

            • 3. Re: a4j commandlink re-renders the view
              Clinton Murdoch Newbie

              Hey brendan,

               

              The view param is for when the page is loaded, to get the querystring from the request. I would have thought that once the page is loaded though, this is not used again, so each ajax request should only submit the form/a4j:region and re-render the elements specified by the render attribute of the button.

               

              I have just noticed that the buttons are inside an a4j:region but not in a h:form, could this be causing the problem?

              • 4. Re: a4j commandlink re-renders the view
                Brendan Healey Master

                >not in a h:form, could this be causing the problem?

                 

                definitely, they'll need to be inside an h:form for sure