Rich Waters

Ext, Javascript, Notes/Domino, Ext.nd, Ruby on Rails

Been playing around with integrating the new release of Ext into Domino YUI. There are a few others working on it as well: Jack Ratcliff & Jake Howlett.

It seems that everyone has noticed the transfer hasn’t been completely straight-forward, so I figured I’d post my fixes to a couple of the issues that we’ve all seem to run into (dealing with the new Grid implementation)
EDIT: In Ext 1.0 Alpha 2 this hack is no longer needed

  1. var proxy = new Ext.data.HttpProxy({
  2.     url: parentURL,
  3.     method: "GET"
  4. });
  5. proxy.conn.extraParams = { resortAscending: 1 };
  6. proxy.conn.on(‘beforerequest’,function(e,opts) {
  7.     if (this.url.indexOf(‘&’) != -1) {
  8.         this.url = this.url.split(‘&’)[0];
  9.     }
  10.     this.url += "&"+Ext.urlEncode(Ext.apply(opts.params,
  11.       this.extraParams));
  12. });

There’s an issue with the new Connection routine not sending parameters through if you change the method to get instead of post. I wrote an event listener that attaches to the connections beforerequest event which strips off any parameters already on the URL (anything after an &) then serializes and places the parameters back onto the URL. I went through a couple rounds of tweaks and ended up with very similar code to what Jack is using for Post requests. The example above also tests out sending additional parameters through by setting the connections extraParams property.

Another issue that kept coming up was the hard-coded paging parameters to start at 0 and use “limit” as the keyword where Domino needs “count”. To fix this issue I extended Ext.PagingToolbar and wrote Ext.DominoPagingToolbar.

  1. Ext.DominoPagingToolbar = function(el, ds, config){
  2.     Ext.PagingToolbar.superclass.constructor.call(this, el,
  3.       null, config);
  4.     this.ds = ds;
  5.     this.cursor = 1;
  6.     this.render(this.el);
  7.     this.bind(ds);
  8. };
  9. Ext.extend(Ext.DominoPagingToolbar, Ext.PagingToolbar, {
  10.   onClick : function(which){
  11.     var ds = this.ds;
  12.     switch(which){
  13.       case "first":
  14.         ds.load({params:{start: 1, count: this.pageSize}});
  15.       break;
  16.       case "prev":
  17.         ds.load({params:{start: Math.max(1,
  18.           this.cursor-this.pageSize), count: this.pageSize}});
  19.       break;
  20.       case "next":
  21.         ds.load({params:{start: this.cursor+this.pageSize,
  22.          count: this.pageSize}});
  23.       break;
  24.       case "last":
  25.         var total = ds.getTotalCount();
  26.         var extra = total % this.pageSize;
  27.         var lastStart = total – (extra || total-this.pageSize);
  28.         ds.load({params:{start: lastStart, count: this.pageSize}});
  29.       break;
  30.       case "refresh":
  31.         ds.load({params:{start: this.cursor, count: this.pageSize}});
  32.       break;
  33.     }
  34.   },
  35.   getPageData : function(){
  36.     var total = this.ds.getTotalCount();
  37.     return {
  38.       total : total,
  39.       activePage : Math.ceil((this.cursor-1+this.pageSize)/this.pageSize),
  40.       pages :  total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
  41.     };
  42.   }
  43. });

While still hard coded its now geared to Domino. A couple of hacks were necessary to make activePage reference the proper values.

Anyway, hope its of help to any others who may be trying to implement Ext 1.0 on a Domino system. Stay tuned for a new Domino YUI release once I get things working smoothly.

Share and Enjoy:
  • Digg
  • Facebook
  • Google Bookmarks
  • Posterous
  • RSS
  • Twitter
U Comment, I Follow - Heavily moderated, SPAM will be dealt with.

7 Responses to “Ext 1.0 progress”

  1. Hi Rich,

    You and Jake are ahead of me with implementing Ext 1.0 in Domino. I’m just now starting to look at it. I appreciate you sharing your workarounds and customizations to get Ext working with Domino. I’ve had the need to work with views with readers fields so the paging has been the biggest challenge. I have a pretty decent solution right now and I’ll blog about it soon so that you and others can pick it apart and hopefully we can make it better and more rock solid. :)

    Jack Ratcliff

  2. Cool, I haven’t messed around with any of this in applications using readers fields. I look forward to your post.

    Rich Waters

  3. Hi Rich,

    Finally found some time this week to start converting my DWT project over to using Ext 1.0. As for using a GET request versus a POST, do you come across any issues where the GET doesn’t go to the server but instead pulls from cache? I found that Domino is ok with a POST to ReadEntries and ReadViewEntries. Just wondering your thoughts.

    Jack

    Jack Ratcliff

  4. I haven’t run into any issues so far with ‘GET’ requests caching. I’ve been having some odd issues with javascript files caching but that’s pretty much it.

    Rich Waters

  5. Hi Rich,

    I think it only happens in IE. Using HttpWatch(Fiddler will probably show the same results), I see that as a page thru and view and then page back, urls that I have already hit before are pulled from cache. I know that in some of our custom apps we always tack on a timestamp parameter to the end of a url to trick IE into not pulling from cache. I don’t know if I should do the same here or perhaps Ext has a setting/config option I can set that will do it for me. Do you know of one?

    Jack

    Jack Ratcliff

  6. Hi Everyone,
    I just start to implement the rBefore release of Ext framework. Bu I also apreciate your sharing.

    We use Domino Yui as a foreground into a dev for a multinational company.

    I expect to thanks all of you when dev will be finished in the name of our company.

    Ben

  7. Jack, you can work around the caching issue by appending a parameter to the URL with a random value. There are several threads on the extjs.com forum discussing this. Right now the forums seems down (probably due to a re-configuration of the indexes) so I can’t link to any of the threads now. Hope you can find it yourself.

    John Foldager

Leave a Reply