cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a UI Field non-editable using Java?

Former Member
0 Kudos

How do I do so can anyone advise?

I have a variable "mode" that determine if it is in view or edit mode.

I want to code in such a way that if it is in view mode, I will lock the fields and make them not-editable. Any idea how can I do that?

Thanks a million!

Accepted Solutions (1)

Accepted Solutions (1)

pravesh_verma
Active Contributor
0 Kudos

Hi Jackson,

1) Create a boolean variable in the context and bind it with the readOnly property of the Input UI field.

2) Write a code so that when the mode is locked you set the boolean value to true else false.


wdContext.currentContextElement().setReadOnly(true);

in other case:


wdContext.currentContextElement().setReadOnly(false);

Please note that readonly is only for theinput field, if you have some otehr UI element try this with the enable property of that UI element.

In this case you have to set the enable property to False.

I hope this solves the issue.

Thanks and Regards

Pravesh

Former Member
0 Kudos

That's easy!! Thanks once again!

Former Member
0 Kudos

how about a search button? can it be readonly too? That means non-clickable?

pravesh_verma
Active Contributor
0 Kudos

Hi Jackson,

Yes it can be also set to readOnly. But there is a different property called enabled. As I have explained above you can follow the same approach and bind the button property "enabled" with the boolean attribute and as per requirement can change that.

I hope this helps!

Thanks nad Regards,

Pravesh

Answers (0)