Faster finding with Lenzcape’s searchbar

Next to searching from the Lenzcape application, you can also use the search plugin to search directly from the browser’s searchbar. This is how I am using Lenzcape myself usually.

The searchbar is particularly easy when you know the area that you want to search (that’s the lenz in lenzcape’s terminology). Further, the more you need to search in a specific area, the more it will pay off to create a lenz for that area.

Lenzcape’s searchbar in Firefox

To illustrate what I mean, let’s take grails as an example. I used grails to develop Lenzcape, so I am often searching grails related stuff. The base lenz for grails is “dev/grails” and following the search syntax you separate the lenz part of the query and the terms that you want to search for with a “)”. In this way you can type dev/grails ) redirect in the searchbar and it will search for redirect just in the grails area.

But you can also search more specific grails topics such as:

These lenzes all work for you as well because they are predefined. But you can also extend lenzes by integrating them with your own bookmarks. For example, I have included a few grails blogs with tag dev/grails/blog to my personal bookmarks. In this way I can search my bookmarked grails blogs via dev/grails/blog ) redirect. Note that if you type this using the search bar you will get no results unless you have also added bookmarks with tag “dev/grails/blog”.

Building your own lenzes in Lenzcape

In a former post I wrote that I would show how you can build your own lenzes in Lenzcape.

Initially I intended to show it in a blog post, but later when I got the idea to make a live demo, I thought it would be clearer (and cooler) to include it in the live demo. So check out the live demo if you want to see how you can build your own lenzes!

Redesigned version of Lenzcape now live

I have been busy redesigning Lenzcape. After the initial tryout version, I think the current state of this version is beta. Have a look at it and make sure you don’t miss the live demo.

Thanks to everyone who provided me feedback about the initial version. This has been really helpful to me. I look forward to hear what you think about this new version.

Getting the class attribute of an element in GWT

Spent a while on solving this one…

For the new version of my GWT application, I needed to get the class attribute of an element.
This code was working fine in Firefox:

    HTML html = new HTML(text);
    NodeList links = html.getElement().getElementsByTagName(”a”);
    for (int i = 0; i < links.getLength(); i++) {
      com.google.gwt.user.client.Element link =
        (com.google.gwt.user.client.Element) links.getItem(i);

      Log.info(link.getAttribute("class"));
    }

However, when I started testing other browsers this appeared not to work in Internet Explorer.
So I started trying some alternatives:

      Log.info(DOM.getElementAttribute(link, "class"));
      // Chrome & FF: ok   IE: ""

      Log.info( DOM.getElementProperty(link, "class"));
      //Chrome, FF& IE: null

      Log.info(link.getAttribute("class"));
      //Chrome & FF: ok   IE: ""

      Log.info(getAttribute(link, "class"));
      //Chrome & FF: ok   IE: null

      Log.info(link.getClassName());
      //Chrome, FF & IE: ok 
    }

    public static native String getAttribute(Element elem, String attr)
    /*-{
       return elem.getAttribute(attr);
    }-*/; 

At last link.getClassName() did the trick, but it took me some time before I realized that class is treated as an exceptional attribute in IE and that this method did exist at all!

Would be nice if there was a mechanism (assert?) that pointed to this method when getAttribute is called with class (and what about id?). But for now I hope google is your friend when you stumble on this issue…

©2006 - 2012 Rintcius Blok