gpt4 book ai didi

jsf - "Unable to save dynamic action with clientId ' j_idX' 的警告因为找不到 UIComponent"发生,使用 CombinedResourceHandler

转载 作者:行者123 更新时间:2023-12-02 03:06:57 30 4
gpt4 key购买 nike

当我提交和更新=“@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>

我希望不会收到警告。我该如何修复它?

最佳答案

我发现了几个对此警告的引用,但没有重复的 SO 值得投票以将您的问题作为重复的问题关闭,因此我将尝试通过引用来回答:

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

Michele Mariotti 说:

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 检测到缺少某些东西,变得紧张并通过忽略这些令人困惑的警告来使用react。 BootsFaces 可能使用了“禁止的”API,但我相信已经解决了这个问题。无论如何,你能上传一个重现警告的简单项目吗?这使我们的工作变得更加轻松。


总结 警告是由 org.omnifaces.resourcehandler.CombinedResourceHandler 从 View 中删除资源触发的,这是其核心功能的一部分。尝试将 javax.faces.PROJECT_STAGE 设置为 Production 并在编码时忽略警告。

关于jsf - "Unable to save dynamic action with clientId ' j_idX' 的警告因为找不到 UIComponent"发生,使用 CombinedResourceHandler,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58742500/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com