RichFaces4不呈现组件

时间:2011-04-22 18:02:42

标签: java jsf richfaces

我尝试运行RichFaces4应用,但组件无法渲染。例如,当我尝试这个演示:Demo我得到这样的东西:

Here is an example of default tab panel with 3 tabs.



 j_id1475365623_57f04a9f j_id1475365623_57f04a9f j_id1475365623_57f04a9f 
 j_id1475365623_57f04a75 j_id1475365623_57f04a75 j_id1475365623_57f04a75 
 j_id1475365623_57f04a6b j_id1475365623_57f04a6b j_id1475365623_57f04a6b 



«
↓
»
Here is tab #1



Here is an example of tab panel switched in "ajax" style. Second tab is disabled.



 j_id1475365623_57f04a27 j_id1475365623_57f04a27 j_id1475365623_57f04a27 
 j_id1475365623_57f04a1d j_id1475365623_57f04a1d j_id1475365623_57f04a1d 
 j_id1475365623_57f04bf3 j_id1475365623_57f04bf3 j_id1475365623_57f04bf3 



«
↓
»
Here is tab #1



Here is an example of tab panel switched completely on client.



 j_id1475365623_57f04bcf j_id1475365623_57f04bcf j_id1475365623_57f04bcf 
 j_id1475365623_57f04ba5 j_id1475365623_57f04ba5 j_id1475365623_57f04ba5 
 j_id1475365623_57f04b9b j_id1475365623_57f04b9b j_id1475365623_57f04b9b 



«
↓
»
Here is tab #1
Here is tab #2
Here is tab #3

我的代码与演示中的代码几乎相同。我刚刚添加了表单标签,因为它抱怨它。

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich">
    <p>Here is an example of default tab panel with 3 tabs.</p>
    <h:form>
    <rich:tabPanel>
        <rich:tab label="First">
            Here is tab #1
        </rich:tab>
        <rich:tab label="Second">
            Here is tab #2
        </rich:tab>
        <rich:tab label="Third">
            Here is tab #3
        </rich:tab>
    </rich:tabPanel>
    <br/><br/>
    <p>Here is an example of tab panel switched in "ajax" style. Second tab is disabled.</p>
    <rich:tabPanel switchType="ajax">
        <rich:tab label="First">
            Here is tab #1
        </rich:tab>
        <rich:tab label="Second" disabled="true">
            Here is tab #2
        </rich:tab>
        <rich:tab label="Third">
            Here is tab #3
        </rich:tab>
    </rich:tabPanel>
    <br/><br/>
    <p>Here is an example of tab panel switched completely on client.</p>
    <rich:tabPanel switchType="client">
        <rich:tab label="First">
            Here is tab #1
        </rich:tab>
        <rich:tab label="Second">
            Here is tab #2
        </rich:tab>
        <rich:tab label="Third">
            Here is tab #3
        </rich:tab>
    </rich:tabPanel>
    </h:form>
</ui:composition>

2 个答案:

答案 0 :(得分:6)

  

这就是Crome开发者工具告诉我http://img571.imageshack.us/i/rfnotdefined.jpg(未捕获的ReferenceError:RichFaces未定义)

这意味着生成的HTML <head>中未提供RichFaces所需的JavaScript文件。您需要确保在模板中使用JSF <h:head>组件而不是纯HTML <head>。这就是新的JSF 2.0资源注入机制的mandatroy,JSF和RichFaces将在那里注入与Ajax / UI相关的JavaScripts / Stylesheets。

但我想知道服务器日志中是否记录了<h:head>的缺失。密切关注服务器日志。

答案 1 :(得分:0)

至少在某些情况下,没有任何内容记录到服务器日志中缺少<h:head>。使用MyFaces 2.1.4的facelets模板中的<head>,WAS 7.0.0.13上的RichFaces 4.0.0会导致RichFaces组件无法正常呈现,但a4j组件工作正常。在迁移JSF1项目时,一定要注意什么。