jsf-2 - 动态渲染 - 无法找到具有 clientId 的组件

标签 jsf-2 primefaces

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

使用 PrimeFaces 5.1、JSF 2.1 Mojarra 和 tomcat 7。

当我单击弹出窗口的关闭按钮时,在 Eclipse 控制台中会看到大量无法找到该组件的情况,因此关闭操作响应缓慢。

尝试将 myForm 上的 prependId 更改为 true。还尝试将关闭按钮的 update 属性中的 @form 替换为 :myForm。 这两种方法都没有成功。

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

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);

最佳答案

找到了这个问题的解决方案...要修复“无法找到带有 clientId 'tab:j_id16:sec_4' 的组件,无需删除它。”,我们必须将 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

关于jsf-2 - 动态渲染 - 无法找到具有 clientId 的组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30778214/

相关文章:

java - JSF 不更新变量

java - primefaces 默认 css 主题被自定义模板覆盖

javascript - Primefaces datePicker范围过滤器结束日期问题

redirect - 显示成功消息,然后在超时后使用PageFlow重定向到另一个页面

css - 如何更改 treeNode 背景图片

jsf - 如何在操作方法期间更新的 PrimeFaces oncomplete 属性中使用 EL

jsf-2 - 数据表更新后,Primefaces 数据表在过滤器字段中丢失文本

java - Icefaces 性能问题 - 部分提交

java - 未能成功地将参数从 primefaces 页面发送到 java bean 类

jsf - Primefaces文件下载不起作用?