Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Back again - set focus

Avatar

Former Community Member

Hi again,

I've been struggling with setting focus on each instance of a field within a repeating subform. My subform is limited to 5 instances. Min of 1.

As the user exits the only textfield in the subform, I have a new instance creating. I want the focus set to the new instance but I have not been able to get anything to work. My latest attempt has been to try to pass a count using the instancemanager to a variable in the setfocus string.

Here is what I have thus far. I know I need to resolve the node but that process is confusing the heck out of me. I've read and re-read everything I've been able to find but I havent been able to wrap my head around that part successfully.

Can anyone point me in the correct direction or suggest a better solutions? TIA!

form1.Account_Client_Information.Long_Title.Account_Long_Title::exit - (JavaScript, client)

var oSubform = xfa.resolveNode("Long_Title");

var oNewInstance = oSubform.instanceManager.addInstance(1);

xfa.form.recalculate(1);

var count = (this.instanceManager.count)

xfa.host.messageBox("Text Field Index in new Subform: " + count);

var vfocindex = xfa.resolveNode("Account_Long_Title[count]");

xfa.host.setFocus(vfocindex);

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

The addInstance method will return the subform that you want so you only need to do;

var oNewInstance = Subform1.instanceManager.addInstance(1);

xfa.host.setFocus(oNewInstance.Account_Long_Title)

Regards

Bruce

 

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

The addInstance method will return the subform that you want so you only need to do;

var oNewInstance = Subform1.instanceManager.addInstance(1);

xfa.host.setFocus(oNewInstance.Account_Long_Title)

Regards

Bruce

 

Avatar

Former Community Member

Bruce Thanks! So simple. Feel like an ID 10 T.

Worked like a charm.