Welcome!

Java IoT Authors: APM Blog, Liz McMillan, Elizabeth White, Simon Hill, Stackify Blog

Related Topics: Java IoT

Java IoT: Article

Apache Trinidad - A World Cup Skinning Experience?

A global style sheet that only has to be set in one place for the entire application

One of the 2006 Soccer World Cup highlights must surely be the Trinidad and Tobago versus Sweden game. The underdogs Trinidad and Tobago managed to push off the onslaught from the Swedish team. The game ended 0-0, which was for the people of Trinidad and Tobago a divine experience - their teams very first World Cup point!

So, you are, of course, asking yourself: What are these guys talking about? The question you should ask yourself is: Is Trinidad and Tobago going to be a success in the Java EE world as well? With the addition of project Trinidad to the Apache MyFaces community, the MyFaces project can now offer a rich and powerful component solution Trinidad and Tobago (and not to forget the original Tomahawk library). Project Tobago is a donation from Atanion GmbH (www.atanion.com) and, as a project, it recently graduated from the Apache Incubator.

Project Trinidad, the largest component library of the three, is a donation from Oracle. This donation is a subset of Oracle's well-known ADF Faces component library to the Apache Software Foundation (http://incubator.apache.org/adffaces/).

What is Apache Trinidad? Apache Trinidad is the most comprehensive free JSF component library on the planet. This library contains 12 helper objects such as converters and validators, and a staggering 93 components ranging from simple input components to complete page components with built-in menu model support. In addition, Apache Trinidad provides a set of extended services such as dialog framework and skinning framework.

This is the second article in a series of articles where we will be deep diving into various aspects of Oracle's donation - Apache Trinidad - and give developers insight into its functionality and how to use and extend Apache Trinidad. In our first article we covered the HTML Ajax RenderKit provided with project Apache Trinidad (http://jdj.sys-con.com/read/232061.htm), and in this second article we are going to cover the skinning feature provided by this JSF component library.

Project Trinidad's Skinning Framework
Project Trinidad lets you change the appearance, or look and feel, of an application without having to rewrite the code that implements the application's user interface. Trinidad currently provides two parent skins, Simple and Minimal, which you can extend to provide custom skins for your applications. The Minimal skin provides some formatting and the Simple skin contains almost no special formatting. By default, a custom skin inherits the appearance of its parent look and feel. When you wish to modify the appearance of a component, you simply provide custom style definitions and custom icons.

About the Trinidad Skins
A skin in project Trinidad is a global style sheet that only needs to be set in one place for the entire application. Instead of having to style each component, or having to insert a style sheet on each page, you can create one skin for the entire application. Every component will automatically use the styles as described by the skin. Any changes to the skin will be picked up at runtime; no change to the code is needed. Skins are based on the Cascading Style Sheet specification, and are using CSS 3.0 syntax.

In addition to using a CSS file to determine the styles, skins also use a resource bundle to determine the text. For example, the words "Previous" and "Next" in the navigation bar of the Project Trinidad's table component are determined using the skin's resource bundle. All the included skins use the same resource bundle. In this article, we are not going to cover the use of resource bundles.

Creating a Custom Skin
You create a custom skin by extending the Simple skin and overriding the provided selectors. There are three different levels of selectors: Global, Button, and Component.

  • Global Style selectors affect more than one component. If the selector name ends in the :alias pseudo-class, then the selector is most likely included in other component-specific selectors. Defining properties for a selector that ends in :alias will most likely affect the skin for more than one component
  • Component-level selectors can be used to skin a particular project Trinidad component. The selectors defined below are specified by the component they affect. Let's say you want to skin the tr:chooseDate component. One of the selectors is af|chooseDate::title. The ::title pseudo-element indicates that this is the title portion of the tr:chooseDate component. If you want to skin the title of the tr:chooseDate component, you would set css properties on the af|chooseDate::title selector in your Project Trinidad skin .css file.

    Note: Apache Trinidad is still undergoing incubation, so naming conventions such as af| will likely change in future builds of Apache Trinidad.

    You may see selector names that end in :alias in the component-level section. These are meant to provide short-cuts to skin more than one component that shares a certain style or icon, or to skin more than one piece of a component. For example, the .AFDefaultFont:alias style defines skin properties that are shared by all tr:outputXX items. Therefore, if you change the .AFDefaultFont:alias style, you will affect all components sharing this style selector.

  • Project Trinidad does not currently support component-level selectors for buttons. For example, you cannot customize a goButton differently from a commandButton. Skinning supports two very different button implementations. By default, standard browser buttons are used. However, the skinning also supports dynamic generation of image-based buttons. In order to enable image-based buttons, the following four button icons must be specified:
  1. .AFButtonStartIcon:alias
  2. .AFButtonEndIcon:alias
  3. .AFButtonTopBackgroundIcon:alias
  4. .AFButtonBottomBackgroundIcon:alias
