2

In my project I'm adding programmatically a composite component to a primefaces p:panel, as described here: How to programmatically or dynamically create a composite component in JSF 2 .

This is the composite component:

<?xml version="1.0" encoding="UTF-8"?>
<!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:p="http://primefaces.org/ui">

<composite:interface>

</composite:interface>

<composite:implementation>

   <h:panelGroup styleClass="ui-grid ui-grid-responsive"
    id="myPG" layout="block">

       <div class="ui-grid ui-grid-responsive label-777777">
        <div class="ui-grid-row">
            <div class="ui-grid-col-11-5">
                <label>#{msgs['label.content']}</label>
            </div>
        </div>
    </div>


    <p:commandButton styleClass="myButton blueButton"
        id="myCompositeButton" value="#{msgs['button.elimina']}"
        update="@form"
        actionListener="#{myController.onMyClick}" />
  </h:panelGroup>
</composite:implementation>
</html>

When added to the page, it show fine, but after the postback of the button, the "div" part, disappear (it isn't sent to the browser).

If I implements the div whith h:panelGroup and h:outputlabel, the elements get rendered but empty (#{msgs['label.content']} is void).

Here is the onMyClick handler (no logic in it):

public void onMyClick()
{
    System.out.println("#########################################CALLBAK");
}

Where I'm wrong?

Primefaces version is 5.1, running on JBoss AS 7.1.1

Community
  • 1
  • 1
Dan M
  • 315
  • 2
  • 14

1 Answers1

0

As I was having problem to programmatically create a component on the target architecture (IBM WAS 8.5, with myfaces 2.0 and no, I can't change jsf implementation), I changed the approach, using backing bean bound ui:include inside an h:panelGroup

<h:panelGroup id="myPanel" layout="block" rendered="#{myController.moduleSelected }">
   <ui:include src="#{myController.moduleType}"></ui:include>
</h:panelGroup>

Posting the answer to help other users

Dan M
  • 315
  • 2
  • 14