缺少js for openfaces树表

时间:2012-01-05 12:20:51

标签: java richfaces jsf-1.2 openfaces

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

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

这看起来你还没有在应用程序的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>

请参阅Installation部分以及OpenFaces 2.0文档中的Resource Filter Optimization部分。