简体   繁体   English

在 ah:inputTextarea 上显示超链接

[英]Displaying a Hyperlink on a h:inputTextarea

I'm trying to display a hyperlink clickable in a inputtextarea is that possible?我正在尝试在 inputtextarea 中显示可点击的超链接,这可能吗? If no, how could I do it without the inputtextarea but same effects as a textarea?如果没有,如果没有 inputtextarea 但效果与 textarea 相同,我怎么能做到这一点?

That's not possible with a HTML <textarea> element, so the JSF <h:inputTextarea> already can't do much for you.这对于 HTML <textarea>元素是不可能的,因此 JSF <h:inputTextarea>已经无法为您做太多事情。

If you don't need it to be editable, just use a <h:outputText escape="false"> to not escape HTML.如果您不需要它是可编辑的,只需使用<h:outputText escape="false">不转义 HTML。

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

Bring in some CSS if necessary to make it look like a textarea, eg如有必要,请引入一些 CSS 使其看起来像文本区域,例如

.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!小心XSS 攻击,但是当它涉及用户控制的输入时! Running the Jsoup#clean() on the input may be helpful in this.在输入上运行Jsoup#clean()可能对此有所帮助。

But if you need it to be editable, then you basically need a HTML editor component.但是如果你需要它是可编辑的,那么你基本上需要一个 HTML 编辑器组件。 The standard JSF component library doesn't ship with such a component.标准 JSF 组件库不附带这样的组件。 Head to a 3rd party component library like PrimeFaces which has a <p:editor> .前往第 3 方组件库,例如 PrimeFaces ,它有一个<p:editor>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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