How to use PrimeFaces p:fileUpload? Listener method is never invoked or UploadedFile is null / throws an error / not usable

How to configure and troubleshoot <p:fileUpload> depends on PrimeFaces and JSF version. All PrimeFaces versions The below requirements apply to all PrimeFaces versions: The enctype attribute of the <h:form> needs to be set to multipart/form-data. When this is absent, the ajax upload may just work, but the general browser behavior is unspecified and dependent on … Read more

How to include another XHTML in XHTML using JSF 2.0 Facelets?

<ui:include> Most basic way is <ui:include>. The included content must be placed inside <ui:composition>. Kickoff example of the master page /page.xhtml: <!DOCTYPE html> <html lang=”en” 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”> <h:head> <title>Include demo</title> </h:head> <h:body> <h1>Master page</h1> <p>Master page blah blah lorem ipsum</p> <ui:include src=”/WEB-INF/include.xhtml” /> </h:body> </html> The include page /WEB-INF/include.xhtml (yes, this is the … Read more

What can , and be used for?

Process GET parameters The <f:viewParam> manages the setting, conversion and validation of GET parameters. It’s like the <h:inputText>, but then for GET parameters. The following example <f:metadata> <f:viewParam name=”id” value=”#{bean.id}” /> </f:metadata> does basically the following: Get the request parameter value by name id. Convert and validate it if necessary (you can use required, validator … Read more

JSF returns blank/unparsed page with plain/raw XHTML/XML/EL source instead of rendered HTML output

There are three main causes. FacesServlet is not invoked. XML namespace URIs are missing or wrong. Multiple JSF implemenations have been loaded. 1. Make sure that URL matches FacesServlet mapping The URL of the link (the URL as you see in browser’s address bar) has to match the <url-pattern> of the FacesServlet as definied in … Read more

Differences between action and actionListener

actionListener Use actionListener if you want have a hook before the real business action get executed, e.g. to log it, and/or to set an additional property (by <f:setPropertyActionListener>), and/or to have access to the component which invoked the action (which is available by ActionEvent argument). So, purely for preparing purposes before the real business action … Read more

Understanding PrimeFaces process/update and JSF f:ajax execute/render attributes

<p:commandXxx process> <p:ajax process> <f:ajax execute> The process attribute is server side and can only affect UIComponents implementing EditableValueHolder (input fields) or ActionSource (command fields). The process attribute tells JSF, using a space-separated list of client IDs, which components exactly must be processed through the entire JSF lifecycle upon (partial) form submit. JSF will then … Read more