使用 CombinedResourceHandler 出现 "Unable to save dynamic action with clientId 'j_idX' because the UIComponent cannot be found" 的警告
The warning of "Unable to save dynamic action with clientId 'j_idX' because the UIComponent cannot be found" occur, with using CombinedResourceHandler
当我提交和 update="@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
- 野蝇 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);
}
}
人脸-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>
我预计不会收到警告。
我该如何修复它?
我发现了几个对这个警告的引用,但没有重复的所以值得投票将你的问题作为重复来关闭,所以我会尝试通过引用来回答:
PrimeFaces nested form inside p:dialog with appendTo="@(body)
米歇尔·马里奥蒂 说:
These warnings, as for my experiments, are harmless and could be safely ignored.
However I opened a pull request to eventually fix it.
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 可能使用 "forbidden" API,但我相信已经解决了这个问题。无论如何,你能上传一个重现警告的简单项目吗?这让我们的工作变得轻松多了。
总而言之 警告是由 org.omnifaces.resourcehandler.CombinedResourceHandler
从视图中删除资源触发的,这是其核心功能的一部分。尝试将 javax.faces.PROJECT_STAGE
设置为 Production
并在编码时忽略警告。
当我提交和 update="@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
- 野蝇 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);
}
}
人脸-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>
我预计不会收到警告。 我该如何修复它?
我发现了几个对这个警告的引用,但没有重复的所以值得投票将你的问题作为重复来关闭,所以我会尝试通过引用来回答:
PrimeFaces nested form inside p:dialog with appendTo="@(body)
米歇尔·马里奥蒂 说:
These warnings, as for my experiments, are harmless and could be safely ignored. However I opened a pull request to eventually fix it.
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 可能使用 "forbidden" API,但我相信已经解决了这个问题。无论如何,你能上传一个重现警告的简单项目吗?这让我们的工作变得轻松多了。
总而言之 警告是由 org.omnifaces.resourcehandler.CombinedResourceHandler
从视图中删除资源触发的,这是其核心功能的一部分。尝试将 javax.faces.PROJECT_STAGE
设置为 Production
并在编码时忽略警告。