Exception while using p:layout, Facelets and Richfaces

UI Components for JSF
Post Reply
juangon
Posts: 69
Joined: 22 Mar 2009, 19:05

15 Sep 2009, 10:33

Hi:

I am having a problem while showing an .xhtml (with templates) Facelets page. The trace error is shown below:

Code: Select all

java.lang.ClassCastException: com.sun.facelets.compiler.UIInstructions cannot be cast to org.primefaces.ui.component.layout.LayoutUnit
	at org.primefaces.ui.component.layout.LayoutRenderer.encodeScript(LayoutRenderer.java:76)
	at org.primefaces.ui.component.layout.LayoutRenderer.encodeBegin(LayoutRenderer.java:33)
	at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:788)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:884)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
	at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
	at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
	at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
	at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
	at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
	at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
	at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
	at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
	at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:853)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:544)
	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:474)
	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:366)
	at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:531)
	at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:420)
	at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:351)
	at org.apache.catalina.core.StandardHostValve.postInvoke(StandardHostValve.java:230)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:633)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
	at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
	at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
	at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
	at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
	at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
	at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
	at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
	at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
	at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
The template is something like this:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html 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"
	xmlns:p="http://primefaces.prime.com.tr/ui">
	
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="cache-control" content="no-store" />

<title><ui:insert name="title">Title</ui:insert></title>


<link rel="stylesheet" media="all"
	href="#{facesContext.externalContext.request.contextPath}/resources/styles.css"
	type="text/css" />


<a4j:loadScript src="resource://jquery.js" />

<p:resources exclude="/jquery/jquery.js" />

<script type="text/javascript">		   
		A4J.AJAX.onExpired = function(loc,expiredMsg){
    		if(window.confirm("<h:outputText value='#{msg.errorExpired}'/>")){
	      		return loc;
    		} else {
     			return false;
    		}    		
		}

		A4J.AJAX.onError = function(req,status,message){
				#{rich:component('ajaxErrorModalPanel')}.show();			    
		} 

		function removeTabHandlingFromPanel(modalPanelComponent){
		        modalPanelComponent.lastOnfocus = function(event){};
		        modalPanelComponent.firstOnfocus = function(event){};
		        modalPanelComponent.processAllFocusElements = function(event){};
		        modalPanelComponent.processTabindexes = function(event){};
		        modalPanelComponent.restoreTabindexes = function(event){};
		        modalPanelComponent.preventFocus = function(event){};
		        modalPanelComponent.restoreFocus = function(event){};
		}	
</script>

</head>
<body>
			
<p:layout >
	<!--  HEADER  -->

	<p:layoutUnit position="top" height="100">
			 <h:panelGroup>
				<rich:modalPanel id="loadingModalPanel">
					<f:facet name="header">
						<h:outputLabel value="#{msg.loading_please_wait_title}" />
					</f:facet>
					<h:outputText value="#{msg.loading_please_wait}" />
					<h:graphicImage value="/imagenes/indicator.gif"
						alt="#{msg.loading_please_wait}"
						title="#{msg.loading_please_wait}" style="border:0px" />
				</rich:modalPanel>
				<rich:modalPanel id="ajaxErrorModalPanel">
					<f:facet name="header">
						<h:panelGroup>
							<h:outputLabel value="#{msg.error_title}" />
						</h:panelGroup>
					</f:facet>
					<f:facet name="controls">
						<h:panelGroup>
							<h:graphicImage value="/imagenes/close.png" styleClass="hidelink"
								id="hidelink" />
							<rich:componentControl for="ajaxErrorModalPanel"
								attachTo="hidelink" operation="hide" event="onclick" />
						</h:panelGroup>
					</f:facet>
					<h:graphicImage value="/imagenes/error.png" height="50" width="50" />
					<h:outputText value="#{msg.error}" />
				</rich:modalPanel>
				<a4j:region>
					<!-- Please Wait Modal -->
					<a4j:status id="ajaxLoadingStatusModal"
						onstart="#{rich:component('loadingModalPanel')}.show()"
						onstop="#{rich:component('loadingModalPanel')}.hide()" />
				</a4j:region>

			</h:panelGroup>
			<ui:insert name="header">&nbsp;</ui:insert>
		<ui:insert name="menu">&nbsp;</ui:insert>
	</p:layoutUnit>
	<!--  MENU  -->	

	<!--  BODY  -->

	<p:layoutUnit position="center">
		<ui:insert name="body">&nbsp;</ui:insert>
	</p:layoutUnit>
