使用绑定的JSF / Facelets组件

时间:2011-05-13 15:31:12

标签: jsf components facelets el

我正在创建一个简单的JSF / Facelets组件,用于指定时间间隔:

<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>

我想将此标记用作:

<time:interval value="#{myBean.intervalInMilliseconds}"/>

因此组件本身会转换单位并以毫秒为单位返回值。 问题是,为此使用Facelets,表达式value="#{myBean.intervalInMilliseconds}"<ui:component>部分中进行计算,因此我无法按原样传递值表达式。 如何在不使用标记/属性编写(普通JSF组件)但使用Facelets和处理输入/输出表达式的情况下创建自定义组件?

0 个答案:

没有答案