Programmatically created html components in managed jsf beans
I have the following code:
<div id="mws-navigation">
<ul>
<li><p:commandLink
value="#{contentMB.msg.welcome_title.value}" actionListener="#{cleanUpMB.alChangeArea}"
styleClass="mws-i-24 i-home" action="#{welcomeMB.aLoadDashboard}" global="false" /></li>
<li><p:commandLink
value="#{contentMB.msg.layout_menu_measures.value}"
rendered="#{userSessionMB.measureEdit or userSessionMB.measureCreate}"
styleClass="mws-i-24 i-table-1" global="false" />
<ul>
<li><p:commandLink
value="#{contentMB.msg.layout_menu_mm_findMeasures.value}"
rendered="#{userSessionMB.measureEdit}"
actionListener="#{cleanUpMB.alChangeArea}"
action="#{chooseMeasureControllerMB.aChoose}" /></li>
<li><p:commandLink
value="#{contentMB.msg.layout_menu_mm_newMeasures.value}"
rendered="#{userSessionMB.measureCreate}"
actionListener="#{cleanUpMB.alChangeArea}"
action="#{newMeasureControllerMB.aNew}" /></li>
</ul>
</li>
</ul>
</div>
which I want to create from a JSF managed bean. I know that there are java components for Primefaces that I can use and link them as a model, but how can I generate pure HTML tags:
<ul>
<div>
...
?
+1
1 answer
An easy way would be to return some HTML from a bean backup:
@Named
@RequestScoped
public class HtmlController implements Serializable {
private static final long serialVersionUID = 1L;
public String getSomeHtml(){
return "<h1>Some HTML from a bean</h2>";
}
}
And paste this into the JSF part:
<h:outputText value="#{htmlController.someHtml}" escape="false" />
But I think that for your case it would be better to create your own component, there you can also bind to beans support. One example of how to do this can be found here or take a look at the Java EE 6 tutorial .
+2