In my JSF 2.0 project i have 2 classes:
public class driver {
private String name = "Mr Taxi";
public String getName {
return name;
}
}
…
import driver;
public class CarBean {
private Driver driver;
private String anotherProperty;
public String getAnotherProperty {
return anotherProperty;
}
}
And the jsf file:
<!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:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
The car has a driver with name: #{carBean.driver.name} <--------Focus on this one
</h:body>
</html>
I know that the above example do not work. But is there any way to access the driver object getName method from the jsf file? Or do I have to make a new method “getDriverName” in the CarBean class?
Can you please help med guys? B.R
Look at this example, its simple enough:
Injecting Managed beans in JSF 2.0