It's time for a fresh take on JSF. BootsFaces brings the clean look and feel of Bootstrap to the JSF world. AngularFaces
adds AngularJS to the equation. AngularTetris takes both frameworks and pushes the envelope. Be honest: does it look like
The settings tab uses the panelGrid of BootsFaces and the automatic generation of labels of AngularFaces. The resulting source
code is very compact.
The highscore tab uses SmartTable to generate the table on the client. The <ngsync> tag
only transfers the payload data to the client. As a result, the network is used a lot more
efficient than with a traditional JSF or PrimeFaces data table.
The game tab itself is basically a two-dimensional grid. It's displayed by an AngularJS ng-repeat directive.
The data structure of the playground is a bit odd. Basically, it's simply a two-dimensional array of integers.
Unfortunately, it's difficult to translate such an array to JSon from Java. So I chose to model both the
rows and the cells as full-blown objects. That make for slightly clumsy code, but it does the trick.
The AngularJS controller is responsible for hiding the buttons and for displaying the highscore table.
It adds a certain degree of responsiveness to the JSF application.
The GameController withing the AngularJS controller is responsible for running the game itself. It has been
please look at the GitHub repository:
Tetromino.js (the Tetris bricks)
There's nothing special about the JSF beans. The Grid class represents the entire playground. Actually, in the current
version it doesn't play an important role. It simply initializes the AngularJS model of the game with empty fields.
The Row class represents a row of picture elements.
The Cell class represents an individual pixel. In theory, a simple two-dimensional array of integers suffices to represent the playground.