Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Facelets components and attributes defined in taglib

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!

like image 587
mgamer Avatar asked Apr 08 '10 06:04

mgamer


1 Answers

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.

like image 89
Bozho Avatar answered Oct 04 '22 22:10

Bozho