Java Magazine, September/October 2016
ORACLE COM JAVAMAGAZINE SEPTEMBER OCTOBER 2016 56 jvm languages just like Swing The domkit Table automatically handles all the thorny issues eficiently mapping the model to DOM elements but only for the visible rows scrolling column sorting single multiple selection and many other features Lets look at some real code to illustrate how to build a table using domkit @ Js class MyTableModel TableModel override Int numCols 5 override Int numRows 3 override Void onHeader Elem e Int c e text Col c override Void onCell Elem e Int c Int r TableFlags f e text r x c This creates a subclass of the domkit TableModel It defines the number of rows and columns for the model and provides a callback for how to render the column headers and cells Now lets see how I put it all together to create a table table Table model MyTableModel sel multi true onAction t echo onAction t sel indexes onSelect t echo onSelect t sel indexes This code creates an instance of Table using the model class and sets multiple selection to be enabled Then I add some event handlers for action double click and selection changes that echo to stdout the selected row indexes Figure 1 shows what the table looks like in a browser If you have experience building HTML5 UIs and miss the higher level abstractions that a widget toolkit such as Swing provides then domkit might be just the technology for you Conclusion In this article I examined four key features of Fantom portability immutability actor concurrency and domkit This only briefly touches on the Fantom language libraries and tools If you would like to learn more visit our website where you can find documentation a community forum an active mailing list and links to downloads as well as our BitBucket repo article Brian Frank is the founder and president of SkyFoundry a software company specializing in IoT data collection analysis and visualization Brian and his brother Andy Frank have been developing the Fantom platform since 2005 Brian also serves as the technical lead for project haystack org an open source project for defining data models and formats in the IoT space Figure 1 A sample table created with Fantom domkit learn more Why Fantom
You must have JavaScript enabled to view digital editions.