When these four icons are specified, Project Trinidad combines the images specified by these icons into a single button image. (Note: These icons must be specified using either context-image or resource-image icons. Text-based icons are not allowed.)

To Create a Custom Skin
In most cases you will probably not customize the skin of every component available in project Trinidad's component library (there are after all 84 UI components). By reviewing your application using, for example, the Simple skin, you can determine what components to customize.

Note: At the moment the application developer can only extend, and inherit from, the Simple skin, but there is progress in the Apache Trinidad community to improve this, so that a skin can inherit from any custom skin. A skin consists of the following artifacts:

  • A CSS file that defines the actual look of the components
  • A configuration file - trinidad-skins.xml - that lists all skins available for this application (not including Minimal and Simple). This file has to be located in your applications WEB-INF directory
  • An entry in the Trinidad/ADF Faces configuration file - trinidad-config.xml. This file should also be located in the WEB-INF directory.
  • Any other resources need to create the actual look of the components - additional CSS files, Images etc...
Modifying the Trinidad Skin CSS
We are going to use an application that mimics the Apache MyFaces Website, so that we can illustrate how the skinning feature works and compare with the original (see Figure 1).

The hard part of providing a skin is not the actual creation of the Trinidad artifacts; it is creating the actual graphics and styles to be used by the application that is tedious. In this case we already have the above page as a foundation for the look and feel, which contains the styles and images needed. In the skin CSS file you can add any selectors that you wish to override, and set the properties as needed. You can set any properties as supported by the CSS specification. You can also create your own alias classes.

The application we have built is a standard JSF application using the Apache Trinidad's components with the Minimal skin (see Figure 2).

Changing the Color Scheme of a Skin
The easiest part of changing the look of your application is to change the base classes of a skin to use other colors. For example, the Simple skin looks Figure 3 without changes, and with some very minor changes to the following alias classes:

