Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

java - RichFaces4 don't render the components

I try to run RichFaces4 app but the components don't render. For example when I try this demo: Demo I get something like this:

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

My code is almost the same as in the demo. I just added form tag becouse it complained for it.

<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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

That's what Crome Developer Tools told me http://img571.imageshack.us/i/rfnotdefined.jpg (Uncaught ReferenceError: RichFaces is not defined)

This means that the necessary JavaScript files of RichFaces are not been supplied in the generated HTML <head>. You need to ensure that you're using the JSF <h:head> component instead of plain HTML <head> in the template. This is namely mandatroy for the new JSF 2.0 resource injection mechanism, JSF and RichFaces will inject Ajax/UI-related JavaScripts/Stylesheets in there.

I however wonder if anything has been logged in the server log about the lack of the <h:head>. Keep an eye on the server logs.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...