简体   繁体   中英

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?

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, eg

.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> .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM