以编程方式加载的复合在回发后消失元素

时间:2015-10-06 17:17:42

标签: jsf postback composite-component programmatically-created

在我的项目中,我以编程方式将复合组件添加到primefaces p:面板,如下所述:How to programmatically or dynamically create a composite component in JSF 2

这是复合组件:

<?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>

当添加到页面时,它显示正常,但在按钮的回发后,&#34; div&#34;部分,消失(它不会被发送到浏览器)。

如果我实现div whith h:panelGroup和h:outputlabel,则元素会被渲染但是空(#{msgs [&#39; label.content&#39;]}无效。)

这是onMyClick处理程序(其中没有逻辑):

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

我哪里错了?

Primefaces版本为5.1,在JBoss AS 7.1.1上运行

1 个答案:

答案 0 :(得分:0)

由于我在编程上在目标体系结构上创建组件时遇到问题(IBM WAS 8.5,myfaces 2.0并且没有,我无法更改jsf实现),我改变了方法,使用支持bean绑定ui:include inside一个h:panelGroup

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

发布答案以帮助其他用户