[22 Feb 2016 update]
Regarding my previous questions about list box, I can move values between two listboxes and save values after I receive useful answers.
However, if I retrieve those saved values, the listboxes can display the proper values but I cannot move those values and get exception message.
I can only move values between two listboxes if I don't save them.
Therefore, I am planning to have another button for delete listboxes values. I am not sure this is a good practice/design in xpages but I don't have a better method solve the exception.
I am sorry if I caused any inconvenience in this question. Thank you.
[23 Feb 2016 update]
According to the latest comments and answer, I notice that I made a big mistake because I mixed the document and value together.
I decide to break the design into few steps to find the problem occurs.
Due to I can move values between two listboxes and save them. I use another listbox test whether I can retrieve those saved values or not.
The third list box, I use View Scope Variable(similar to listbox B) but I use another variable name to avoid vague.
Here is my code of the third listbox:
var item = getComponent("comboBox4").getValue();
if ((item == null) || (null == item))
{
return "void";
}
else if ((item != null) || (null != item))
{
var lookupItem = @DbLookup(@DbName(),"ViewName", item,3 )
return lookupItem;
}
if (!viewScope.totalItems)
{
viewScope.totalItems = [lookupItem];
}
return viewScope.totalItems;
In the combo box, I use onchange partial update and apply to the third list box . When I run the program, I select a value from the combo box, the third listbox can display the relevant values that I saved before.
That part is fine, so I keep the third listbox for testing. And I put some dummy but unique data (to prevent confusion) related to the combo box.
Here is my first attempt: I choose a value from a combo box, the third listbox can display the relevant values that I saved. I move one value from listbox A to listbox B and click save. The third list box can reflect the value that I save.
In my second attempt: after the first attempt, listbox B still contains the value from listbox A, so this time, I move that value back to listbox A and click save. In the result, in the third list box, I see that value disappear.
At this moment, there is no value in listbox B and I add another two button and write similar code to pretend move values between the third list box and listbox B.
I test it, I select the value from the combo box, the third list box shows the proper values. But when I select a value from the third list box and click the button to move it to listbox A. I think that value will move to the listbox A but the result is nothing happens.
I try the other way, I select a value from listbox A and click the button to move it to the third button. Again the result is nothing happens.
After those fail attempts, I think the problem occurs in the buttons.
Here are the code of the two buttons
Button 1 (move value to the third listbox):
if (viewScope.ALstBoxItem) {
var sel = [].concat(viewScope.ALstBoxItem);
for (var i = 0; i < sel.length; i++) {
viewScope.totalItems.add(sel[i]);
viewScope.AselectItems.remove(sel[i]);
}
viewScope.totalItems.sort();
viewScope.ALstBoxItem = "";
}
Button 2 (move value to the listbox A):
if (viewScope.TotalItemsVariable) {
var sel = [].concat(viewScope.TotalItemsVariable);
for (var i = 0; i < sel.length; i++) {
viewScope.AselectItems.add(sel[i]);
viewScope.totalInItem.remove(sel[i]);
}
viewScope.AselectItems.sort();
viewScope.TotalItemsVariable = "";
}
Recall to comments in the question, I guess I should focus on the values in the listbox, not the button. I search on the internet about hide selected value and find these websites almost can give me the idea to solve the problem:
xpages hiding/showing fields based on a combobox value
Hiding based on previous combo box choice in xpages?
https://www-10.lotus.com/ldd/ddwiki.nsf/dx/dynamical_elements_on_xpages.htm
I try to apply those summary to suit my case but I still cannot move values after I save.
Grateful if someone can give advice please. Thank you very much.
