Gondim
Gondim

Reputation: 3048

Displaying a Hyperlink on a h:inputTextarea

I'm trying to display a hyperlink clickable in a inputtextarea is that possible? If no, how could I do it without the inputtextarea but same effects as a textarea?

Upvotes: 1

Views: 1302

Answers (1)

BalusC
BalusC

Reputation: 1109865

That's not possible with a HTML <textarea> element, so the JSF <h:inputTextarea> already can't do much for you.

If you don't need it to be editable, just use a <h:outputText escape="false"> to not escape HTML.

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

Bring in some CSS if necessary to make it look like a textarea, e.g.

.someClass {
    display: block;
    width: 300px;
    height: 100px;
    border: 1px solid gray;
    white-space: pre;
}

Be careful with XSS attacks however when it concerns user-controlled input! Running the Jsoup#clean() on the input may be helpful in this.

But if you need it to be editable, then you basically need a HTML editor component. The standard JSF component library doesn't ship with such a component. Head to a 3rd party component library like PrimeFaces which has a <p:editor>.

Upvotes: 1

Related Questions