Mojarra Scales


The other day I was looking for a good UI charting package that plays nice with JSF and stumbled on Mojarra Scales, one of those cool little projects that reminds me why JSF seemed like such a good idea at the time. Basically it’s a wrapper for YUI charts that lets you bind them to a backing bean as the data source via JSF and configure many of the attributes declaratively through EL. For example, I created a chart showing min/max/average HTTP request time like this:

<sc:chart id="requestThroughputChart" type="line"
     value="#{charts.totalRequestThroughputChartData}"
     seriesDef="[{ displayName: 'Rate', yField: 'rate' }]"
     horizontalField="time" width="100%" />

For the backing bean it’s a little old-school in that it uses a simple string-property map:

public List<Map<String, String>> getTotalRequestThroughputChartData() {
     List<Map<String, String>> list = new ArrayList<Map<String, String>>();
     for (Summary s : result.getSummariesByTimeSeq()) {
          Map<String, String> map = new HashMap<String, String>();
          map.put("time", timeIndex(s));
          map.put("rate", s.getStatistic().getRate().toString());
          list.add(map);
     }<
     return list;
}

But hey, it works and is super easy to use – a good thing since their examples are sparing and the site has practically zero documentation. The result looks like this:

chart

It always feels like JSF could have gone farther if more things like this fit together: I think the haphazard piling of the API, differing implementations, renderkits, and component libraries by separate vendors always made things a little sticky, and to the uninitiated, often a configuration nightmare. There’s something to be said for frameworks that package it all up in a nice shiny box. But, projects like this still make me smile and appreciate being able to throw a good-looking chart on my site in minutes without touching Flash or JavaScript (or mutiliated Java – I’m still a little bitter towards GXT!). Keep up the good work.

, ,

  1. No comments yet.
(will not be published)