Putting JSF composite components in a subfolder based hierarchy

折月煮酒 提交于 2020-01-05 07:17:15

问题


I'm roughly following this guide for creating composite components in JSF 2.2. I've managed to define and use a component, but I'm having problems properly organizing the components. In all tutorials the components are put into one directory and the files' names define the tag name.

META-INF/resources/ts
                   +-plainbox.xhtml
                   +-showcasebox.xhtml

I'd prefer having categories and a directory for each element, with bundled JS, CSS and images. I'd like to use a structure like this:

META-INF/resources/ts
                   +-containers
                   |  +-plainbox
                   |  |  +-plainbox.xhtml
                   |  |  +-plainbox.css
                   |  +-showcasebox
                   |     +-showcasebox.xhtml
                   |     +-showcasebox.js
                   +-otherstuff
                      +-...

Unfortunately, when using this structure I need to reference each component by an own namespace:

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:jsf="http://xmlns.jcp.org/jsf"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:ts="http://java.sun.com/jsf/composite/ts/containers/showcasebox"
    xmlns:ts2="http://java.sun.com/jsf/composite/ts/containers/plainbox">
<head jsf:id="head">
</head>
    <body>
        <ts:showcasebox>hello world</ts:showcasebox>
        <ts2:plainbox>foo bar</ts2:plainbox>
    </body>
</html>

Having to reference the categories one by one would be okay, but having a new namespace for each component is unbearable. Also I've read that this nesting is against the specification.

Is it possible to have a hierarchy of composite components in JSF with only one namespace? How are frameworks like Primefaces doing it? Are they defining all elements in Java?

来源:https://stackoverflow.com/questions/39537911/putting-jsf-composite-components-in-a-subfolder-based-hierarchy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!