使用CombinedResourceHandler出现“由于无法找到UIComponent而无法使用clientId'j_idX'保存动态操作的警告”

问题描述 投票:0回答:1

当我提交并更新=“ @ form”时,一次收到以下警告。

14:03:23,139 WARNING [javax.enterprise.resource.webcontainer.jsf.application.view] (default task-27) Unable to save dynamic action with clientId 'j_id2' because the UIComponent cannot be found
14:03:23,139 WARNING [javax.enterprise.resource.webcontainer.jsf.application.view] (default task-27) Unable to save dynamic action with clientId 'j_id3' because the UIComponent cannot be found

但是从faces-config.xml中删除“ org.omnifaces.resourcehandler.CombinedResourceHandler”,警告没有得到。

发展环境是...

  • Primefaces 7.0
  • Omnifaces 3.4
  • WildFly 16.0.0.Final

这里是最少的示例。(但是我的生产代码更复杂,因此警告很多(20-1000)。)

index.xhtml

<?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://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">
<h:head></h:head>
<f:metadata><f:viewAction action="#{indexView.init()}"/></f:metadata>
<h:body>
    <h:form id="mainForm">
        <p:messages id="messages"/>
        <p:panelGrid id="panelGrid" columns="3" layout="grid">
            <p:outputLabel id="labelInput1" for="@next" value="input"/>
            <p:selectOneMenu id="input" value="#{indexView.selectOne}">
                <f:selectItems value="#{indexView.itemCandidates}" var="i" itemLabel="#{i}" itemValue="#{i}"/>
            </p:selectOneMenu>
            <p:commandButton id="btn" value="submit" process="panelGrid" update="@form" actionListener="#{indexView.submit}"/>
        </p:panelGrid>
    </h:form>
</h:body>
</html>

IndexView.java

package com.sample.primafaces_operation_verification;

import javax.faces.view.ViewScoped;
import // omitted // ;

@Named
@ViewScoped
public class IndexView implements Serializable {

    @Getter
    private List<String> itemCandidates;

    @Getter @Setter
    private String selectOne;

    public void init() {
        this.itemCandidates = List.of("aaa", "bbb", "ccc", "ddd");
    }

    public void submit() {
        Messages.addGlobalInfo("Selected item : {0}", selectOne);
    }
}

faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
              version="2.0">
    <application>
        <resource-handler>org.omnifaces.resourcehandler.CombinedResourceHandler</resource-handler>
        <action-listener>org.primefaces.application.DialogActionListener</action-listener>
        <navigation-handler>org.primefaces.application.DialogNavigationHandler</navigation-handler>
        <view-handler>org.primefaces.application.DialogViewHandler</view-handler>
    </application>
</faces-config>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
        <param-value>0</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.CLIENT_SIDE_VALIDATION</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.FONT_AWESOME</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.MOVE_SCRIPTS_TO_BOTTOM</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>com.sun.faces.numberOfLogicalViews</param-name>
        <param-value>6</param-value>
    </context-param>
    <context-param>
        <param-name>com.sun.faces.numberOfViewsInSession</param-name>
        <param-value>6</param-value>
    </context-param>
    <context-param>
        <param-name>org.omnifaces.VIEW_SCOPE_MANAGER_MAX_ACTIVE_VIEW_SCOPES</param-name>
        <param-value>6</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>index.faces</welcome-file>
    </welcome-file-list>
</web-app>

我希望不会收到警告。我该如何解决?

jsf primefaces jsf-2 omnifaces
1个回答
1
投票

我发现了该警告的多个参考文献,但没有一个值得一提的重复文献,值得重复以结束您的问题,因此,我将尝试通过引文进行回答:

PrimeFaces nested form inside p:dialog with appendTo="@(body)

Michele Mariotti说:

对于我的实验,这些警告是无害的,可以安全地忽略。但是我打开了a pull request来修复它。这些就我的实验而言,警告是无害的并且可以安全地进行忽略。


BootsFaces issue 325 Unable to save dynamic action with clientId 'j_id...'

stephanrauh于2016年3月22日发表评论]

这是警告,不是错误。将ProjectStage设置为生产后,警告就消失了。所以我认为这是一个小麻烦,不是一个严重的错误。无论如何,您是否在不使用OmniFaces的情况下得到警告?

stephanrauh于2016年3月22日发表评论]

不太可能。当您使用错误的API操作JSF DOM树时,将发生警告。例如,通过简单地从列表中删除资源文件来删除它。这就是OmniFaces在早期版本中所做的。 JSF检测到某些东西丢失了,变得紧张起来,并做出了相应的反应,忽略了这些令人困惑的警告。 BootsFaces可能会使用“禁止” API,但我相信已经解决了该问题。无论如何,您可以上传一个简单的项目来重现警告吗?这使我们的工作更加轻松。


总结通过org.omnifaces.resourcehandler.CombinedResourceHandler从视图中删除资源(这是其核心功能的一部分)来触发警告。尝试将javax.faces.PROJECT_STAGE设置为Production,并在编码时输入警告。

© www.soinside.com 2019 - 2024. All rights reserved.