Skip to content Skip to sidebar Skip to footer

Programmatically Created Html Components In Jsf Managed Beans

I have a following code:
  • Solution 1:

    A simple way would be to return some HTML from the backing bean:

    @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 for your case it would be better to create your own component, there you can also do some binding to backing beans. One example how to do that can be found here or take look at the tutorial of Java EE 6 .


Post a Comment for "Programmatically Created Html Components In Jsf Managed Beans"