动态呈现 - 无法找到具有 clientId 的组件

Dynamic rendering - unable to find component with clientId

我正在将 xhtml 渲染到一个对话框,其组件是使用 Dynamic example 从服务器端动态添加的。

使用 PrimeFaces 5.1、JSF 2.1 Mojarra 和 tomcat7.

当我单击关闭按钮时弹出大量无法找到组件的 Eclipse 控制台,因此关闭操作响应缓慢。

尝试将 myForm 上的 prependId 更改为 true。还尝试用 替换 关闭按钮的 @form 属性中的 @form:我的表格。 两种方法都不成功。

我想知道如何防止无法找到组件被触发。

Unable to find component with clientId editOwnerForm:tab:j_id16:iq_16_panelGroup2', no need to remove it.

Unable to find component with clientId 'editOwnerForm:tab:j_id16:j_id235', no need to remove it. Unable to find component with clientId 'editOwnerForm:tab:j_id16:j_id236', no need to remove it. Unable to find component with clientId 'editOwnerForm:tab:j_id16:j_id237', no need to remove it. Unable to find component with clientId 'editOwnerForm:tab:j_id16:j_id238', no need to remove it. Unable to find component with clientId 'editOwnerForm:tab:j_id16:j_id239', no need to remove it. Unable to find component with clientId 'editOwnerForm:tab:j_id16:j_id240', no need to remove it. Unable to find component with clientId 'editOwnerForm:tab:j_id16:j_id241', no need to remove it. Unable to find component with clientId 'editOwnerForm:tab:j_id16:j_id242', no need to remove it. Unable to find component with clientId 'editOwnerForm:tab:j_id16:j_id243', no need to remove it. Unable to find component with clientId editOwnerForm:tab:j_id16:iq_17_225', no need to remove it. Unable to find component with clientId 'editOwnerForm:tab:j_id16:iq_17_panelGroup2', no need to remove it.

myForm.xhtml

<h:form prependId="false" id="form">
    <p:commandButton id="editOwnerButtonId" oncomplete="PF('editOwnerDlgVar').show();"
    actionListener="#{myViewBean.editOwner}"
    update=":editOwnerForm" icon="ui-icon-pencil"
    iconPos="right">
    <f:param name="ownerId"
            value="#{myViewBean.id}" />
     </p:commandButton>
</h:form>

<p:dialog id="editOwnerDlgId" widgetVar="editOwnerDlgVar"
    modal="true" closable="true" width="1200px" height="600" >
    <ui:include src="ownerEdit.xhtml" />
</p:dialog>

ownerEdit.xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
    lang="en" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:shiro="http://shiro.apache.org/tags">

     <h:form prependId="true" id="editOwnerForm">
        <p:tabView id="tab" style="border-width:0px;"
        activeIndex="#{myViewBean.tanIndex}">
               <p:tab >

               </p:tab >
           <p:tab id="dynamicResponse" title="Dynamic Response">
            <h:panelGroup id="sections"
                binding="#{myViewBean.panelGroup}">
            </h:panelGroup>
        </p:tab>
    </p:tabView>

    <p:commandButton value="Close" update=":form" id="cancelButton"
        immediate="true"
        actionListener="#{myViewBean.cancelOwner}"
        icon="ui-icon ui-icon-arrowreturn-1-w" iconPos="right">
        <p:ajax listener="#{myViewBean.setTabIndex}" />
    </p:commandButton>
  </h:form>
</ui:composition>

MyViewBean 动态呈现代码 - 在单击编辑按钮时触发

HtmlPanelGroup panelGroup = new HtmlPanelGroup();
panelGroup.getChildren().clear();
TabView tabView = new TabView();
Tab sectionTab = (Tab) tabView.findComponent("sec_" + question.getSectionId());
sectionTab.setId("sec_" + question.getSectionId());
sectionTab.setTitle(question.getSectionName());

HtmlPanelGrid pg = new HtmlPanelGrid();
pg.setColumns(3);

OutputLabel questionText = new OutputLabel();
questionText.setValue(question.getTitle());
pg.getChildren().add(questionText);

OutputLabel coln1 = new OutputLabel();
coln1.setValue(":");
pg.getChildren().add(coln1);

final String respBind = "#{myViewBean.questionResponse[\""+ question.getId()+ "_"+ pet.getId()+ "_"+ question.getMultiPet() + "\"]}";
final ValueExpression resp = FacesContext.getCurrentInstance().getApplication()
                                .getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), respBind,   String.class);
InputText value = new InputText();
value.setId("iq_"+ String.valueOf(question.getId()) + "_"+ String.valueOf(pet.getId()));
value.setSize(20);
value.setValueExpression("value", resp);

pg.getChildren().add(value);

sectionTab.getChildren().clear();
sectionTab.getChildren().add(pg);
tabView.getChildren().add(sectionTab);
panelGroup.getChildren().add(tabView);

已解决此问题...要解决 "Unable to find component with clientId 'tab:j_id16:sec_4', no need to remove it.",我们必须将 jsf jar 从 2.1.7 更新到 2.1.9 或 2.1.29。 在下面的链接中,这被报告为 Mojarra 的一个问题。

查看链接 http://forum.primefaces.org/viewtopic.php?f=3&t=22880
https://java.net/jira/browse/JAVASERVERFACES-2383
https://java.net/jira/secure/ReleaseNote.jspa?projectId=10204&version=15535