Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

how do you reset a subform?

Avatar

Former Community Member
i find the scripting in desiigner one of the hardest things ive ever tried - ive been working on this on & off for the past year and have not been able to write the simplest scripts. well.. i dont really understand the language all the scripting is explained in..



today i have been trying all day to reset a subform and havent been able to.



the subform is called 'radiobuttons1' i have CTRL-clicked on one of the radiobuttons within the subform to maybe help you people understand what im trying to do.. and i get this:



xfa.resolveNode("F.P1.radiobuttons1.question1.#field[0]")



so.. how would i reset all fields in 'radiobuttons1' subform? without having to type out all fields.. pretend i have 1000 fields i want to reset and another 1000 i dont want to reset.. there must be a way to do this.



xfa.host.resetData("radiobuttons1"); ??



xfa.F.P1.radiobuttons1.resetData() ??



xfa.host.resetData("F.P1.radiobuttons1"); ??



is there anywhere with kiddy instructions such as 'click on that button that looks like this..' 'in order to do .....,type the following words in that blank space you can see at the top of your screen...etc' even the supposedly simple explanations use words i dont understand..



thanks in advance hopefully - i want to die
3 Replies

Avatar

Former Community Member
You're right: Scripting forms isn't an easy task. I hope this will help you out.



It's quite easy to reset an individual object. For instance, to reset question1 in the radiobuttons1 subform, you could place a regular button on the form and use the following script (written in JavaScript) which assumes the button is placed outside the radiobuttons1 subform:



radiobuttons1.question1.rawValue = "";


What you want to do is find all the radio button lists inside a particular subform (radiobuttons1) and reset them all. Let's extend this to resetting any type of object (field) so that this solution doesn't just work on radio button lists.



What you need is a script which will look at all the objects inside a subform (radiobuttons1 in this case) and reset them all:



var oQuestionList = radiobuttons1.nodes;

var nQuestionCount = oQuestionList.length;



for (var i = 0; i < nQuestionCount; i++)



{



var oQuestionNode = oQuestionList.item(i);



var sClassName = oQuestionNode.className;



if (sClassName == "field" || sClassName == "exclGroup") // radio button lists are called "exclusion groups" in XFA

{

// reset field or radio button list

oQuestionNode.rawValue = "";

}

}


This JavaScript script, placed on the Click event of a button outside the radiobuttons1 subform, will find all objects inside the radiobuttons1 subform and reset them.



You can easily modify this script to reset objects inside another subform by changing the name of the subform in the following line: "var oQuestionList =
radiobuttons1.nodes;"



Stefan

Adobe Systems

Avatar

Former Community Member
crispo@adobeforums.com wrote:

> find the scripting in desiigner one of the hardest things ive ever tried - ive been working on this on & off for the past year and have not been able to write the simplest scripts. well.. i dont really understand the language all the scripting is explained in..

>

> today i have been trying all day to reset a subform and havent been able to.

>

> the subform is called 'radiobuttons1' i have CTRL-clicked on one of the radiobuttons within the subform to maybe help you people understand what im trying to do.. and i get this:

>

> xfa.resolveNode("F.P1.radiobuttons1.question1.#field[0]")

>

> so.. how would i reset all fields in 'radiobuttons1' subform? without having to type out all fields.. pretend i have 1000 fields i want to reset and another 1000 i dont want to reset.. there must be a way to do this.

>

> xfa.host.resetData("radiobuttons1"); ??

>

> xfa.F.P1.radiobuttons1.resetData() ??

>

> xfa.host.resetData("F.P1.radiobuttons1"); ??

>

> is there anywhere with kiddy instructions such as 'click on that button that looks like this..' 'in order to do .....,type the following words in that blank space you can see at the top of your screen...etc' even the supposedly simple explanations use words i dont understand..

>

> thanks in advance hopefully - i want to die





If you want to reset only a specific subform, you have to pass in the

full SOM expression to the resetData() method. The most reliable way to

do this is to use the 'somExpression' property. So, for example,

suppose you have a "reset" button inside of your radiobuttons1 subform

that you want to reset only that subform. You could do it with the

following line of code on the click event for your button:

xfa.host.resetData(this.parent.somExpression);

This will reset only the data in the radiobuttons1 subform.



See if this helps. If not, feel free to ask question.



Justin Klei

Cardinal Solutions Group

www.cardinalsolutions.com