I have created a TinyMCE Composite Component
Steps which i did
1- Added tinymce folder provided by TinyMCE in resource directory of the project.
2- Then created another folder editors in resource directory and created two file one is js file tinymce_init.js and code is
tinyMCE.init({
mode : "specific_textareas",
theme : "simple",
debug : true,
editor_selector : "tinymce"
});
and another file tinymce.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<ui:component 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:composite="http://java.sun.com/jsf/composite"
xmlns:pe="http://primefaces.org/ui/extensions">
<composite:interface>
<composite:attribute name="value" />
</composite:interface>
<composite:implementation>
<h:outputScript library="tinymce" name="tinymce.js" target="head" />
<h:outputScript library="editors" name="tinymce_init.js" target="head" />
<h:inputTextarea rows="5" cols="80" />
</composite:implementation>
</ui:component>
3- Now access this composite component into my xhtml file something like this
<?xml version="1.0" encoding="UTF-8"?>
<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:editors="http://java.sun.com/jsf/composite/editors">
<h:head>
<title>test</title>
</h:head>
<h:body>
<editors:tinymce />
</h:body>
</html>
But when i access this file i saw a input box without any toolbar , what i am doing wrong and JS is loaded properly without any error in browser console.
Related
Iam using primefaces in my project and everything works fine except p:calendar component of Primefaces.The following xhtml file doesn't show up the calendar component.
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
template="/WEB-INF/Templates/Commons/MainContent.xhtml">
<ui:define name="main_content">
<h:body>
<h:form>
<p:calendar value="#{controller.data}" pattern="dd/MM/yyyy" />
</h:form>
</h:body>
</ui:define>
</ui:composition>
However if I remove ui:compisition ,as the following snippet shows,it works fine.
<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:p="http://primefaces.org/ui">
<h:body>
<h:form>
<p:calendar value="#{controller.data}" pattern="dd/MM/yyyy" />
</h:form>
</h:body>
</html>
Is there anything I should know about ui:compisition and p:calendar?
I think that if you use this template it may helps you
<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:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<ui:composition template="/WEB-INF/Templates/Commons/MainContent.xhtml">
<ui:define name="main_content">
<h:body>
<h:form>
<p:calendar value="#{controller.data}" pattern="dd/MM/yyyy" />
</h:form>
</h:body>
</ui:define>
</ui:composition>
</html>
follow this structure.
This works:
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 xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<f:view contentType="text/html" encoding="UTF-8" locale="#{LanguageBean.localeLanguage}">
<f:metadata>
<f:viewParam name="token" value="#{changePasswordBean.token}"/>
<f:viewAction action="#{changePasswordBean.checkValidToken}" />
</f:metadata>
But this (based on this example) does not (token is always null):
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 xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<f:view contentType="text/html" encoding="UTF-8" locale="#{LanguageBean.localeLanguage}">
<ui:insert name="metadata" />
page.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">
<ui:composition template="template.xhtml"
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"
>
<html>
<ui:define name="metadata">
<f:metadata>
<f:viewParam name="token" value="#{changePasswordBean.token}"/>
<f:viewAction action="#{changePasswordBean.checkValidToken}" />
</f:metadata>
</ui:define>
Why?
I've got the same example working in my project code (Mojarra 2.1.29), so it must be an implementation issue. Your current JSF implementation was released more than three years ago and lots of problems have been solved since then. I recommend you to go at least with the latest 2.1.x available or to switch to 2.2.x if it's a new project. Also, you're using f:viewAction, which is a JSF 2.2 specific feature and simply won't properly work with your JSF implementation version.
See also:
f:viewAction feature
I'm building a page in JSF and am running it on Tomcat in Eclipse. Everything was working quite well until I started getting these errors everytime I try to load the page. The page looks wrong and the eclipse console shows me around 12 of errors like this one:
Dec 19, 2013 9:23:26 PM com.sun.faces.context.ExternalContextImpl getMimeType
WARNING: JSF1091: No mime type could be found for file /img/sep.jsp.
To resolve this, add a mime-type mapping to the applications web.xml.
The funny thing is that the file in this particular error isnt sep.jsp but sep.PNG...
<?xml version='1.0' encoding='UTF-8' ?>
<!-- index.xhtml -->
<!-- JSF page that displays the current time on the web server -->
<!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">
<h:head>
<title>WebTime: A Simple Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</h:head>
<h:body>
<h1>Current time on the web server: #{webTimeBean.time}</h1>
<img src="img/sep.png" alt="sep.png" style="width:200px; height:200px;
float:right;" />
</h:body>
</html>
its recommended to use only jsf TAGS and not mixing standard html and jsf.
a valid xhtml for jsf use should be somthing like this:
you don't need to declare xml at the top of your page!!!!
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
>
<h:head>
<meta charset="UTF-8" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<h:outputStylesheet name="stylesheet.css"/>
<title>Test</title>
</h:head>
<body>
<f:view>
<h:outputText value="hello"></h:outputText>
<h:graphicImage name="img/sep.png" class="LOGO" alt="Image not found!"></h:graphicImage>
</f:view>
</body>
</html>
in your web.xml, check the Faces Servlet Pattern. it seems to me that tomcat tries to compile every file under / as jsf. so change your faces pathern and
try it and let me know if you still have the same "warning".
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.
I wanted to introduce CCs in my project. I am running Java EE 6 on JBoss 7.1.1.
/myProj/src/main/webapp/composites/scheda.xhtml:
<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:composite="http://java.sun.com/jsf/composite">
<composite:interface>
<composite:attribute name="prod" />
</composite:interface>
<composite:implementation>
Hello!
</composite:implementation>
</html>
/myProj/src/main/webapp/someDir/page.xhtml:
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition 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:p="http://primefaces.org/ui"
xmlns:composites="http://java.sun.com/jsf/composite/composites"
template="/templates/default.xhtml">
<ui:define name="content">
<p:dialog
header="Scheda"
widgetVar="schedaDialog"
id="schedaDialogId">
<composites:scheda prod="test" />
</p:dialog>
</ui:define>
</ui:composition>
This results in:
javax.servlet.ServletException: /.../page.xhtml
Tag Library supports namespace:
http://java.sun.com/jsf/composite/composites, but no tag was defined
for name: scheda
Some bug?
You didn't put your xhtml of composite component in the right place. As I can see you are using Maven so proper path to your composite component should be:
/myProj/src/main/webapp/resources/composites/scheda.xhtml
resources is the folder where JSF looks for composite components.