I migrated some of my facelets custom components into proper composite components, but encounters the following error while rendering a view that contains the composite component:
javax.faces.view.facelets.TagException: /WEB-INF/taglib/cctest.xhtml #15,26 <composite:interface> Component Not Found for identifier: bodyId.getParent().
at com.sun.faces.facelets.tag.composite.InterfaceHandler.validateComponent(InterfaceHandler.java:135)
at com.sun.faces.facelets.tag.composite.InterfaceHandler.apply(InterfaceHandler.java:125)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:87)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:320)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:379)
at com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:326)
at com.sun.faces.facelets.tag.UserTagHandler.apply(UserTagHandler.java:142)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:187)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
at com.sun.faces.facelets.tag.jsf.core.ViewHandler.apply(ViewHandler.java:188)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:87)
at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:164)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:906)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.jav
In the error message, the name bodyId refers to the id of <h:body> in the file below, and getParent() is hardcoded during the creation of the exception message. #15,26 refers to the end of <composite:interface> in cctest.xhtml below.
Here is the page that contains the composite component:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core"
xmlns:bam="http://bam.mycompany.com/jsftaglib"
>
<f:view locale="en" id="viewId">
<h:head id="headId">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Title</title>
</h:head>
<h:body id="bodyId">
<bam:cctest value="hello world."/>
</h:body>
</f:view>
</html>
Here is the file named cctest.xhtml that declares the composite component cctest:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:h="http://java.sun.com/jsf/html"
>
<h:head>
<title>not used</title>
</h:head>
<h:body>
<composite:interface>
<composite:attribute name="value" required="true"/>
</composite:interface>
<composite:implementation>
<h:outputText id="text_#{cc.attrs.value}" value="#{cc.attrs.value}"/>
</composite:implementation>
</h:body>
</html>
The composite component is declared in a file named bam.taglib.xml located in /WEB-INF/taglib/, next to cctext.xhtml. Here is the file:
<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
version="2.0">
<namespace>http://bam.mycompany.com/jsftaglib</namespace>
<tag>
<tag-name>cctest</tag-name>
<source>cctest.xhtml</source>
</tag>
</facelet-taglib>
I'm using mojarra 2.1.21 into tomcat 7.0.41. My faces-config.xml file is empty, there's no managed beans or other custom-defined components (validator, etc.). Web.xml only declares a few context param, plus the faces servlet mapped on *.xhtml; here are those context parameters:
javax.faces.FACELETS_REFRESH_PERIOD = 1
javax.faces.FACELETS_SKIP_COMMENTS = false
javax.faces.FACELETS_LIBRARIES = /WEB-INF/taglib/bam.taglib.xml
javax.faces.PROJECT_STAGE = Development
javax.faces.VALIDATE_EMPTY_FIELDS = false
javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL = true
Looking at the component tree that is displayed in the facelets error page, there's no element named bodyId, which might be a hint for my issue. A copy of which is displayed below:
<UIViewRoot id="j_id1" inView="true" locale="en" renderKitId="HTML_BASIC" rendered="true" transient="false" viewId="/pages/composite_component_test.xhtml">
<html xmlns="http://www.w3.org/1999/xhtml">
<UIOutput id="headId" inView="true" rendered="true" transient="false">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Title</title>
</UIOutput>
</UIViewRoot>
Many thanks in advance for looking at this issue.
I have seen this type of error occur in Development mode when referencing a component from another component via an include e.g.
<composite:implementation>
<ui:include src="/resources/mycomponents/component1.xhtml" />
</composite:implementation>
Instead one should use appropriate JSF Component referencing syntax
e.g.
<mycomponents:component1/>
Strangely this error doesn't happen if one switches to Production mode and all works fine.
Related
Resource Library Contracts is not working on Weblogic 12.1.1. Wondering is it the version issue? Encounter the below error when try to access c1/index.xhtml
javax.faces.view.facelets.TagAttributeException: //seamnt/prd101/weblogic12_projects/testdomain/servers/testserver/stage/JavaWeb/JavaWeb/c1/index.xhtml #8,48 Invalid path : /template.xhtml
This is the war structure:
WEB-INF/faces-config.xml
<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.1"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd">
<application>
<resource-library-contracts>
<contract-mapping>
<url-pattern>/c1/*</url-pattern>
<contracts>c1</contracts>
</contract-mapping>
<contract-mapping>
<url-pattern>/c2/*</url-pattern>
<contracts>c2</contracts>
</contract-mapping>
</resource-library-contracts>
</application>
</faces-config>
contracts/c1/template.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<h:outputStylesheet name="default.css"/>
<title><ui:insert name="title">c1 Template</ui:insert></title>
</h:head>
<h:body styleClass="body">
<h1><ui:insert name="h1">template.xhtml</ui:insert></h1>
<h:graphicImage url="#{resource['duke.handsOnHips.gif']}"
alt="Duke with hands on hips"/>
<ui:insert name="content"/>
</h:body>
</html>
c1/index.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition template="/template.xhtml">
<ui:define name="title">c1 Index</ui:define>
<ui:define name="h1">index.xhtml</ui:define>
<ui:define name="content">
<h:form>
<div>Name: #{requestScopedBean.name}</div>
<label>Name:
<h:inputText id="username"
title="Name: "
value="#{requestScopedBean.name}"
required="true"
requiredMessage="Error: A name is required."
maxlength="25" />
</label>
<br/>
<h:commandButton id="submit" value="Submit"
action="index" />
<h:commandButton id="reset" value="Reset" type="reset" />
</h:form>
<div class="messagecolor">
<h:messages showSummary="true"
showDetail="false"
errorStyle="color: #d20005"
infoStyle="color: blue"/>
</div>
</ui:define>
</ui:composition>
</html>
Resource library contracts was introduced in JSF 2.2.
You're using only JSF 2.1. This is not only indicated by the fact that you're using version="2.1" in faces-config.xml, but also the fact that WebLogic 12.1.x has JSF 2.1 built-in.
Logically, you've 2 options:
Upgrade to JSF 2.2 (this means, upgrade to WebLogic 12.2.x).
Drop the idea of using resource library contracts. It's a rather useless feature anyway.
Last but not least, make sure your versions match the learning resources and that you catch up the currently available versions. Make sure you learn JSF the right way. Start here.
i am trying to apply the basic sample for rendering a page inside a dialog as in the showcase
http://www.primefaces.org/showcase/ui/dialogFrameworkBasic.jsf
my web pages are under webapp/pages/general
i am running PrimeFaces-4.0-SNAPSHOT on Mojarra-2.1.20
i have two pages:
1- home.xhtml
2- viewreport.xhtml
1- home.xhtml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:p="http://primefaces.org/ui"
xmlns:pretty="http://ocpsoft.com/prettyfaces"
xmlns:sec="http://www.springframework.org/security/tags"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<title>Welcome</title>
<h:outputStylesheet library="css" name="style.css" />
</h:head>
<h:body dir="rtl">
<h:form>
<p:commandButton value="View" icon="ui-icon-extlink"
action="dialog:viewreport" />
</h:form>
</h:body>
</html>
2- viewreport.xhtml:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:panelGroup id="report_details_new" layout="block" style="width:500px;height:500px;">
HELLO WORLD
</h:panelGroup>
</h:body>
</html>
when clicking on the button, nothing happens, i don't get any errors in eclipse console or in browser console.
please advise why the dialog framework is not working.
Solved by adding the following configuration to the faces-config.xml:
<action-listener>org.primefaces.application.DialogActionListener</action-listener>
<navigation-handler>org.primefaces.application.DialogNavigationHandler</navigation-handler>
<view-handler>org.primefaces.application.DialogViewHandler</view-handler>
tested on IE9,Chrome,Firefox for primefaces 4.0-SNAPSHOT
I create a template xhtml file which is like richfaces-showcase main.xhtml:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j">
<f:view contentType="text/html">
<h:head>
<!-- Mimic Internet Explorer 8 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<title>My title</title>
</h:head>
<h:body>
<div id="page">
<ui:insert name="body">
Body content missed
</ui:insert>
</div>
</h:body>
</f:view>
</html>
And in sub page, I defined the "template body", and add an a4j:poll in my sub page, which I want to use to refresh the data every 5 seconds:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:rich="http://richfaces.org/rich"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<ui:composition template="/templates/main.xhtml">
<ui:define name="body">
<h:form>
<a4j:poll id="poll" interval="5000" enabled="true" action="..." render="poll,grid" />
</h:form>
<h:form>
<h:panelGrid columns="2" width="80%" id="grid">
sorry, details forgot ...
</h:panelGrid>
</h:form>
</ui:define>
</ui:composition>
</html>
But the question is, when I open my sub page with IE8 in the localhost computer, the a4j:poll can refresh data once, and then it never get data again. when I open the sub page with IE6 or IE8 in other computer, it works fine! Can anybody find the reason out? Thanks in advance!!
I change the
<h:head>
<!-- Mimic Internet Explorer 8 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<title>My title</title>
</h:head>
to
<h:head>
<!-- Mimic Internet Explorer 7 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>My title</title>
</h:head>
and, it works now... but why?
I got it working with EmulateIE8. But probably when using it in an intranet way IE can be doing things differently.
Check your Browser mode and Document mode (press F12).
I got: IE9 / IE8 standards.
I'm using JSF2 and Richfaces 4.
I've added the following to my web.xml:
<mime-mapping>
<extension>xcss</extension>
<mime-type>text/css</mime-type>
</mime-mapping>
I have an test.xcss file:
<?xml version="1.0" encoding="UTF-8"?>
<f:template xmlns:f="http:/jsf.exadel.com/template"
xmlns:u="http:/jsf.exadel.com/template/util"
xmlns="http://www.w3.org/1999/xhtml" >
<f:verbatim><![CDATA[
#content a:link[disabled]{ cursor: default;}
]]>
</f:verbatim>
<u:selector name="body">
<u:style name="background-color" skin="generalBackgroundColor" />
<u:style name="font-size" skin="generalSizeFont" />
<u:style name="font-family" skin="generalFamilyFont" />
</u:selector>
</f:template>
I load this test.xcss via my template.xhtml:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.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">
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8" />
<f:view contentType="text/html">
<h:head>
<title>TEST</title>
<h:outputStylesheet library="css" name="test.xcss" />
</h:head>
<h:body>
</h:body>
</f:view>
</html>
Using firebug to view the content, the test.xcss is empty. Any ideas why it is not rendering the file correctly?
I suspect .xcss files are not supported in Richfaces 4, that ecss files are now used.
http://docs.jboss.org/richfaces/latest_4_0_X/Developer_Guide/en-US/html_single/#sect-Developer_Guide-Skinning_and_theming-What_are_skins
Found my answer:
http://community.jboss.org/wiki/RichFacesMigrationGuide33x-4xMigration-Skinning
.xcss not supported anymore, quite a bit of code migration to do now :(
I have the following snippet:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<f:metadata>
<f:event type="preRenderView" listener="#{workflowController.test}"/>
</f:metadata>
<h:head>
<title>Simple JSF Facelets page</title>
</h:head>
<h:body>
Hello, Place your content here
</h:body>
</html>
When I open the page, the WorkflowController.test() method is called twice (it's just a simple method which makes a log entry). Do you know why it's being called twice?
Thanks.
Try to put the <f:event/> tag outside of the <f:metadata>, it worked for me (mojarra 2.1.0).