Xpages repeat value depends on a value outside of the repeat - xpages

Hardly I managed to build a repeat with 2 inputText that do some math depending on the value of another inputText(let's call it outside_input) which is outside the repeat.
Everything is working fine, but the problem is when I want to change the value of the outside_input the values of the inputTexts inside the repeat doens't automatically refresh. I have a partial refresh on the repeat.
The 2 fields inside the Repeat are binded with a viewScope. And the script is on the first field on the onChange method.
Is there a way that when I change the outside_input I could trigger the onChange method of the inner fields?

Put the partial refresh on the first field (that has the onChange event) and specify to refresh the repeat or a panel that contains the repeat and whatever other fields rely on it. Note that this requires your onChange event to be server side code not client side code.
Howard

Related

Xpages chained djFilteringSelect in separate dialogs

I am trying to make a 2nd djFilteringSelect using a #Dbcolumn depending on the value selected in the 1st djFilteringSelect control. That's a common task, using a partial refresh. However, each of the controls is within a dialog control from the extension library. One dialog pops up, the user selects a value, and automatically the 1st dialog closes and the 2nd opens. YOU CAN'T SEEM TO REFRESH THE FIELD (I'm guessing b/c it's not in the DOM). I've tried writing the first value to to an computed field and/or a text box on the main Xpage using CSJS and then looking for that value for the second lookup. Also, tried with SSJS, etc. I tried do updates and writing to fields on either the onChange or on the click of button. How do I go about using the selected value of the first to do the lookup in the 2nd?
You can use a single dialog control where you hide and show the relevant controls. I am using this approach in several apps.

onclick event of button requires double click

I have a viewPanel using DB2 for the datasource. I have created a comboBox containing all the possible viewPanel columns, a radioGroup to select ASC or DESC, a comboBox containing all the possible viewPanel columns with an onchange event to partially update the values in another comboBox, and a final comboBox that has all the values from DB2 according to the previous comboBox value that has an onchange event to partially update the viewPanel.
The onclick event for my button has this code and does a partial update of the viewPanel:
var sort:String = getComponent('comboBox1').getValue();
var order:String = getComponent('radioGroup1').getValue();
var vp = getComponent('panel_container').getData()[0];
vp.setDefaultOrderBy(sort + " " + order)
The problem is that I have to click the button twice to get the code to actually run. The first click is ensuring the onchange event is fired, then the second click activates the code. I have tried to use Full Update and checking the 'Set partial execution mode' with the partial update.
How do I get the onclick event for my button to work on the first click?
Too much event tango :-) Here is what I would do:
bind your combo boxes to viewScope variables. That's more robust than getValue() and allows to change the UI later (fancy some d&d)
use the combo box client side, not the server side onChange() event. This would require all values to be send down eg via Ajax
when you click the button make sure the fields are inside the panel you refresh
Hope that helps

Action Button works differently if added to the DataView

I have a button that calls a Dialog that has a combo box bound to a sessionScope variable. The combo box contains a list of form names that I use to then call an XPage to create a new document. The first value in the forms list is "" so the user needs to select a value. I have a button with the onClick event of:
var c = getComponent("CreateDocDialog");
sessionScope.put("ssSelectedForm","")
c.show();
I have the button and dialog on a customControl with a repeatControl and when the button to open the dialog is clicked the ssSelectedForm is null and the current value of the combo is blank, which is exactly what I want it to be. However, if I add the same button and dialog to a customControl with a dataView control the dialog displays but ssSelectedForm is not null so the combo box displays the last value of ssSelected. I have placed the button outside the dataView, in several of the facets on the dataview, but all with the same results.
Very confusing.
Bill,
I am going to answer the same as my comment since I am pretty confident about what I said.
Go ahead and change the scope from sessionScope to viewScope. I had a similar issue once, and I 'fixed' it by clearing out the sessionScope variable after I used it. This worked, but I realized that it was not necessary, and that by changing to viewScope the lifecycle will be shorter and there was no need to clear out the value when I was done with it.
I don't know why this fails when added to the data view, but if this fixes it that would be all that matters.

XPages - Value Picker - Update Multiple fields

I would like to use a dominoViewValuePicker to update several fields with several values. I have seen that it is possible to add multiple values to the one field. Is it possible to select one document from a dominoViewValuePicker and then use multiple values from this document to update multiple fields on the XPage?
Certainly. Just set the onChange event to refresh those fields (preferably, they all go into a panel so that you can do a partial refresh rather than a full refresh) and compute the values (either from the script on the onChange or just by the formulas for determining those values in the first place).
If you do set up a panel for a partial refresh, make sure to give the panel an ID. By default panels are not given ID's and are not available to refresh.

Xpages - How to save values to list box that have been entered by client side javascript

I have a list box that I am adding and removing items with client side javascript. The issue is that these new values are not being saved to the list box(binded to field). The only value that comes back is the original one that was set in list box. The values are all there on the client since I can loop through the array. How can I get these values to replace the value that is currently there?
By default the listbox have a validator that you may not see during save, (you need to add error controls to see it) and the validator do not accept new values added using CSJS
If you set disableValidators="true" in the listbox control you suppress the validator and the save works fine. you also need to select the entries in the listbox using CSJS before you save,
Credits goes to Jesse Gallagher
Thomas
In the List Box properties, you must to set mutiple = true

Resources