JSF/Facelets component using bindings
I'm creating a simple JSF/Facelets component, useful to specify time intervals:
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:t="http://myfaces.apache.org/tomahawk"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:jstl="http://java.sun.com/jsp/jstl/functions" version="2.0">
<ui:component>
<h:panelGrid columns="2" cellpadding="2">
<rich:inputNumberSpinner value="#{durationBean.duration}"/>
<h:selectOneMenu value="#{durationBean.unit}">
<f:selectItem itemValue="sec" itemLabel="Second/s"/>
<f:selectItem itemValue="min" itemLabel="Minute/s"/>
<f:selectItem itemValue="hou" itemLabel="Hour/s"/>
<f:selectItem itemValue="day" itemLabel="Day/s"/>
</h:selectOneMenu>
</h:panelGrid>
</ui:component>
</jsp:root>
I want to use this tag as:
<time:interval value="#{myBean.intervalInMilliseconds}"/>
So the component itself converts the units and return the value in ms.
The problem is that, using Facelets for this, the expression value="#{myBean.intervalInMilliseconds}"
is evaluated in the <ui:component>
section, so I can't pass the value expression as is.
How can create custom components 开发者_C百科without having to do with tag/attributes writing (plain JSF components) but using Facelets and dealing with input/output expressions?
精彩评论