Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF2 how to specify more than one custom element library in web.xml file

I have two custom components and I need to use them both on the same project. I know how to specify single component (tutorial: http://myjavabuddy.blogspot.com/2013/04/writing-custom-components-for-jsf-20.html) (web.xml):

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

<context-param>
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
    <param-value>/WEB-INF/marquee-taglib.xml</param-value>
</context-param>
</web-app>

As soon as I add another component (web.xml) the first element stops working:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

<context-param>
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
    <param-value>/WEB-INF/marquee-taglib.xml</param-value>
</context-param>

<context-param>
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
    <param-value>/WEB-INF/spinner-taglib.xml</param-value>
</context-param>
</web-app>

Doesn't work either:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

<context-param>
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
    <param-value>/WEB-INF/marquee-taglib.xml</param-value>
    <param-value>/WEB-INF/spinner-taglib.xml</param-value>
</context-param>
</web-app>

How can I specify two custom elements in the same web.xml file?

like image 800
Benas Avatar asked Aug 27 '13 08:08

Benas


1 Answers

Use the following:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

    <context-param>
        <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
        <param-value>/WEB-INF/marquee-taglib.xml;/WEB-INF/spinner-taglib.xml</param-value>
    </context-param>
</web-app>

If you use myFaces you can look here for what param-values the configuration parameters expect.

like image 85
user1983983 Avatar answered Oct 25 '22 08:10

user1983983