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

How to find out client ID of component for ajax update/render? Cannot find component with expression “foo” referenced from “bar”

Look in HTML output for actual client ID You need to look in the generated HTML output to find out the right client ID. Open the page in browser, do a rightclick and View Source. Locate the HTML representation of the JSF component of interest and take its id as client ID. You can use … Read more

Why JSF calls getters multiple times

This is caused by the nature of deferred expressions #{} (note that “legacy” standard expressions ${} behave exactly the same when Facelets is used instead of JSP). The deferred expression is not immediately evaluated, but created as a ValueExpression object and the getter method behind the expression is executed everytime when the code calls ValueExpression#getValue(). … Read more

Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable

1. Target Unreachable, identifier ‘bean’ resolved to null This boils down to that the managed bean instance itself could not be found by exactly that identifier (managed bean name) in EL like so #{bean}. Identifying the cause can be broken down into three steps: a. Who’s managing the bean? b. What’s the (default) managed bean … Read more

JSTL in JSF2 Facelets… makes sense?

Introduction JSTL <c:xxx> tags are all taghandlers and they are executed during view build time, while JSF <h:xxx> tags are all UI components and they are executed during view render time. Note that from JSF’s own <f:xxx> and <ui:xxx> tags only those which do not extend from UIComponent are also taghandlers, e.g. <f:validator>, <ui:include>, <ui:define>, … Read more