I’m making an XPages form called “Project”. It has a tab control with seven tabs. The first one is a summary tab with totals on it. The other 6 tabs each contain a repeat control of response documents for each of the types of one-to-many details. (labor, materials, travel, etc.).
If I open an existing Project, go to the Labor tab and edit the number of hours for Jane Doe, then switch tabs, the changed hours are not yet saved to disk, but they are somewhere cached on the server for me. Where are they?!? They aren’t sent back to the browser as hidden fields… they’ve got to be on the requestScope object somewhere?
I’ve got client-side JavaScript that gets totals for the Labor tab by using onblur events to trigger an update function I’ve written, but I’d hate to rely on it because it’s client-side JavaScript, and therefore inherently something to be mistrusted (even though I trust the users not to hack values at the browser-end).
How the heck can I loop through the Hours values within a repeat control and get a total number using server-side JavaScript?
I misread read your post. You can try something like the following in the postOpenView event. Assuming that your view has a column that does totalling this will get the last entry in the view and get the total for the designated column.
var nav:NotesViewNavigator=viewDocuments.createViewNav();
Subject: I’ve found a workaround but I’d still like the answer.
What I’m looking for is a way to loop through a repeat control and get the values, even if they’re on a non-current tab, even if the user changed the values then changed to a different tab and hasn’t saved yet. Using a view or viewnavigator object won’t work because that’s only what’s saved to disk, which show wrong numbers for what I’m trying to do.
My current workaround is to still use the client-side script and have the total as a hidden field on that tab. Then I use a computed field to display that field value (again) on the first summary tab. In this way, the total on the summary tab is always current even for unsaved data.
However, if I could loop through the repeat control to get whatever the user has entered even if it hasn’t been saved yet, I would have less moving parts.