JBoss 7.1, JSF, RichFaces - rich components don't want to render - jsf

I'm learing RichFaces now for my JSF project, but i have problem with rendering rich components in my enviroment.
I have added RichFaces jar(all 4 jars from RichFaces page) to JBoss modules (E:\JBoss\modules\org\richfaces\main) with module.xml:
<module xmlns="urn:jboss:module:1.1" name="org.richfaces">
<resources>
<resource-root path="richfaces-components-api-4.2.1.Final.jar"/>
<resource-root path="richfaces-components-ui-4.2.1.Final.jar"/>
<resource-root path="richfaces-core-api-4.2.1.Final.jar"/>
<resource-root path="richfaces-core-impl-4.2.1.Final.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="org.w3c.css.sac"/>
<module name="net.sourceforge.cssparser"/>
<module name="com.sun.jsf-impl"/>
<module name="javax.api"/>
<module name="javax.faces.api"/>
<module name="javax.xml.bind.api"/>
<module name="javax.xml.jaxp-provider"/>
<module name="com.google.guava"/>
</dependencies>
</module>
All dependencies were added to jboss modules by default configuration.
I created simple JSF page with RichFaces from tutorial:
<!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:a4j="http://richfaces.org/a4j">
<h:head></h:head>
<body>
<rich:panel>
<f:facet name="header">
Write your own custom rich components with built-in AJAX support
</f:facet>
<h:outputText value="Panel Body" />
</rich:panel>
<rich:panel>
<f:facet name="header">
Write your own custom rich components with built-in AJAX support
</f:facet>
<h:outputText value="Panel Body" />
<a4j:form>
<h:outputText value="The integer version of the selected color:" />
<h:outputText id="RGBvalue" value="#{colorPickerBean.color}" />
<rich:panel header="RichFaces Color Picker" style="width: 315px">
<rich:colorPicker value="#{colorPickerBean.color}" colorMode="rgb"
converter="org.richfaces.IntegerColor">
<a4j:support event="onchange" reRender="RGBvalue" />
</rich:colorPicker>
</rich:panel>
</a4j:form>
</rich:panel>
</body>
</html>
Both xmlns in head tag are highlighted with "NLS missing message: CANNOT_FIND_FACELET_TAGLIB in: org.eclipse.jst.jsf.core.validation.internal.facelet.messages"
I've deployed my new xhtml page for JBoss and now rich components aren't handled proper. Next listing shows source of deployed page.
<!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:rich="http://richfaces.org/rich" xmlns:a4j="http://richfaces.org/a4j"><head></head>
<body>
<rich:panel>Panel Body
</rich:panel>
<rich:panel>Panel Body
<a4j:form>The integer version of the selected color:<span id="RGBvalue"></span>
<rich:panel header="RichFaces Color Picker" style="width: 315px">
<rich:colorPicker colorMode="rgb" converter="org.richfaces.IntegerColor">
<a4j:support event="onchange" reRender="RGBvalue"></a4j:support>
</rich:colorPicker>
</rich:panel>
</a4j:form>
</rich:panel>
</body>
</html>
My jboss-deployment-structure.xml in WebContent/META-INF:
<jboss-deployment-structure>
<sub-deployment name="Tutorial2.war">
<dependencies>
<module name="org.richfaces" slot="main">
<imports>
<include path="**" />
</imports>
</module>
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
Modules defines as showed in link https://issues.jboss.org/browse/RF-12008
After few more changes I got
00:29:52,455 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.unit."Tutorial2.war".STRUCTURE: org.jboss.msc.service.StartException in service jboss.deployment.unit."Tutorial2.war".STRUCTURE: Failed to process phase STRUCTURE of deployment "Tutorial2.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_31]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_31]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_31]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: Sub deployment Tutorial2.war in jboss-structure.xml was not found. Available sub deployments:
at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.subDeploymentNotFound(DeploymentStructureDescriptorParser.java:233) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.deploy(DeploymentStructureDescriptorParser.java:159) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
... 5 more
Error occurs as soon as I add jboss-deployment-structure.xml to WEB-INF.

