How to deactivate spellcheck in p:inputTextarea PrimeFaces?
Asked Answered
F

2

6

I would like to deactivate the spell check in a PrimeFaces inputTextarea.

spellcheck="false" is not possible in a p:inputTextarea

<p:inputTextarea value="#{mybean.cardescription}" 
                 cols="95"
                 autoResize="true"
                 rows="20"/>
Fatherland answered 22/10, 2014 at 8:25 Comment(2)
use jQuery on page load $('inputTextId').attr('spellcheck','false'), or you should write a custom renderer for the inputTextarea.. Also I'm not sure if the Html5RenderKit of OmniFaces would work on PrimeFaces inputTextarea but it should be.Epner
Hello, thank you for your reply. I don't know how to use jQuery, where should I put this code please ? In the xhtml document or in a bean ?Fatherland
I
1

Use following:

<h:head>
    <h:outputScript   name="/js/util/disableSpellCheck.js"/> 
</h:head>

$('inputTextId').attr('spellcheck','false')
Inequality answered 17/7, 2017 at 0:20 Comment(0)
A
1

Although I'm pretty late to the party I think there is a cleaner way to do it without Javascript. When you include the namespace xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" you can pass attributes through to the generated HTML and you can hence directly set the attribute in your JSF code:

<p:inputTextarea value="#{mybean.cardescription}" 
        cols="95"
        pt:spellcheck="false"
        autoResize="true"
        rows="20"/>

This works for all HTML attributes that do not have a corresponding JSF attribute in their components.

The pt is selected here to avoid namespace collisions with PrimeFaces. You'll also find p for passthrough attributes pretty often.

Amateurism answered 19/10, 2023 at 14:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.