I had also the problem, that the datascroller did not work anymore:

I solved this with by using always the same ids for the links and not the pagenr as id suffix.

 

Here are some tips:

DataScroller:

I created my own DataScroller with corresponding Tag and Renderer. All those classes extend the corresponding HtmlDataScrollers from MyFaces.

It is important that encodeChildren does nothing and you have to call scroller.getChildren().clear() in encodeEnd().

Otherwise links could be rendered two times.

 

I could fix the problem with the not working links by creating dummy links for all pages in renderPaginator

Something like this:

    //create dummy links until maxPages is reached. These links should not be encoded!

    //Otherwise the links are not executed after AJAX refreshs and data model updates that result in more pages.

    if  (idCounter<maxPages)

    {

      for (;idCounter<maxPages;idCounter++)

      {

        if (scroller.getAjaxified())

        {

          // create an AJAX Link

          this.getAjaxLink(facesContext, scroller, idCounter, idCounter);

        }

        else

        {

          this.getLink(facesContext, scroller, idCounter, idCounter);

        }

      }

    }

Note that these dummy links should not be encoded !

 

Then I patched the getLink methods:

It is important that the links keep the same ids after ajax refreshs independent of the pagenr!!! Otherwise they are not executed.

MyFaces used the pagenr as id suffix for the links and this does not work!

You have to use something like a linknr which starts always at 1 and runs til maxPaginatorPages.

 

DataTable

- use a value binding for the first attribute of the datatable and manage this property in your backing bean. e.g. set it to 0 if you sort the table

- overwrite or extend org.apache.myfaces.component.html.ext.HtmlDataTable

      public void setFirst(int first)

    {

      ValueBinding vb = getValueBinding("first");

      if (vb != null)

      {

        //vb.setValue(getFacesContext(), first);

        return;

      }

      else

        if (_preservedDataModel != null)

        {

            //Also change the currently restored DataModel attribute

            _preservedDataModel.setFirst(first);

        }

        super.setFirst(first);

    }   

 

The above two points are important to get the right page visible in the datatable for scrolling or sorting after datamodel updates.

 

Hope this helps,

Michael

 

 


From: Aneesha Govil [mailto:[EMAIL PROTECTED]
Sent: Mittwoch, 1. November 2006 09:11
To: MyFaces Discussion
Subject: Re: JSF and ajax using phaselistener approach

 

Hi Michael,

Here is the description of my specific problem:

I got the datatable, sortheaders and datascroller working with Tomahawk. Then I was trying to ajaxify the table loading on the basis of a drop down. The table loads with ajax perfectly however, the datascroller and sort headers in it have stopped working. Is this a known issue? Does tomahawk not work with Ajax4jsf?

Can anyone help me look into how to make this work?

Tell me if you need more details/code to be able to help.

Thanks a lot.
Regards,
Aneesha

On 11/1/06, Michael Heinen < [EMAIL PROTECTED]> wrote:

Annesha,

 

I use the datatable with datascroller and a4j.

I spent a lot of time to get this running and I had to patch the datatable and the datascroller.

What is your specific problem ?

(I don't have the beginning of this thread)

 

Michael

 


From: Aneesha Govil [mailto:[EMAIL PROTECTED]]
Sent: Mittwoch, 1. November 2006 06:02
To: MyFaces Discussion
Subject: Re: JSF and ajax using phaselistener approach

 

Hi Craig,

I tried using Ajax4JSF but the datascrollers and sortheaders stopped working as soon as I put the datatable in an ajax-rendered zone. Therefore, I had to abandon it. I couldn't get any help on that either.

I will look at the rest of the resources. Thanks a lot for replying.

Regards,
Aneesha

On 10/31/06, Craig McClanahan < [EMAIL PROTECTED]> wrote:

 

On 10/31/06, Aneesha Govil <[EMAIL PROTECTED]> wrote:

Hi,

Can anyone give me links to any resources/examples on Ajax with JSF using the PhaseListener approach. I found it on the J2EE Blueprints but they work only with Java EE 5. I am using myfaces 1.1.4 (J2EE 1.4). Does this approach work with that too? Please give me some links/resources.


In addition to the other references people have given, you might want to look at the Remoting feature in Shale[1].  It includes a built-in phase listener that tries to do all the hard stuff so you don't have to, and an extensible Processor architecture so you can plug in your own processing logic.

One important factor is that Shale Remoting assumes you do *not* need access to the JSF component tree for the original page (thus eliminating the overhead of saving and restoring it), or even that the client be a JSF page at all.  If you need that, you might want to look at Ajax4JSF[2] or Dynamic Faces[3].  But, if you just need an easy way to hook incoming requests to back end business logic, and like the ability to use JSF's managed beans and _expression_ evaluation capabilities, Remoting might be useful to you.

(Incidentally, Shale Remoting is what many of the Blueprints AJAX components are using under the covers to acccess static resources, or connect to server side event handlers.)

Craig

[1] http://shale.apache.org/shale-remoting/
[2] https://ajax4jsf.dev.java.net/
[3] https://jsf-extensions.dev.java.net/

 

Any help is appreciated.

Thanks a lot.
Regards,
Aneesha

 

 

 

Reply via email to