openfaces 树表缺少 js

发布于 2024-12-25 04:23:24 字数 1592 浏览 5 评论 0原文

当尝试将 RichFaces 与 OpenFaces 合并到树表中时,它不显示任何展开折叠按钮。原来是部分js没有加载,可能是这个原因。

JSF 代码如下:

<o:treeTable var="o">
                        <o:dynamicTreeStructure nodeChildren="#{bean.originNodeChildren}"
                                                nodeHasChildren="#{bean.originHasChildren()}"/>
                        <o:treeColumn expandedToggleImageUrl="/img/toggle-expand-light.png"
                                      collapsedToggleImageUrl="img/toggle-collapse-light.png">
                            <h:outputText value="#{o.description}"/>
                        </o:treeColumn>
                    </o:treeTable>

Bean 代码被正确触发(包括 hasChildren 方法)。

JS 例外:

Failed to load resource: the server responded with a status of 404 (/openFacesResources/META-INF/resources/openfaces/util/ajaxUtil-2.1.EA1.1143.js)
Failed to load resource: the server responded with a status of 404 (/openFacesResources/META-INF/resources/openfaces/util/util-2.1.EA1.1143.js)
Failed to load resource: the server responded with a status of 404 (/openFacesResources/META-INF/resources/openfaces/tableUtil-2.1.EA1.1143.js)
Failed to load resource: the server responded with a status of 404 (/openFacesResources/META-INF/resources/openfaces/table/table-2.1.EA1.1143.js)
Failed to load resource: the server responded with a status of 404 (/openFacesResources/META-INF/resources/openfaces/table/treeTable-2.1.EA1.1143.js)

使用 OpenFaces 2.0 版和 RichFaces 3.3.3 版。

While trying to incorporate RichFaces with OpenFaces in a tree table, and it doesn't display any expand collapse buttons. It turned out that some of the js are not loaded, which might be the cause of it.

JSF code is as follows:

<o:treeTable var="o">
                        <o:dynamicTreeStructure nodeChildren="#{bean.originNodeChildren}"
                                                nodeHasChildren="#{bean.originHasChildren()}"/>
                        <o:treeColumn expandedToggleImageUrl="/img/toggle-expand-light.png"
                                      collapsedToggleImageUrl="img/toggle-collapse-light.png">
                            <h:outputText value="#{o.description}"/>
                        </o:treeColumn>
                    </o:treeTable>

Bean code is being triggered correctly (including hasChildren method).

JS exceptions:

Failed to load resource: the server responded with a status of 404 (/openFacesResources/META-INF/resources/openfaces/util/ajaxUtil-2.1.EA1.1143.js)
Failed to load resource: the server responded with a status of 404 (/openFacesResources/META-INF/resources/openfaces/util/util-2.1.EA1.1143.js)
Failed to load resource: the server responded with a status of 404 (/openFacesResources/META-INF/resources/openfaces/tableUtil-2.1.EA1.1143.js)
Failed to load resource: the server responded with a status of 404 (/openFacesResources/META-INF/resources/openfaces/table/table-2.1.EA1.1143.js)
Failed to load resource: the server responded with a status of 404 (/openFacesResources/META-INF/resources/openfaces/table/treeTable-2.1.EA1.1143.js)

Using OpenFaces version 2.0 and RichFaces version 3.3.3.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风月客 2025-01-01 04:23:24

需要在 web.xml 中为开放面配置资源过滤器,工作就完成了。像这样的东西:

public class OpenFacesResourceFilter extends ResourceFilter {
    // -- Fields --

    // -- Methods --
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        try{
            super.doFilter(servletRequest, servletResponse, filterChain);
        } catch (ServletException e) {
            Throwable parent = e.getCause();
            if(parent!=null && parent instanceof ServletException) {
                throw (ServletException) parent;
            } else {
                throw e;
            }
        }
    }
}

It is needed to configure resource filter for open faces in web.xml and the job is done. Something like:

public class OpenFacesResourceFilter extends ResourceFilter {
    // -- Fields --

    // -- Methods --
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        try{
            super.doFilter(servletRequest, servletResponse, filterChain);
        } catch (ServletException e) {
            Throwable parent = e.getCause();
            if(parent!=null && parent instanceof ServletException) {
                throw (ServletException) parent;
            } else {
                throw e;
            }
        }
    }
}
情丝乱 2025-01-01 04:23:24

看来您确实没有在应用程序的 xml 文件中声明 OpenFaces 资源过滤器。以下是有关如何声明过滤器的文档摘录(请注意,您不必自己为此过滤器创建任何 Java 类):

  <!-- FILTER FOR PROCESSING INTERNAL OPENFACES RESOURCES -->
  <filter>
    <filter-name>ResourceFilter</filter-name>
    <filter-class>org.openfaces.util.ResourceFilter</filter-class>
  </filter>

  <!-- MAPPING FOR OPENFACES RESOURCE FILTER -->
  <filter-mapping>
    <filter-name>ResourceFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

请参阅 安装 部分,以及 OpenFaces 2.0 中的资源过滤器优化部分文档。

This looks like you have not declared the OpenFaces resource filter in the application's xml file indeed. Here's an excerpt from documentation on how a filter can be declared (note that you don't have to create any Java classes for this filter yourself):

  <!-- FILTER FOR PROCESSING INTERNAL OPENFACES RESOURCES -->
  <filter>
    <filter-name>ResourceFilter</filter-name>
    <filter-class>org.openfaces.util.ResourceFilter</filter-class>
  </filter>

  <!-- MAPPING FOR OPENFACES RESOURCE FILTER -->
  <filter-mapping>
    <filter-name>ResourceFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

See the Installation section, and the Resource Filter Optimization sections in OpenFaces 2.0 documentation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文