Friday, January 25, 2008

Moving status checking stuff to a managed bean?

It is a time consuming procedure for javascript now to check whether each station has a status change on the chosen date or within the last 30 days before that date, because javascript is not efficient enough. So I am thinking about moving this procedure into a jsf managed bean, and call a method like "getColorsForStations" on it when we need to recolor the stations.

The problem is that managed bean can only be used by binding to some jsf tag of a html control. We can't call the methods of a managed bean directly from javascript. So the following tricks might be needed:
a. The method may need five parameters: the current view scope of the map (min latitude, max latitude, min longitude, max longitude), and the chosen date. So we need five invisible control tags to save the value of these parameters;
b. We need an invisible commandButton or something like that to map its onClick action to the call to this method. In this way we'll be able to call the method by invoking "btn.click()", after setting up the parameter values.
c. We need an invisible control to store the result. The result should be simple, like a string on {0, 1, 2, 3,4, 5}, where each number denotes a different color.

After calling the method, we can decide the color for every station by analyzing the resulted string.

No comments: