I am trying to use Glassfish 4.0 with Java EE 7 XML namespaces to test the sample below.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>Title</title>
</h:head>
<h:body>
<h:form>
<ul>
<ui:repeat value="#{appLoad.movieList}" var="movie">
<li>
<h:link value="#{movie.title}" outcome="movie" includeViewParams="true">
<f:param name="id" value="#{movie.id}"/>
</h:link>
</li>
</ui:repeat>
</ul>
</h:form>
</h:body>
</html>
It links to the following page movie.xhtml
:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<f:metadata>
<f:viewParam name="id" value="#{appLoad.movieId}"/>
<f:event listener="#{appLoad.movieDetail()}" type="preRenderView"/>
</f:metadata>
</h:head>
<h:body>
<h:form>
<h:panelGrid columns="2">
<h:panelGrid columns="1" width="400">
<h:panelGrid columns="1">
Title : <h:outputLabel value="#{appLoad.movie.title}"/>
</h:panelGrid>
</h:panelGrid>
</h:panelGrid>
</h:form>
</h:body>
</html>
The #{appLoad}
backing bean is
@ManagedBean
@RequestScoped
public class AppLoad {
@EJB
private MovieFacade movieFacade;
private Movie movie = new Movie();
private List<Movie> movieList;
private int movieId;
@PostConstruct
public void movieDetail(){
movieList = movieFacade.findAll();
movie = movieFacade.find(movieId);
System.out.println(movieId);
}
// Getters+setters.
}
When the index page is run, and the link is been clicked, the url outrightly changed to
result.xhtml?id=8
But no data is been displayed. Its comes as blank. I figured out that #{appLoad.movieId}
is null
. In other words, the <f:viewParam>
does not set this request parameter.
The only work around I had was to change the XML namespaces back to the older version.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
I'm guessing I'm getting something wrong here. How is this problem caused and how am I supposed to use the new XML namespaces?