• Geek Answers Handbook

    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
    html jsf
    Nikola Sep 06 '12 at 14:00
    source share
    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
    joerno 07 . '12 7:20

    More articles:

    • Cordon geolocation plugin does not get location from GPS for Android - android
    • Using OWL API, how to get a class or an individual name - semantic-web
    • Servlet Servicing Method Purpose - java
    • Programming Interface - primefaces
    • It is effective to determine if a number from a series of subsequent numbers is in an ordered list. (in Python) - python
    • How to make a recursive LINQ query? - c #
    • StickyTableHeaders Cloned Width Problem - jquery
    • can anyone tell me what this syntax is called and what it does? - javascript
    • Unity and random exception "Index outside the array" - dependency-injection
    • java.time.DateTimeFormatter cannot parse without delimiters - java

    All Articles

    Geek Answers | 2019