Passing the backing bean as a parameter to a Facelet include

You can use <ui:param> for that. It needs to be nested in the <ui:include>. <ui:include src=”https://stackoverflow.com/questions/16842912/formView.xhtml”> <ui:param name=”ParameterBean” value=”#{Bean}” /> </ui:include> Unrelated to the concrete problem, standard Java Naming Conventions state that instance variable names must start with lower case. You should change your code in such way that respectively parameterBean and #{bean} will be … Read more

JPA Entity as JSF Bean?

You could do so. It’s technically possible. But it does (design)functionally not make any sense. You’re basically tight-coupling the model with the controller. Usually the JPA entity (model) is a property of a JSF managed bean (controller). This keeps the code DRY. You don’t want to duplicate the same properties over all place, let alone … Read more

How to provide a file download from a JSF backing bean?

Introduction You can get everything through ExternalContext. In JSF 1.x, you can get the raw HttpServletResponse object by ExternalContext#getResponse(). In JSF 2.x, you can use the bunch of new delegate methods like ExternalContext#getResponseOutputStream() without the need to grab the HttpServletResponse from under the JSF hoods. On the response, you should set the Content-Type header so … Read more