Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Can i use a variable instead of a fixed TextField?


Level 8


I have to set the readOnly property to some fileds DYNAMICALLY (i mean, until run time, i dont know Which fields are readOnly and which are not?  .

So, i want to replace the TextField1 dynamically with all the fileds in the below syntax. So, can i put some variable in the position of TextField1? if so, How can i do that?

xfa.resolveNode("VISITOR.Page3.SubFrom1.TextField1").access = "readOnly";

xfa.resolveNode("VISITOR.Page3.SubFrom1.MyVariableComesHere").access = "readOnly";

How can i put the variable in the red position?

THank you

3 Replies


Level 7


Not sure if this is the answer you are looking for. You can set field.access = "protected"

The user cannot change it, however you can still assign values to it.


The processing application prevents the user from making any direct changes  to the container's content. Indirect changes such as calculations can occur. The  container does not participate in the tabbing sequence, though an application  may allow the selection of text for clipboard copying. Protected containers do  not generate any events.

I use this all the time.

Good luck!



Level 8

Sorry, am not looking that!!

Say, i have 5 fields, then, i want to make them readOnly, then i hv to write as below,

xfa.resolveNode("VISITOR.Page3.SubFrom1.TextField1").access = "readOnly";

xfa.resolveNode("VISITOR.Page3.SubFrom1.TextField2").access = "readOnly";

xfa.resolveNode("VISITOR.Page3.SubFrom1.TextField3").access = "readOnly";

xfa.resolveNode("VISITOR.Page3.SubFrom1.TextField4").access = "readOnly";

xfa.resolveNode("VISITOR.Page3.SubFrom1.TextField5").access = "readOnly";

Actually, my requirement is differnent (I know at run time only...that Wht wht fields i hv to set readOnly and wht wht fields should okay for input enable), for that reason i want to use a VARIABLE in the 'position' of TextField1, TextField2.....like bleow

var myVariable

myVariable = TextField1


xfa.resolveNode("VISITOR.Page3.SubFrom1.myVariable").access = "readOnly";

PLs. let me know Can i sue a variable like that? if so, what is the correct syntax (pls.  suggest me a SYNTAX error free code, bcz am very very beginner to this)

THank you


Level 5

Hi ,

If you want to use a variable then you can just change the following line

xfa.resolveNode("VISITOR.Page3.SubFrom1.myVariable").access = "readOnly";


xfa.resolveNode("VISITOR.Page3.SubFrom1."  + myVariable).access = "readOnly";

this will add the value of the myVariable to the end of the string and then call the resolveNode.

Hope this helps