Custom Facelets components and attributes defined in taglib
Asked Answered
P

3

8

Defining custom components in Facelets is easy and quick but there's one thing I can't figure out.

Is it possible with Facelets to define what attributes my custom component has? I.e: I've created a component which is used in such a way:

 <blue:modalWindow id="editFeesWizard" width="500" height="440" title="Wizard">

and is defined in taglib.xml as follows:

<!DOCTYPE facelet-taglib PUBLIC
        "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
        "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
<facelet-taglib>
    <namespace>...</namespace>
    <tag>
        <tag-name>modalWindow</tag-name>
        <source>components/modalWindow.xhtml</source>
    </tag>    
</facelet-taglib>

Taglib doesn't contain any information on component's attributes (id, width, height, title) and IDE cannot therefore check my syntax nor can it suggest attributes while I'm typing.

I cannot find anything on this subject in Facelets documentation. Thought you could help. Thanks!

Paniagua answered 8/4, 2010 at 6:41 Comment(0)
M
4

It seems there isn't a way. But even if there was, I don't think Eclipse (for example) would be able to handle it and offer autocomplete. That's why you can define a .tld, containing the attributes:

<?xml version="1.0" encoding="utf-8"?>

<taglib
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1">
......
</taglib>

Just for the sake of autocompletion. Ugly, I know.

Metonymy answered 8/4, 2010 at 7:57 Comment(0)
F
1

I don't know about before, but it is possible now. Just add:

<tag>
    <tag-name>mycustomtag</tag-name>
    <source>tags/mycustomtag.xhtml</source>
    <attribute>
        <description>What does this do?!</description>
        <name>attribute</name>
    </attribute>
</tag>
Faith answered 24/1, 2018 at 15:47 Comment(0)
I
0

I'm looking forward to being able to create composite components using JSF 2 and facelets; from what I've read, it seems very quick and easy, and you define what attributes your composite component accepts.

Isolt answered 9/4, 2010 at 22:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.