Pushpa
Pushpa

Reputation: 109

How can we make a TextArea uneditable in GWT?

Is there any way for making TextArea uneditable in GWT?If yes please help me to sort out the problem. Thanks in advance.

Upvotes: 2

Views: 2197

Answers (2)

Braj
Braj

Reputation: 46841

setReadOnly(true)

is translated into HTML as shown below

 <textarea class="gwt-TextArea gwt-TextArea-readonly" name="name" readonly=""></textarea>

This will work fine in HTML 4.01 and HTML5 but not in XHTML as defined at HTML readonly Attribute

In XHTML, attribute minimization is forbidden, and the readonly attribute must be defined as

<textarea readonly="readonly">

Try this one to disable a text area field that will work in all the cases.

textArea.getElement().setAttribute("readonly", "readonly");

Same thing applies for

setEnabled(false)

that is translated into HTML as shown below

<textarea class="gwt-TextArea" name="name" disabled=""></textarea>

This will work fine in HTML 4.01 and HTML5 but not in XHTML as defined at HTML disabled Attribute

In XHTML, attribute minimization is forbidden, and the disabled attribute must be defined as

<input disabled="disabled" />

Try this one to disable a text area field that will work in all the cases.

textArea.getElement().setAttribute("disabled", "disabled");

Upvotes: 4

salk31
salk31

Reputation: 1015

setEnabled(false)

?

That seems to work nicely across browsers.

Upvotes: 2

Related Questions