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>
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.
At least in some cases nothing is being logged to the server log about the lack of <h:head>
. Using just <head>
in the facelets template with MyFaces 2.1.4, RichFaces 4.0.0 on WAS 7.0.0.13 results in the RichFaces components not rendering properly, but the a4j components working fine. Definitely something to be on the lookout for when migrating JSF1 projects.
来源:https://stackoverflow.com/questions/5758434/richfaces4-dont-render-the-components