A shopping application that displays multiple items on
a page might have a custom thumbnail item renderer with two view
states. In one view state, the item cell might look the following
image:
When the user rolls the mouse over the item, the view state changes:
the thumbnail no longer has the availability and rating information,
but now has buttons that let the user get more information or add
the item to the wish list or cart. In the new state, the cell also
has a border and a drop shadow, as the following image shows:
In this example, the application item renderer’s two view states
have different child components and have different component styles.
The summary state, for example, includes an availability label and
a star rating image, and has no border. The rolled-over state replaces
the label and rating components with three buttons, and has an outset
border.
Example: Using view states with a custom item renderer
The following
code shows an application that uses a custom item renderer to display
catalog items. When the user moves the mouse over an item, the item renderer
changes to a state where the picture is slightly enlarged, the price appears
in the cell, and a text box shows a message about the item. All
changes are made by the item renderer’s state, including the change
in the parent application.