In a jsf page, I'm using ui:include.
index.xhtml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>test</title>
</h:head>
<h:body>
<ui:include src="included.xhtml" >
<ui:param name="myBean" value="beanA" />
</ui:include>
</h:body>
</html>
and I want to pass a Bean name so the included content can call a method on the bean
included.xhtml:
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
This is from included file.<br/>
#{myBean[greeting]}
</ui:composition>
the bean is as simple as possible
BeanA.java:
package com.test;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
@ManagedBean
public class BeanA implements Serializable{
public String getGreeting(){
return "hello from BeanA";
}
}
looking at a previous answer on stackoverflow: JSF 2: how to pass an action including an argument to be invoked to a Facelets sub view (using ui:include and ui:param)? I was expecting this to work, but it doesn't. The 'This is from included file' text gets printed, but not the BeanA property. Could anyone tell me why?
Eventually I'm wanting to pass to the included file both a bean name and the method name which I want to invoke. For the moment though, I can't even get this simpler example to behave as I'd expect.
Mojarra 2.2.0, Apache Tomcat/7.0.55