4

I wish to extend the following element:

<h:commandButton action="#{menuController.xyz}" value="xyz" 
     image="images/buttons/xyz.png" alt="xyz".....[more attributes]..../>

to include code to produce a depressed button:

<h:commandButton action="#{menuController.xyz}" value="xyz" 
     image="images/buttons/xyz.png" alt="xyz" 
     onmousedown="[some JS here to change image src]"
     .....[more attributes]..../>

I understand the neatest way to do this is with a JSF component? So I created the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:composite="http://java.sun.com/jsf/composite">
    <head>
        <title>Not present in rendered output</title>
    </head>
    <body>
        <composite:interface>
            <composite:attribute name="depressImage" required="false" />
        </composite:interface>

        <composite:implementation>
            <h:commandButton onmousedown="[some JS here to change the img src to the value of #{cc.attrs.depressImage}]" />
        </composite:implementation>
    </body>
</html>

My question is, without having to type all the possible attruibutes and map the EL is there a way to populate them automatically (for example the command button action and value etc.)?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Mark W
  • 5,824
  • 15
  • 59
  • 97

1 Answers1

4

Unfortunately no, there is no neat way to automagically inherit them this way. You'd really have to redefine them all. For a real custom component, you'd also have to do the same for the .taglib.xml file by the way, so this is not only a problem in composite components, but also in real custom components. Tag attributes do not support any form of inheritance.

Consider only redefining those which you absolutely need right now and add new ones on demand only.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555