Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf PrimeFaces数据表复合组件默认值_Jsf_Jsf 2_Primefaces_Datatable_Composite Component - Fatal编程技术网

Jsf PrimeFaces数据表复合组件默认值

Jsf PrimeFaces数据表复合组件默认值,jsf,jsf-2,primefaces,datatable,composite-component,Jsf,Jsf 2,Primefaces,Datatable,Composite Component,我有下面的复合组件 <ui:component xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:cc="http://java.sun.com/jsf/composite" xmlns:ui="http://java.sun.com/jsf/facelets"

我有下面的复合组件

<ui:component xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:cc="http://java.sun.com/jsf/composite"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:p="http://primefaces.org/ui">

    <cc:interface>
        <cc:attribute name="rows" />
        <cc:attribute name="value"
            type="org.primefaces.model.LazyDataModel" />
        <cc:attribute name="var" />
        <cc:attribute name="id" />
        <cc:attribute name="rowStyle" default="false"/>
    </cc:interface>

    <cc:implementation>
        <p:dataTable value="#{cc.attrs.value}"
            rendered="#{not empty cc.attrs.value}" id="#{cc.attrs.id}"
            paginator="true" rows="25" 
            currentPageReportTemplate="Showing {startRecord}-{endRecord} of {totalRecords}"
            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
            rowsPerPageTemplate="25,50,100" paginatorPosition="bottom"
            lazy="true" rowStyleClass="#{cc.attrs.rowStyle}">
             <c:set target="#{component}" property="var" value="#{cc.attrs.var}"/>
            <cc:insertChildren />
        </p:dataTable>
    </cc:implementation>
</ui:component> 

我的要求是: 在少数情况下,我将传递rowStyle的值,否则如果未传递该值,则应采用默认值

我已经在我的复合组件中添加了以下行

<cc:attribute name="rowStyle" default="false"/>


但它不起作用。为什么?

我认为您需要在默认值中输入实际的CSS类名


因此,默认值不是真/假标志,而是带有实际值的字段。

请记住,
default
属性用于处理属性未通过的情况,而不是属性为空的情况

因此,考虑到这个接口:

<cc:interface>
    <cc:attribute name="monkey" />
    <cc:attribute name="food" default="banana" />
</cc:interface>
但是,如果
myFood
null
并且我这样调用它:

<barrel monkey="Bonzo" food="#{myFood}" />

然后
food
的值将为
null

<barrel monkey="Bonzo" food="#{myFood}" />