Prerequisites:
JSF 2.1
Primefaces 5.2
Glassfish 3.1
User Story:
When clicking on a CommandButton, a Window should pop up.
Implementation:
commandbutton
<p:commandButton value="+" actionListener="#{beanname.showDialogue}" />
bean
public void showDialogue() {
RequestContext.getCurrentInstance().openDialog("/Dialogues/Dialogue");}
faces-config
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
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"
version="2.1">
<application>
<action-listener>org.primefaces.application.DialogActionListener</action-listener>
<navigation-handler>org.primefaces.application.DialogNavigationHandler</navigation-handler>
<view-handler>org.primefaces.application.DialogViewHandler</view-handler>
</application>
</faces-config>
The popup to open is placed in src/main/webapp/Dialogues
Outcome:
When Clicking on the button the URL reloads from host/applicationname/ to host/applicationname/faces/[pagewherecommandbuttonis]
Question:
What am i (possibly) missing here, in order to get the popup working?
You must do this:
org.primefaces.context.RequestContext.getCurrentInstance().execute("PF('widgetName').show();");
Related
there is a way to change the locale for especific view in jsf?
i can try the locale via faces-config.xml, but i just wanna a specific view.
faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude"
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_1_2.xsd">
<application>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
<locale-config>
<default-locale>es</default-locale>
<supported-locale>ca</supported-locale>
<supported-locale>en</supported-locale>
</locale-config>
You can set the locale on a per-view basis by nesting your content in a <f:view> tag that has one of its attributes, locale, for exactly this purpose:
<f:view locale="#{localeBean.selectedlocale}">
For more information consult Localization in JSF, how to remember selected locale per session instead of per request/view.
I'm new to JSF. Right now I am developing a JSF project. I have 2 properties files, configured correctly. (tested on previous Servlet/ JSP proj.)
The problem is when I try to get the value from the property file, I get just a code typed in my browser like this:
Welcome, "#{bundle.dude}"
But it should be like:
Welcome, dude
That's my problem.
My 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>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>en</supported-locale>
<supported-locale>ru</supported-locale>
</locale-config>
<resource-bundle>
<base-name>i18n.MediaPortal</base-name>
<var>bundle</var>
</resource-bundle>
</application>
</faces-config>
i18n property files are located at src/main/resources/i18n/ dir
Every answer is appreciated.
Thanks in advice.
Nazar
we have following taglib:
<facelet-taglib version="2.0" 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">
<namespace>http://www.example.com/mytaglib</namespace>
<composite-library-name>common</composite-library-name>
<tag>
<tag-name>selectOneRadio</tag-name>
<component>
<component-type>psa.selectOneRadio</component-type>
<renderer-type>psa.selectOneRadioRenderer</renderer-type>
</component>
<attribute>
<name>styleClass</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<name>itemStyleClass</name>
<type>java.lang.String</type>
</attribute>
</tag>
The tag lib combines composite components in /resources/common (composite-library-name) and java written components.
It all works fine, but when using the selectOneRadio (java) component, we get the following error (but without a "real" error -> the selectOneRadio component also works fine):
08:31:31,202 ERROR [ResourceImpl:98] Resource handler [com.sun.faces.application.resource.ResourceHandlerImpl#1c22bcb0] was unable to create a resource for resourceName=[selectOneRadio.xhtml] libraryName=[common] contentType [application/xhtml+xml]
Its clear, because the selectOneRadio component is a java written component, the selectOneRadio.xhtml does not exist.
Thanks
Dirk
I am using Mojarra 2.1.2 and want to configure the facelet cache factory. I tried the following in my WEB-INF/faces-config.xml but it does not seem to work.
<factory>
<facelet_cache_factory>org.valuesource.custdb.web.extension.SimpleFaceletCacheFactory</facelet_cache_factory>
</factory>
You shouldn't use underscores. Use hyphens.
<facelet-cache-factory>
No one XML element of faces-config.xml uses underscores. Note that the FaceletCacheFactory was introduced in JSF 2.1, so ensure that your faces-config.xml root declaration conforms JSF 2.1:
<faces-config
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"
version="2.1">
when you use a component from extarnal libraries (or custom component) in JSF page you add the xmlns declaration, for example:
xmlns:util="http://java.sun.com/jsf/composite/component/util
I would like to know what I have to do to use a private address in the Namaspace like this below:
xmlns:p="http://primefaces.prime.com.tr/ui"
It is something related to packages? Or it depends from the name of the .JAR that contains the components?
Thank you!
For Facelets this is definied in .taglib.xml file. In case of PrimeFaces it's /META-INF/primefaces-p.taglib.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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://primefaces.prime.com.tr/ui</namespace>
...
Note the <namespace>. For JSP this is definied in the .tld file, for PrimeFaces it's the /META-INF/primefaces-p.tld
<?xml version="1.0" encoding="UTF-8"?>
<taglib xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1">
<tlib-version>1.2</tlib-version>
<short-name>p</short-name>
<uri>http://primefaces.prime.com.tr/ui</uri>
...
Note the <uri>.