Archive for the 'code' Category

JavaScript Library Overview

Wednesday, October 31st, 2007

JavaScript Library tutorial that JQuery’s Resig gave at the October 2007 Ajax Experience conference

JavaScript Library Overview » SlideShare (share powerpoint presentations online, slideshows, slide shows, download presentations, widgets, MySpace codes)

Very interesting comparison of the “Big 4″ JavaScript libraries (Prototype, jQuery, YUI, and Dojo). If you’re up in the air over which to use, this might help sway you one way or the other. It’s very interesting to see how similar they all are and makes you think about which approach is best (querying CSS selectors versus grabbing a single DOM element, extending the language or namespacing functionality).

Tags: , , , , , , ,

Internet Explorer and Advanced Behaviors

Thursday, October 11th, 2007

For Microsoft Internet Explorer 5 and later, HTML Components (HTCs) provide a mechanism to implement components in script as Dynamic HTML (DHTML) behaviors. An HTC is an HTML file that contains script and a set of HTC-specific elements that define the component. The component is saved with an .htc extension. This section lists these HTC-specific elements and the members they support.

HTC Reference

How did I not know about these before? Essentially, they let you inject new behaviors into IE. this guy injected :hover onto any class, something that IE 6 and lower don’t support. This guy fixed PNG 24-bit transparency.

Essentially, you include a link to an HTC file (a file ending in .htc or .hta) into your document. Using a JavaScript-based syntax, you can essentially hack through the old IE DOM (or stylesheets, or whatever) and rewrite it to workaround IE limitations.

In the :hover example above, the author parses all the stylesheets and creates a class-based JavaScript workaround. Yep, that’s what you’d usually do to implement :hover, only this is done all behind the scenes: you define your stylesheet as normal, and the HTML Component takes over and extends IE’s behavior to match it.

Couple these with conditional comments, and you can selectively extend versions of Internet Explorer with behaviors they don’t (and should) support.

Like conditional compilation, how did I not know about this by now?

Tags: , , , , , ,

Adobe Demos "Thermo” RIA Design Tool to Delighted Crowd

Wednesday, October 3rd, 2007

Thermo has basic drawing tools that can be used to wireframe an app, but what really makes Thermo special for designers is that it understands Photoshop images and uses layer data to capture information about various UI elements (the application also plays nice with images from Illustrator and Fireworks).

Adobe Demos “Thermo” RIA Design Tool to Delighted Crowd

Damn.

Edit: Posted this on Ajaxian.

I’ve gone through most prototyping tools that are currently out there, trying to find one that would let designers / IAs easily get their ideas on a screen.

All either require designers to learn how to develop in something (”learn HTML + JavaScript” or “learn mxml for Flex”) or create something too basic for us to use to collaborate on interaction design (”here are a bunch of boxes on a wireframe…look, they moved to the left”).

If this can translate a comp into something that we can work on together as an actual prototype, I’m all for it. If it works as advertised, it could really speed up and help an iterative creative process.

Tags: , , ,

Pricing Web Apps

Wednesday, September 12th, 2007

Step 1: Idea
Step 2: Build
Step 3: Figure out how much to charge
Step 4: Profit.

read more | digg story

Dragging Windows in Adobe AIR

Saturday, August 11th, 2007

Here’s how to do that.

technorati tags:

Back to School with JSTL

Tuesday, July 31st, 2007

I haven’t done any work with JSTL in a little while, but some work with JSP brings it back. It reminds me that JSTL is a pretty powerful little taglib, espcially JSTL core (the old c: guys). Here are a couple references that I found helpful when first learning about and working with JSTL and JSTL core, all those many years ago:

Personally, I have to make a concious effort not to write eRB-style Ruby templating code, but I’m coping pretty well.

technorati tags:,

Searching Creative Commons Commercial Use OK Images on Flickr

Monday, July 9th, 2007

Need to find images available under the Creative Commons license that are OK to use in commercial applications on Flickr? I did for a few presentations, and Flickr conveniently buries this type of search under more than enough clicks to make doing it kind of annoying.

So, I built a Mozilla search plugin that makes it a heck of a lot easier. (I screwed up my first upload, so it’s the second one on the page if two results show up – the one with the Apple icon). Just type in the tag you’d like to search for, and get those CC and commercial use images back.

technorati tags:, , , ,

An Odd Introduction to Adobe AIR

Tuesday, June 19th, 2007

Adobe’s running a bus tour to introduct/promote its new AIR framework to developers like you and me. A bus tour? With an API? Very Web 2.0.

technorati tags:,

The Differences Between HTML4 and HTML5

Friday, June 15th, 2007

Here’s what will be changing (added, dropped, altered) when HTML4 is replaced with HTML5. Get to know these guys. Make friends. They’ll be around for a while.

technorati tags:, , ,

HOWTO: Creating Column Layouts with JSTL and JSP

Saturday, March 3rd, 2007

