Вопрос

I am trying to create a custom tag that will act as a wrapper to standard components and will define values for some common attributes

For example the custom tag will look like this

<ui:component xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jstl/core">

   <rich:datascroller fastControls="false" fastStep="false" maxPages="20" id="#{value}"/>

</ui:component>

Then i will be able to use this tag every time i need a datascroller component like

<my:dataTable id="componentId"/>

My question is whether i can provide my custom tag with attributes that will be "transfered" to the jsf component without specifying each one explicitly. For example consider the following use of my custom component

<my:dataTable id="componentId" pagesVar="books" stepControls="true"/>

and this one

<my:dataTable id="componentId" pagesVar="items" renderIfSinglePage="false"/>

Attributes pagesVar, stepControls, renderIfSinglePage should be passed to the rich:datascroller component. I know i can do something like this

<rich:datascroller pagesVar=#{pagesVar ? pagesVar : ''} stepControls=#{stepControls ? true: false}/>

but i am wondering if there is a way to pass all attributes without specifying each one of them

Это было полезно?

Решение

but i am wondering if there is a way to pass all attributes without specifying each one of them

No, tag attributes does not support any form of inheritance.

You can however simplify your particular example more.

<rich:datascroller pagesVar="#{pagesVar}" stepControls="#{stepControls}" />
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top