</p:layout>
</body>
</html>
And the page is :

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<ui:composition template="/WEB-INF/facelets/template.xhtml"
	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">

	<ui:define name="title">
		<h:outputText value="#{msg.pagina_titulo}" />
	</ui:define>

	<ui:define name="header">
		<ui:include src="/WEB-INF/facelets/header.xhtml" />
	</ui:define>

	<ui:define name="menu">
		<ui:include src="/WEB-INF/facelets/menu.xhtml" />
	</ui:define>

	<ui:define name="body">

		<a4j:keepAlive beanName="personalController" ajaxOnly="false" />

		<rich:messages layout="list" globalOnly="true" infoClass="infoMessage"
			errorClass="errorMessage" warnClass="warnMessage">
			<f:facet name="errorMarker">
				<h:graphicImage url="/imagenes/error.gif" />
			</f:facet>

			<f:facet name="infoMarker">
				<h:graphicImage url="/imagenes/messagebox_info.png" />
			</f:facet>

			<f:facet name="warnMarker">
				<h:graphicImage url="/imagenes/messagebox_warning.png" />
			</f:facet>
		</rich:messages>

		<rich:panel>
			<f:facet name="header">
				<rich:spacer height="4" />
			</f:facet>

			<h:panelGrid columns="1" width="100%">
				<rich:panel>
					<f:facet name="header">
						<h:outputLabel value="#{msg.welcome_title}" />
					</f:facet>
					<h:outputFormat escape="false"
						value="#{msg.welcome_body}">
						<f:param
							value="#{userBean.name}" />
					</h:outputFormat>
				</rich:panel></h:panelGrid>
</rich:panel>
<ui:define>
</ui:composition>
I cutted some lines because the structure is basically like the source shown above.

I am using glassfish 2 UR 2, Facelets 1.1.13, Richfaces 3.3.1 GA

Any ideas?

Thanks very much!

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

15 Sep 2009, 10:44

Hi, where is the p:layout component, cant see it in source page.

juangon
Posts: 69
Joined: 22 Mar 2009, 19:05

15 Sep 2009, 10:48

It's in the template (in the source code provided).

Thanks!

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

15 Sep 2009, 10:58

Oh, I see ok :). Can you add this to your web.xml?

Code: Select all

<context-param>
		<param-name>facelets.SKIP_COMMENTS</param-name>
		<param-value>true</param-value>
	</context-param>

juangon
Posts: 69
Joined: 22 Mar 2009, 19:05

15 Sep 2009, 11:08

Oh great it worked! Another question: How can I change the css of the p:layout and p:layoutUnit components? richfaces skin is blue but the p:layout uses grey as background ,for example).

Thanks very much again!

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

15 Sep 2009, 11:11

I haven't added a skinning guide to layout in reference documentation but it's based on YUI layout framework so easy to skin. Here's a full CSS guide;

http://developer.yahoo.com/yui/examples ... ayout.html

juangon
Posts: 69
Joined: 22 Mar 2009, 19:05

15 Sep 2009, 11:17

thanks again!

It would be perfect if you could see why Primefaces fails in other of my post (export PDF with rich:datatable SerializableDataModel etc).

samuelasu
Posts: 6
Joined: 17 Jan 2014, 18:59

17 Jan 2014, 19:11

Thank you. I had the same problem and is also solved by:

<context-param>
<param-name>facelets.SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>

elkomodin
Posts: 1
Joined: 25 Sep 2016, 22:16

24 Oct 2016, 05:20

gracias, tenia el mismo problema y lo solucioné con lo que puso optimus

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 57 guests