This looks like it's probably an issue with eclipse. It seems there are a few different questions along the same lines with eclipse and JSF. Most of them seem to say something this one does.

see following discussion on jboss forum
https://community.jboss.org/message/633025#633025
and search for the correnct answer
you should supply jboss7 specific deployment descriptor jboss_deployment_structure.xml to make richfaces module available to your application

Related

PrimeFaces Barcode sample

I just tried to just copy-paste sample from PrimeFaces Showcase about Barcode.
Here is this code, and I get:
I just wanted to test it go get same effect as sample.
<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:pm="http://primefaces.org/mobile"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<p:panelGrid columns="2">
<h:outputText value="Postnet" />
<p:barcode value="0123456789" type="postnet"/>
<h:outputText value="QR" />
<p:barcode value="0123456789" type="qr"/>
</p:panelGrid>
</h:body>
Have you add barcode4j and qrgen library into your dependency?
<dependency>
<groupId>net.glxn</groupId>
<artifactId>qrgen</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>net.sf.barcode4j</groupId>
<artifactId>barcode4j-light</artifactId>
<version>2.1</version>
</dependency>
**barcode4j 2.1 does not exist in maven central repository so manual installation is necessary for
maven users
you need to add a jar file to your repository to let primefaces understand the component much better. You can get the jar from here http://www.barcodelib.com/java_barcode/barcode_symbologies. That is the "barcode4j-light version 2.1"

I can't see html components in browser [duplicate]

