How to include and evaluate xhtml content represented as a String into a page using JSF?
Posted
by happycoder
on Stack Overflow
See other posts from Stack Overflow
or by happycoder
Published on 2010-06-11T14:13:21Z
Indexed on
2010/06/11
16:43 UTC
Read the original article
Hit count: 194
jsf
Hi!
Im using JSF 1.2 and need to include xhtml content represented as a String in a bean.
So, how can I get the content from a bean in xhtml but represented as a String and render it on the page? Here is an example:
myPage.xhml
...
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
...
<h:panelGrid>
<a4j:outputPanel ajaxRendered="true">
<ui:include src="#{myBean.someContent}" /> <!-- this doesnt work! -->
</a4j:outputPanel>
</h:panelGrid>
...
MyBean.java
...
class MyBean ... {
private String someContent = "<h:panelGrid><h:outputText value=\"Name:\"/><h:inputText value=\"#{anotherBean.name}\" /></h:panelGrid>";
public String getSomeContent() {
return someContent;
}
public void setSomeContent(String someContent) {
this.someContent = someContent;
}
}
i.e. in myPage.xhtml I want to read the someContent variable and include the content before page evaluation. The ui:include-tag nor the h:outputText escape="false" seems to work.
/happycoder
© Stack Overflow or respective owner