.AFDarkForeground:alias {color:#900000;}
.AFDarkBackground:alias {background-color:#333333;}

you can change the look and feel by changing the style classes controlling the base colors of the Simple skin (see Figure 4).

Adding a Skin to a Apache Trinidad Component
The components that we are going to provide a skin for are - tr:panelHeader, tr:panelSideBar, tr:navigationPane, and tr:inputDate. We are going to start with the tr:inputDate component. At the moment the tr:inputDate component looks like this with the Minimal Look and Feel:

Image 1

but we would like to change to look like this:

Image 2

To able to do this we need to add the component selector for the tr:inputDate component. By adding the following code to the skin CSS file (in this case we have named the file trinidadSkin.css), we can change the icon of the calendar launch button. Add the following af|selectInputDate style class code snippet to CSS file (note that in CSS the order of the style classes listed in the CSS file is important).

/** inputDate launch icon **/

af|inputDate::launch-icon {
    content:url(/skins/trinidad/skin_images/timedate_ena.png);
    width: 16px;
    height: 16px;
}
af|inputDate::launch-icon:rtl {
    content:url(/skins/trinidad/skin_images/timedate_ena.png);
    width: 16px;
    height: 16px;
}


More Stories By Kaazing Blog

Kaazing is helping define the future of the event-driven enterprise by accelerating the Web for the Internet of Things.

More Stories By John Fallows

John brings to Kaazing his 17 years’ experience in technology development and software design, and is considered a pioneer in the field of rich and highly interactive user interfaces. As CTO he formulates Kaazing Corporation’s vision of enabling mobile users, marketplaces and machines to connect and communicate in real-time, more reliably and at unprecedented scale. He defines the architecture of the Kaazing product suite and oversees its development. Prior to co-founding Kaazing, John served as Architect for Brane Corporation, a startup company based in Redwood City, California. Before joining Brane, he was a Consulting Member of Technical Staff for Server Technologies at Oracle Corporation. During his last five years at Oracle, he focused on designing, developing, and evolving Oracle ADF Faces to fully integrate Ajax technologies. Originally from Northern Ireland, he received his MA in Computer Science from Cambridge University in the United Kingdom and has written several articles for leading IT magazines such as Java Developer’s Journal, AjaxWorld Magazine, and JavaMagazine (DE), and is a popular speaker at international conferences. He is co-author of the bestselling book Pro JSF and Ajax: Building Rich Internet Components (Apress).

Comments (2) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
janet 12/14/06 03:46:23 PM EST

is the new skinning features going to allow for multiple skins for a component. Such as the selectOneTab. I want it to look two different ways(one flipped upside down and one right side up) but there seems to be no way to do this with the current ADF faces version.

JDJ News Desk 09/24/06 04:42:32 PM EDT

One of the 2006 Soccer World Cup highlights must surely be the Trinidad and Tobago versus Sweden game. The underdogs Trinidad and Tobago managed to push off the onslaught from the Swedish team. The game ended 0-0, which was for the people of Trinidad and Tobago a divine experience - their teams very first World Cup point!

@ThingsExpo Stories
Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, discussed how from store operations and ...
In his session at 21st Cloud Expo, Carl J. Levine, Senior Technical Evangelist for NS1, will objectively discuss how DNS is used to solve Digital Transformation challenges in large SaaS applications, CDNs, AdTech platforms, and other demanding use cases. Carl J. Levine is the Senior Technical Evangelist for NS1. A veteran of the Internet Infrastructure space, he has over a decade of experience with startups, networking protocols and Internet infrastructure, combined with the unique ability to it...
"There's plenty of bandwidth out there but it's never in the right place. So what Cedexis does is uses data to work out the best pathways to get data from the origin to the person who wants to get it," explained Simon Jones, Evangelist and Head of Marketing at Cedexis, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5–7, 2018, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buye...
"MobiDev is a software development company and we do complex, custom software development for everybody from entrepreneurs to large enterprises," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
SYS-CON Events announced today that Telecom Reseller has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.
WebRTC is great technology to build your own communication tools. It will be even more exciting experience it with advanced devices, such as a 360 Camera, 360 microphone, and a depth sensor camera. In his session at @ThingsExpo, Masashi Ganeko, a manager at INFOCOM Corporation, introduced two experimental projects from his team and what they learned from them. "Shotoku Tamago" uses the robot audition software HARK to track speakers in 360 video of a remote party. "Virtual Teleport" uses a multip...
Gemini is Yahoo’s native and search advertising platform. To ensure the quality of a complex distributed system that spans multiple products and components and across various desktop websites and mobile app and web experiences – both Yahoo owned and operated and third-party syndication (supply), with complex interaction with more than a billion users and numerous advertisers globally (demand) – it becomes imperative to automate a set of end-to-end tests 24x7 to detect bugs and regression. In th...
"Space Monkey by Vivent Smart Home is a product that is a distributed cloud-based edge storage network. Vivent Smart Home, our parent company, is a smart home provider that places a lot of hard drives across homes in North America," explained JT Olds, Director of Engineering, and Brandon Crowfeather, Product Manager, at Vivint Smart Home, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
"IBM is really all in on blockchain. We take a look at sort of the history of blockchain ledger technologies. It started out with bitcoin, Ethereum, and IBM evaluated these particular blockchain technologies and found they were anonymous and permissionless and that many companies were looking for permissioned blockchain," stated René Bostic, Technical VP of the IBM Cloud Unit in North America, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Conventi...
"Cloud Academy is an enterprise training platform for the cloud, specifically public clouds. We offer guided learning experiences on AWS, Azure, Google Cloud and all the surrounding methodologies and technologies that you need to know and your teams need to know in order to leverage the full benefits of the cloud," explained Alex Brower, VP of Marketing at Cloud Academy, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clar...
It is of utmost importance for the future success of WebRTC to ensure that interoperability is operational between web browsers and any WebRTC-compliant client. To be guaranteed as operational and effective, interoperability must be tested extensively by establishing WebRTC data and media connections between different web browsers running on different devices and operating systems. In his session at WebRTC Summit at @ThingsExpo, Dr. Alex Gouaillard, CEO and Founder of CoSMo Software, presented ...
A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, whic...
SYS-CON Events announced today that Evatronix will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Evatronix SA offers comprehensive solutions in the design and implementation of electronic systems, in CAD / CAM deployment, and also is a designer and manufacturer of advanced 3D scanners for professional applications.
Leading companies, from the Global Fortune 500 to the smallest companies, are adopting hybrid cloud as the path to business advantage. Hybrid cloud depends on cloud services and on-premises infrastructure working in unison. Successful implementations require new levels of data mobility, enabled by an automated and seamless flow across on-premises and cloud resources. In his general session at 21st Cloud Expo, Greg Tevis, an IBM Storage Software Technical Strategist and Customer Solution Architec...
To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
An increasing number of companies are creating products that combine data with analytical capabilities. Running interactive queries on Big Data requires complex architectures to store and query data effectively, typically involving data streams, an choosing efficient file format/database and multiple independent systems that are tied together through custom-engineered pipelines. In his session at @BigDataExpo at @ThingsExpo, Tomer Levi, a senior software engineer at Intel’s Advanced Analytics gr...
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things’). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing? IoT is not about the devices, it’s about the data consumed and generated. The devices are tools, mechanisms, conduits. In his session at Internet of Things at Cloud Expo | DXWor...
Everything run by electricity will eventually be connected to the Internet. Get ahead of the Internet of Things revolution. In his session at @ThingsExpo, Akvelon expert and IoT industry leader Sergey Grebnov provided an educational dive into the world of managing your home, workplace and all the devices they contain with the power of machine-based AI and intelligent Bot services for a completely streamlined experience.
SYS-CON Events announced today that Synametrics Technologies will exhibit at SYS-CON's 22nd International Cloud Expo®, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Synametrics Technologies is a privately held company based in Plainsboro, New Jersey that has been providing solutions for the developer community since 1997. Based on the success of its initial product offerings such as WinSQL, Xeams, SynaMan and Syncrify, Synametrics continues to create and hone inn...