Creating a multi-column layout in a JSP using JSTL can be a difficult concept to master. Over at my day job, we’ll see this concept occasionally. We’ll have a block of data that we’d like to present in a series of columns, with a maximum number of items in each column. Here is a quick tutorial to outline a solution to this pattern. We’ll be using Sun’s Core JSTL tag library, to do the heavy lifting, along with CSS and HTML.

The Setup
Let’s assume we’ll have at most 30 items in our set, and we’ll want a maximum of 10 items in each column, giving us a three-column layout. For this example, we’ll also put our items in an ordered list so that we can see what item number we’re working with. Let’s set that up in code.

  1. CSS — You’ll need a simple column layout that accounts for the fact that you may have any number of columns, depending on how much data you’ll be working with. I’ll use floats to make it simple, and I’ll add a border to each successive column for a little visual flair. My CSS would look like this:

            div.leftCol{
              float:left;
              width:200px;
            }
    
            div.middleCol, div.rightCol{
              border-left:1px solid #CCC;
              float:left;
              padding-left:20px;
              width:200px;
            }
          
  2. HTML — This one is up in the air. You may have three divs, you may have one. But, they’ll all look something like this:

    <div class="leftCol">[[10 items]]</div>

We know what we’ll be working with, but we’ll need some creative use of JSTL to actually get these elements to fall into place and enforce our maximum values per column rule.

The JSTL
We’ll be making use of two JSTL Core constructs: the <c:if> tag and the <c:forEach> loop.

  • <c:if> works like any standard if test. We’ll use it to test column data boundaries.
  • <c:forEach> gives us a hook called "varStatus" that lets us peek into the status of the iteration. We’ll be looking specifically at the index property of that varStatus object.

Writing the Code
Let’s start with a skeleton JSTL loop, so that we have a little scaffold to build on.

    <c:forEach items="${someItems}" var="item" varStatus="loop">

      <li>${item}</li>

    </c:forEach>
  

That’s a start. We still have to figure out where to place our starting and closing div tags and our starting and closing ol tags, which is the problem concept behind this pattern. Luckily, there’s a clever way of solving this problem.

Assume that we know that there will be at least one item to work with. (If there’s a chance for zero, use a <c:choose&gt block to react appropriately, dealing with the zero condition separately, and using this method as-is.) With at least one item, we’ll always need a left column and a start <ol> tag, no matter what. We’ll always need closing tags for our left column div and an ol, too. Knowing that these are always required, we’ll move them outside the loop, so that they’re always displayed.

    <div class="leftCol">
      <ol>
        <c:forEach items="${someItems}" var="item" varStatus="loop">

          <li>${item}</li>

        </c:forEach>
      </ol>
    </div>
  

We now have at least one column and list. We can use simple if tests to figure out when to close that first column and list and begin a second. In pseudocode, if we are at our maximum number of items, print a
close ol tag, print a close div tag, print a new open div tag with appropriate class, and print a new open ol tag.
So, if we’re at a maximum number of items (in our case, 10 and 20), we’ll close that column and start a new one. Let’s add that concept to our block of code, and finish this pattern. (Remember that loop.index gives us a count of which item we’re on.)

     <div class="leftCol">
       <ol>
         <c:forEach items="${someItems}" var="item" varStatus="loop">

           <li>${item}</li>

           &;lt;c:if test="${loop.index == 10}">
&;lt;c:if> &;lt;c:if test=”${loop.index == 20}”>
&;lt;c:if> </c:forEach> </ol> </div>

That above code may take a few seconds to sink in. The trick is that the </ol> and </div> tags after the loop will close any <ol> and <div> tags that are open at that point. It could be the left column that those tags close, or the middle column, or the right column. Let’s think about that for a second.

  • If there are 4 items in the list, we print the opening tags, enter the loop, print 4 items, exit the loop, print the close tags.
  • If there are 17 items in the list, we print the opening tags, enter the loop, print 10 items, print the close tags for the left column, print the opening tags for the middle column, print 7 items, exit the loop, print the close tags.
  • If there are 24 items in the list, we print the opening tags, enter the loop, print 10 items, print the close tags for the left column, print the opening tags for the middle column, print 10 items, print the close tags for the middle column, print the opening tags for the right column, print 4 items, exit the loop, print the close tags.

As you can see, we’re using the nature of HTML (a closing tag closes the nearest opening tag, regardless of any attributes that opening tag may have) to simplify our work and save many lines of JSTL. In the meantime, we have a simple pattern that will allow us to create as many columns as we want (simply create a generic CSS column class) with as many items in each as we want (simply change the boundary values in the JSTL). The key to the puzzle: keeping code we know we’ll always need outside of the loop so that it will always be printed and taking advantage of the nature of HTML.

technorati tags:, , , ,

I'm Reading…
Search This Site
You are currently browsing the archives for the code category.

AddThis Feed Button

Need great hosting?

Categories