I am using facelets. I have one class:
public class foo{
public static String foofookoo() {
return "tookoofoopoo";
}
}
How do I access this on my JSF page because this is a simple POJO not a managed bean?
I am using facelets. I have one class:
public class foo{
public static String foofookoo() {
return "tookoofoopoo";
}
}
How do I access this on my JSF page because this is a simple POJO not a managed bean?
Assuming that it is really a POJO and that your code example is simply bad; the only way to access it nicely is to make it a property of an existing managed bean:
@ManagedBean
public class Bean {
private Pojo pojo;
public Bean() {
pojo = new Pojo(); // Create/load it somehow.
}
public Pojo getPojo() {
return pojo;
}
}
Then in the JSF page associated with the managed bean just do:
<h:outputText value="#{bean.pojo.property}" />
which roughly translates to pageContext.findAttribute("bean").getPojo().getProperty()
.
But, if it is on the other hand actually an utility class with static non-getter methods, then your best bet is to wrap it in an EL function. You can find a Facelets-targeted example in this answer.