API
@-Formulas
JavaScript
LotusScript
Reg Exp
Web Design
Notes Client
XPages
 
View Icon Column Formula
I can't take complete credit for this, but here's my formula for an icon column in a data view in XPages.

<xp:viewColumn columnName="$6" id="viewColumn1" displayAs="hidden">
      <xp:this.iconSrc><![CDATA[#{javascript:var url:XSPUrl = new XSPUrl(database.getHttpURL());
var path = "/icons/vwicn";
var idx = viewRow.getColumnValues().get(0);
if (idx == 0)
      path = "/icons/ecblank";
else if (idx < 10)
      path += ("00"+idx).left(3);
else if (idx < 100)
      path += ("0"+idx).left(3);
else
      path += idx.left(3);
path += ".gif";
url.setPath(path);
url.removeAllParameters();
url.setScheme("https");
return url.toString();}]]></xp:this.iconSrc>
      <xp:viewColumnHeader value=" " id="viewColumnHeader1">
      </xp:viewColumnHeader>
      </xp:viewColumn>

The important this this formula does that others don't is handle the case when there is no icon. The value "0" in the Notes client will display no icon, but there is no "vwicn000.gif" for display on the web. So, when the value is 0, display the icon "ecblank.gif".

The other thing that this formula does is use SSL to display the icon. This is done in the url.setScheme("https"); statement. If you aren't using SSL, then you can omit that line. Even if you are using SSL and you omit that line, things will still work. You'll just get a lot of warnings on your browser that your main page is secure but you're retrieving the images unsecurely.

The items that need to change are the column name (my example is a computed column with a column name of "$6"). The other item is the var idx = line. The variable "viewRow" is the variable defined for my data table. It gets all the columns for this row, then grabs the first value of that array - my icon column is the first column in the view.