0

I am watching this wiki info concerning the composite components; Here is the snippet :

package com.example;

import javax.faces.component.FacesComponent;
import javax.faces.component.UINamingContainer;

@FacesComponent("ratingComponent")
public class RatingComponent extends UINamingContainer {

    public Object[] getItems() {
        Object totalStars = getAttributes().get("totalStars");
        int size = Integer.valueOf(String.valueOf(totalStars));
        return new Object[size];
    }

}

And then it's usage :

<h:dataTable value="#{bean.products}" var="product">
    <h:column>#{product.name}</h:column>
    <h:column><my:rating score="#{product.rating}" /></h:column>
</h:dataTable>

the taglib.xml (I am testing with) ...

<tag>
   <tag-name>rating</tag-name> 
   <component>
     <component-type>ratingComponent</component-type>
   </component>
</tag>

...

I am just wondering how to make my:rating tag be able to contain <ui:insert/> which should make possible to use my:rating in this way :

<my:rating score="#{product.rating}" >
  <h:panelGrid border="1" columns="1" layout="block">
     <h:panelGroup><label value="Lovely stars"/></h:panelGroup>
      etc...
  </h:panelGrid>
</my:rating>

So my question is... if component is the composite one how to make it insert-able?

Thanks

Community
  • 1
  • 1
cbhogf
  • 91
  • 13
  • Advice: get terminology and separate concepts right based on http://stackoverflow.com/q/6822000. Do note that a composite doesn't require a taglib file at all. – BalusC Jul 30 '16 at 19:58
  • @BalusC No, I am interested in converting the composite into tag for possible lib packing :S Is there a way to make UIComponent insert-able or if it is it can be insert-able or if it is it should use add() way only? I mean how to combine static and dynamic components? – cbhogf Aug 02 '16 at 14:55
  • If model is static during the view scope: http://stackoverflow.com/q/3510614 If model is dynamic during the view scope: http://stackoverflow.com/q/3409053 – BalusC Aug 02 '16 at 15:19

0 Answers0