This question already has an answer here:
JSF returns blank/unparsed page with plain/raw XHTML/XML/EL source instead of rendered HTML output
(1 answer)
Closed 5 years ago.
I couldn't see neither primefaces nor html components in my page. I can see only "sdaf" string. What can be the problem? At index.xhtml page autocomplete works good I can see component names. There must be nothing wrong with libraries.
My index.xhtml file;
<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:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:button value="html button"> </h:button>
sdaf
<p:spinner />
</h:body>
</html>
my pom.xml file;
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven- v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>5454</groupId>
<artifactId>45454</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>45454 Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>45454</finalName>
</build>
</project>
Try this code to see whether you can see inputtext box and a command button,
<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:p="http://primefaces.org/ui">
<f:view contentType="text/html">
<h:head>
<f:facet name="first">
<meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
<title>Title Goes Here</title>
</f:facet>
</h:head>
<h:body>
<h:form>
<p:panel header="Send">
<p:inputText value="Hi"></p:inputText>
<p:commandButton value="Send" id="btnDisplay"/>
</p:panel>
</h:form>
</h:body>
</f:view>
</html>
Web.xml
You need to have the below lines in your web.xml file
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
Problem could be your 'URL' if in your web.xml you have mapping:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>`
then you need to add 'faces' to your url. For example:
:http://localhost:8080/ABC/faces/pages/login.xhtml
The reason is because you have not rendered the requested api like jsf-impl to your pom.xml for reference check Primefaces-Maven-Example
Try to put your elements to show on page into the form tag:
<h:form>
<h:button value="html button"> </h:button>
sdaf
<p:spinner/>
</h:form>

JSF: javax.faces.FacesException: Cannot add the same component twice: vaz4n2-retrieve-update

I am a JSF beginner. I try to implement ICEfaces 3.0 component in Eclipse 4.2 (Juno). I had implemented & run it using Apache Tomcat 7.0. It showing the following error in window:
Cannot add the same component twice
In console bar it shows as :
javax.faces.FacesException: Cannot add the same component twice: v8z4ho2-retrieve-update
My JSF Code
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:icecore="http://www.icefaces.org/icefaces/core"
xmlns:ace="http://www.icefaces.org/icefaces/components"
xmlns:ice="http://www.icesoft.com/icefaces/component" >
<h:head>
<title>Chart</title>
<link rel="stylesheet" type="text/css" href="./xmlhttp/css/rime/rime.css"/>
</h:head>
<h:body styleClass="ice-skin-rime">
<h:form id="canvasForm">
<ace:chart id="chart" animated="false" value="#{chartBean.barData}"
stackSeries="false" defaultAxesConfig="#{chartBean.barDemoDefaultAxis}"
xAxis="#{chartBean.barDemoXAxis}" yAxis="#{chartBean.barDemoYAxis}"
legend="true" legendPlacement="OUTSIDE_GRID" highlighter="true"
highlighterLocation="N" highlighterShowMarker="false"
highlighterBringSeriesToFront="true"
widgetVar="barChart" />
</h:form>
</h:body>
</html>
How to rectify this error? Help me out.
In ICEFaces forum I've found many people with this problem. If you are using Tomcat 7.0.42, try Tomcat 7.0.41 instead and see if it works. Also check if you have icefaces jar duplicated (or icefaces.jar and icefaces-ee.jar) in the same classpath. The link to the post is:
http://www.icesoft.org/JForum/posts/list/22121.page#sthash.qxEkXX1Q.dpbs
Fixed by reverting icefaces version from 3.3.0 to 3.0.1:
<!-- Ices Dependencies -->
<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces-ace</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces-compat</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.icepush</groupId>
<artifactId>icepush</artifactId>
<version>3.1.0</version>
</dependency>

The metadata component needs to be nested within a f:metadata tag. Suggestion: enclose the necessary components within <f:metadata>

I went through different sources like:
Error saying I need to use f:metadata even though I do
http://docs.oracle.com/javaee/7/javaserverfaces/2.2/vdldocs/facelets/f/metadata.html
and it seems to be issue has been fixed in jsf 2.2.1, where as When I tried to use, I am facing issue, below are my configurations:
template.xhtml:
<!DOCTYPE html>
<html lang="#{languageBean.language}"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:fn="http://xmlns.jcp.org/jsp/jstl/functions"
xmlns:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui"
xmlns:of="http://omnifaces.org/functions">
<!-- Enables CTRL+SHIFT+D for activating Facelets debug window -->
<ui:debug />
<f:view locale="#{languageBean.language}" encoding="UTF-8" contentType="text/html">
<!-- Client templates can insert f:metadata here, and this will NOT show up in the showcase page source code -->
<ui:insert name="meta" />
<c:set var="contextPath" value="${pageContext.request.contextPath}"
scope="application" />
<f:loadBundle var="messageResource" basename="MessageResource" />
<h:head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta http-equiv="X-UA-Compatible"
content="EmulateIE8,IE=edge,chrome=1" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Connect" />
<meta name="keywords"
content="timeline, 3d, css, css3, css-only, transitions, responsive, fluid" />
<meta name="author" content="FriendsMirror" />
<link rel="shortcut icon"
href="#{request.contextPath}/Friendsmirror.ico" />
<ui:insert name="js"/>
<h:outputStylesheet library="css" name="common.css" />
<h:outputStylesheet library="css" name="main.css" />
<ui:insert name="css"/>
<ui:insert name="onloadScript"/>
<title><ui:insert name="title">#{messageResource['connect.main.title.main.title']}</ui:insert></title>
</h:head>
<h:body>
<ui:insert name="content" />
</h:body>
</f:view>
</html>
Page:
<ui:composition template="/WEB-INF/templates/discussion_layout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
<ui:define name="meta">
<f:metadata>
<f:viewParam name="sessionKey" value="#{discussionWrapperBean.sessionKey}" />
<f:viewParam name="ref" value="#{discussionWrapperBean.ref}" />
<f:viewParam name="pId" value="#{discussionWrapperBean.pId}" />
<f:viewParam name="dId" value="#{discussionWrapperBean.discussionId}" />
<f:viewParam name="dName" value="#{discussionWrapperBean.discussionName}" />
<f:viewAction action="#{discussionWrapperBean.loadInitDiscussion}" onPostback="false" />
</f:metadata>
</ui:define>
<ui:define name="title">
<ui:fragment rendered="#{discussionWrapperBean.profileId != null}">
#{discussionWrapperBean.userBean.firstName} #{discussionWrapperBean.userBean.lastName != null ? discussionWrapperBean.userBean.lastName: ''}#{discussionWrapperBean.pageTitleNotifications != null ? '(' : ''}#{discussionWrapperBean.pageTitleNotifications != null ? discussionWrapperBean.pageTitleNotifications : ''}#{discussionWrapperBean.pageTitleNotifications != null ? ')' : ''}
</ui:fragment>
<ui:fragment rendered="#{discussionWrapperBean.profileId == null}">
#{messageResource['connect.discussion.title']}
</ui:fragment>
</ui:define>
<ui:define name="content">
</ui:define>
</ui:composition>
Maven:
<jsf.version>2.2.1</jsf.version>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${jsf.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${jsf.version}</version>
<scope>provided</scope>
</dependency>
In Ui I am getting issue like:The metadata component needs to be nested within a f:metadata tag. Suggestion: enclose the necessary components within <f:metadata>
even its not calling the <f:viewAction>
Any Suggestion or help will be appreciated.
One thing I noticed during deployment:
INFO: Initializing Mojarra 2.2.0 ( 20130502-2118 https://svn.java.net/svn/mojarra~svn/tags/2.2.0#11930) for context /connectWAR
I am not sure why this is telling Mojarra 2.2.0, even though I have upgraded to 2.2.1
As to the false UI warning, this is caused by Mojarra issue 2868 and already fixed since 2.2.1.
As to the <f:viewAction> still not working on 2.2.1, another Mojarra bug with the since Java EE 7 introduced xmlns.jcp.org XML namespace domain is causing this trouble. In specifically Mojarra versions 2.2.0 and 2.2.1 the new XML namespace domain is not properly registered for all new JSF 2.2 specific tags which didn't exist in JSF 2.0/2.1, such as <f:viewAction>. In effects, the xmlns.jcp.org will give you in Mojarra 2.2.0/2.2.1 only the JSF 2.1 compatible tags back. This totally explains why the new JSF 2.2 <f:viewAction> didn't work for you.
You have 2 options:
Use the "old" java.sun.com XML namespace domain instead. The new JSF 2.2 specific tags are properly registered there.
Upgrade to at least Mojarra 2.2.2. This peculiar bug is fixed since that version. Mojarra is currently already at 2.2.4.

PrimeFaces components are not recognized and don't render

I just added PrimeFaces 3.0 to a JSF project:
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.0</version>
</dependency>
And I created this test page:
<!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:p="http://primefaces.prime.com.tr/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</h:head>
<h:body>
<h:form>
<p:panel header="F.C. Barcelona" footer="Visca el Barca!">
<h:outputText value="FC Barcelona " />
</p:panel>
<h:outputText id="name" value="#{facesBean.name}" /> <h:commandButton value="Submit" action="#{facesBean.callService()}" />
</h:form>
</h:body>
</html>
But the <p:panel> component is not rendered. Only the <h:xxx> components are properly rendered.
I have PrimeFaces jar in Maven dependecies and in the target folder. I'm using Tomcat 7. PrimeFaces doesn't need any additional configuration, right?
xmlns:p="http://primefaces.prime.com.tr/ui"
This XML namespace is for PrimeFaces 2.x only. Since PrimeFaces 3.0, the new XML namespace is
xmlns:p="http://primefaces.org/ui"
Make sure that you're reading documentation/tutorials concerning PrimeFaces 3.0, not 2.x.

Resources