0
votes

I have a Check box group, whose values are computed by using the selected values of another Check box group. So when I do

var check6:com.ibm.xsp.component.xp.XspSelectManyCheckbox = getComponent("check6");
ArrSelected = check6.getSelectedValues();

to get the selected values, the following exception occurs:

Error calling method 'getSelectedValues()' on java class   'com.ibm.xsp.component.xp.XspSelectManyCheckbox'
java.util.ArrayList incompatible with [Ljava.lang.Object;

Check6 gets its values from a session scope variable that is computed on beforePageLoad event and I have also set the default value.

Note that this does not happen onload of the page, but when the first partial refresh happens. Does anyone know what this exception indicates?

Thanks a lot!

2
Please provide a some source code of the two components.Sven Hasselbach
Are you using the variable ArrSelected in the check box group which is computed? If yes then how? You can compute the check box group simply using Add Formula Items, so your code would be something like <xp:checkBoxGroup id="checkBoxGroup2"......><xp:selectItems><xp:this.value><![CDATA[#{javascript:getComponent("checkBoxGroup1").getSelectedValues();}]]></xp:this.value></xp:selectItems></xp:checkBoxGroup> (assuming original check box group name is checkBoxGroup1) and it would work.Naveen
@Naveen Yes, I am using the values of checkBoxGroup1 as a key to get entries and then the corresponding documents from a view. And the value of checkBoxGroup2 is an array composed by the values of a particular field of the documents. Sven, I isolated these two lines of code and even if I add a print, the exception occurs again.kmak

2 Answers

1
votes

Bind the value of the selectItems for the second check box group to precisely the same expression the first checkbox group's value attribute is bound to.

This article provides a lengthy description of the reason why, but here's a very quick summary: if you ask a component what its value is, it has to ask the data it's bound to. So skip the component, and ask the data yourself.

So, if your first group looks like this:

<xp:checkBoxGroup value="#{currentDocument.FirstField}">...

Then your second group should look like this:

<xp:checkBoxGroup value="#{currentDocument.SecondField}">
  <xp:selectItems value="#{currentDocument.FirstField}">
</xp:checkBoxGroup>

When the user's selection in the first group is posted to the data source, the second group will reflect the changes because they're linked to the same property on that data source. Slight caveat: if your page includes any required fields, you may need to skip validation on the onchange event that triggers the second group to recalculate.

-1
votes

the reason is simple, this class has no method getSelectedValues() (as far as I can see it, look here for more info: http://public.dhe.ibm.com/software/dw/lotus/Domino-Designer/JavaDocs/XPagesExtAPI/8.5.2/index.html?overview-summary.html)

Maybe you could bind the control to a scoped variable and then access this variable to compute your other values?