How to use if, else condition in jsf to display image

For those like I who just followed the code by skuntsel and received a cryptic stack trace, allow me to save you some time. It seems c:if cannot by itself be followed by c:otherwise. The correct solution is as follows: <c:choose> <c:when test=”#{some.test}”> <p>some.test is true</p> </c:when> <c:otherwise> <p>some.test is not true</p> </c:otherwise> </c:choose> You … Read more

JQuery Conflicts with Primefaces? [duplicate]

I had the same problem as described in the question. That’s why I came up with the following solution: Include the primefaces built-in jQuery library (currently 1.4.1) as including an own jQuery library leads to CSS formatting problems. Adding the target=”head” attribute allows for specifying the tag everywhere – e.g. when using templating you not … Read more

JSF 2 – How can I get a context-param value from web.xml using JSF EL?

Steve Taylor’s answer does indeed work, but there is a simpler way using the JSF EL pre-defined object initParam. <h:outputText value=”#{initParam[‘myconstantkey’]}” /> Originally this wasn’t working for me because I forgot to put the single quotes around the key name and was getting back an empty string. This solution should also work with key values … Read more

What is FacesContext used for?

Quote from chapter 6.1 of JSF 2.0 specification: FacesContext JSF defines the javax.faces.context.FacesContext abstract base class for representing all of the contextual information associated with processing an incoming request, and creating the corresponding response. A FacesContext instance is created by the JSF implementation, prior to beginning the request processing lifecycle, by a call to the … Read more

What does the PF function do in Primefaces?

PF is a Javascript function. In Primefaces 4.0 the Javascript scope of widgets changed. Prior to version 4.0 you could open a dialog widget with widgetVar.show();. In Primefaces 4.0 and above the widgets are stored in a Javascript widget array. When you call PF(‘widgetVar’) it is looking for the widget in the array and returning … Read more

Why Facelets is preferred over JSP as the view definition language from JSF 2.0 onwards?

True, JSP has some templating capabilities, but the biggest disadvantage of using JSP in JSF is that JSP writes to the response as soon as it encounters template text content, while JSF would like to do some pre/post processing with it. In JSF 1.0/1.1 the following JSF code <h:outputText value=”first”/> second <h:outputText value=”third”/> fourth would … Read more

Why do I need to nest a component with rendered=”#{some}” in another component when I want to ajax-update it?

Ajax updating is performed by JavaScript language in the client side. All which JavaScript has access to is the HTML DOM tree. If JSF does not render any component to the HTML output, then there’s nothing in the HTML DOM tree which can be obtained by JavaScript upon Ajax update. JavaScript cannot get the desired … Read more

java.lang.IllegalStateException:Could not find backup for factory javax.faces.application.ApplicationFactory

That may happen if your webapp’s runtime classpath is polluted with multiple JSF impls/versions. The org.apache.myfaces entries in the stack trace tells that you’re using MyFaces. This problem thus suggests that you’ve another JSF implementation like Mojarra in the webapp’s runtime classpath which is conflicting with it. It’s recognizable by jsf-api.jar, or jsf-impl.jar, or javax.faces.jar. … Read more

com.sun.faces.numberOfViewsInSession vs com.sun.faces.numberOfLogicalViews

First of all, the Mojarra implementation unintentionally swapped the meaning of those context parameters. So if you have the impression that the description is exactly the other way round than what the literal context parameter name implies, then this is indeed true. com.sun.faces.numberOfLogicalViews This is basically GET request based. Every GET request creates a new … Read more

How to let validation depend on the pressed button?

I understand that you want to filter based on the name input field. The <p:commandButton> sends by default an ajax request and has a process attribute wherein you can specify which components you’d like to process during the submit. In your particular case, you should then process only the name input field and the current … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)