Jan 24, 2016 11:37 PM
110 Posts
topic has been resolvedResolved

Bind to inputTexts in a repeat

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 9.0.1
  • Role: Developer
  • Tags: repeate control,binding
  • Replies: 3

I have a field in my notes form called "PairList" (Text, allow multiple value, separator is comma or semicolon).

What I intend to store in that field is like the following:-





I'm creating something that will auto-calculate the points given to a participant based on how many days they've attended an event. So from the above, if they attend 2 days, they'll get 3 points, if they attend for 3 days, they'll get 5 points and so on.

The following is from my designer:-

The repeat above is bound to a viewScope which stores an ArrayList. The ArrayList will then be used to create the "PairList" above to be stored.

Testing the above, I managed to do the following. The (add) and (remove) works perfectly:-

My problem is I don't know where to bind the 2 inputTexts to so that I can retrieve their value and construct the "PairList". I remember David Leedy doing something similar in one of the Ni9 but that one's in Java. My app will mostly be in SSJS and will be maintained by someone only fluent in SSJS so using Java is not an option.

I'm thinking of creating another 2 viewScopes each storing an ArrayList so that those 2 inputTexts can be bound to each of the viewScope. But it just seems weird that to bind a control to a collection which is within a collection (repeat control) itself. Something just doesn't make sense to me. Any suggestions? I'm assuming if it can be done and saved successfully, the next time I open this document, any value in those inputTexts will be auto-populated based on what I previously entered too.

Jan 25, 2016 4:32 PM
453 Posts

If I understand your problem correctly you have one or more documents and you have a field that stores a single value for the days they attended a given event. This field will contain to text values 1 2 3 or 4. I'm not sure from what you are saying but would appear that you are somehow loading a viewscope variable with one or more values and feeding that to your repeat. So the days attended in your repeat would just be the value of the viewscope variable.  

If this does not answer your question then we would need more info on how your data is structured and loaded.

Jan 25, 2016 8:38 PM
110 Posts
Sorry I wasn't clear on the flow of the app

What I'm currently doing in the EventType Form. Sure the easiest way to do the UI for the Point field is to just give the user a Multiline Edit Box and have them key in the day/point (day and point is separated with a pipe "|") pair separated by a new line but that'll require me to explain to all of them how to enter which in the long run I'll need to explain again if there's new user. I'd figure using a repeat control might make the job easier to the user. The point field does not limit to 4 elements (pair) only. There can be any number of pairs.


"PairList" in my first post and "Point" in this post refer to the same thing (field).

Jan 30, 2016 2:55 PM
453 Posts
So .....

so when finished your event attendance document will contain the value 5 from the Academic lookup. So your issue is displaying these values in the repeat.

so I assume that you have a view of attendance documents categorized by person and so in your definition of the repeat you can filter where the person in the view == @User or ????

What I do is generally create a panel and lets call it panelData and connect it to the attendance view and call the dataSource vwCollection. Then put your repeat inside the panelData and bind it to vwCollection

the repeat will now be working with the subset of attendance documents. Make sure the attendance view contains columns for Event Days and Points (I will use these names) I generally call the the repeat Collection Name: veData because what the repeat returns acts just like a ViewEntry and you can use the viewEntry methods. So add a ComputedField with a value of veData.getColumnValue("Days") for the Days another for Points etc.

I hope I understand what you are doing, there might be a better way but this is what I do, and I seldom use anything but repeats. I did a show for David on repeat controls that might help