2
votes

I have a problem with my composite component in JSF2. I implement a list using ui and li. But if I use my component nothing happens. My list-tag is not replaced in code generated by facelet. So whats wrong with this.

The composite component is stored under /resources/util/list.xhtml. Here is the code:

<!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"
      xmlns:ui="http://java.sun.com/jsf/facelets">
<head><title>(For validation only)</title></head>
<body>
<composite:interface>
    <composite:attribute name="values"/>
    <composite:attribute name="listStyle"/>
    <composite:attribute name="elementStyle"/>
</composite:interface>
<composite:implementation>
<ul class="#{cc.attrs.listStyle}">
<ui:repeat var="element" value="#{cc.attrs.values}">
    <li class="#{cc.attrs.elementStyle}">#{element}</li>
</ui:repeat>
</ul>
</composite:implementation>
</body></html>

I use my tag this way

<!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:ui="http://java.sun.com/jsf/facelets"
    xmlns:core="http://java.sun.com/jsf/core"
    xmlns:utils="http://http://java.sun.com/jsf/composite/utils">
  <h:head>
    <title>Show user Color</title>
    <style type="text/css">
      .elements { font-style: italic; }
      .list { margin: 0px; padding:0px;}
    </style>

  </h:head>
  <h:body>
    <h1>Show Color</h1>
    <p>User selected: #{ColorBean.selectedColor}</p>
    <p>User set hex: #{ColorBean.showHex == true? "yes": "no"}</p>
    <p><h:outputFormat value="#{msgs.hexNotification}"
                    rendered="#{ColorBean.showHex}">
         <core:param value='#{ColorBean.showHex == true? "yes": "no"}' />
       </h:outputFormat>
    </p>
    <fieldset><legend>Colors</legend>
      <utils:list values="#{ColorBean.colors}" listStyle="list" elementStyle="elements"/>
    </fieldset>
  </h:body>
</html>

Here is the generated code.

<!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:utils="http://http://java.sun.com/jsf/composite/utils"><head>
    <title>Show user Color</title>
    <style type="text/css">
      .elements { font-style: italic; }
      .list { margin: 0px; padding:0px;}
    </style></head><body>
    <h1>Show Color</h1>
    <p>User selected: green</p>
    <p>User set hex: no</p>

    <p>
    </p>
    <fieldset><legend>Colors</legend>
      <utils:list values="[Ljava.lang.String;@13e86ec" listStyle="list" elementStyle="elements"></utils:list>
    </fieldset><div id="javax_faces_developmentstage_messages"></div></body>
</html>

What is wrong here. I use an tutorial to build this code.
http://courses.coreservlets.com/Course-Materials/pdf/jsf/jsf2/JSF2-Looping.pdf
They did a similar example on the last pages.

I hope you can help me

Thanks

1

1 Answers

1
votes

Change your

xmlns:utils="http://http://java.sun.com/jsf/composite/utils">

to

xmlns:utils="http://java.sun.com/jsf/composite/utils">

Regs, Rob