在尝试将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版。

最佳答案

需要在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;
            }
        }
    }
}

07-27 13:24