Aurum
Aurum

Reputation: 35

How do I render a String containing HTML code that a bean returns?

I have got a bean that have a method that checks if a user is logged in and returns a String containing HTML code. Is there any way that I can render this String on the webpage after it has been returned?

Upvotes: 0

Views: 507

Answers (1)

noone
noone

Reputation: 19776

Of course. In your managed bean:

public String checkLogin() {
    return "<h2><b>User was not logged in.</b></h2>";
}

And in your xhtml file:

<h:outputText escape="false" value="#{bean.checkLogin()}" />

Upvotes: 2

Related Questions