Styling contracts across different devices
In the preceding examples, we saw how to write the JSF contracts and how to use them by explicitly setting them by name in the contracts
attribute of the <f:view>
tag. Sometimes, you may need to dynamically set a contract (theme); for example, you may need to choose the right contract based on the device type that should display the application (PC, tablet, smartphone, mobile phone, and so on). In this case, you need to provide the contracts
attribute value from a managed bean.
It is beyond the scope of this book to provide a powerful code (or algorithm) for detecting device types, resolutions, and so on. With minimum involvement in the mobile area, we will try to write a JSF application capable of choosing ...
Get Mastering JavaServer Faces 2.2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.