Java Magazine, Jan/Feb 2016
ORACLE COM JAVAMAGAZINE JANUARY FEBRUARY 2016 28 web apps This will be rendered as expected but if we select and submit a Player string representation then an error will occur This is a conversion error indicating that JSF cannot automatically convert the submitted string into the selection This generates the message Player Conversion Error setting value 3 ANDY MURRAY London 27 for null Converter Normally at this point you must write a custom converter especially for this case only but OmniFaces provides a general custom converter named SelectItems IndexConverter Once you specify this converter via omnifaces SelectItemsIndexConverter it automatically converts the submitted strings into the corresponding values objects h selectOneMenu id atp value playerBean selected converter omnifaces SelectItemsIndexConverter h selectOneMenu Its simple to use isnt it In addition OmniFaces provides an alternative to this approach which converts the submitted strings to corresponding values based on the toString implementation of those values This converter uses the ID omnifaces SelectItemsConverter Provide full control over the markup of a tree hierarchy by declaring the appropriate JSF components or HTML elements in the markup By default JSF does not provide any built in artifacts dedicated to exposing or controlling the markup in a hierarchical tree structure but such components are quite popular among JSF developers The OmniFaces tree component provides a powerful and extremely versatile hierarchical tree structure solution that can be obtained via a TreeModel with default implementations ListTreeModel and SortedTreeModel and four tags the main one o tree which encapsulates the entire tree structure o treeNode a single tree node within a parent o tree o treeNodeItem a single child tree node within a parent o treeNode and o treeInsertChildren which indicates the place to insert the children of the current child tree node recursively by an o treeNode associated with the childrens level in the same parent o tree Lets see a simple example and lets start with the model TreeBean uses ListTreeModel which is a TreeModel implementation that holds the tree children in an ArrayList @ Named @ ViewScoped public class TreeBean implements Serializable private static final long serialVersionUID 1L private TreeModel String tree @ PostConstruct public void init tree new ListTreeModel tree addChild Components Showcase addChild OutputFamily addChild ResourceInclude addChild example 1 addChild source code getParent getParent addChild example 2 addChild source code getParent getParent getParent addChild Conditional Comment addChild getParent getParent getParent addChild UtilFamily addChild MoveComponent getParent addChild
You must have JavaScript enabled to view digital editions.