Marcus Loza
Marcus Loza

Reputation: 185

Get selected values in a checkbox group in xpages

I have a checkbox group and I am trying to get the values ​​selected via SSJS, but so far I have not been successful. I've tried several syntaxes, such as: document1.getItemValueArray ("nameField") and getComponent ("nameField") getSelectedValues ​​();

Does anyone know a way to get the selected values ​​from a checkbox group?

Upvotes: 0

Views: 474

Answers (1)

Paul Stephen Withers
Paul Stephen Withers

Reputation: 15729

document1.getFirstItem("nameField").getValues() may be what you want. If it's one value, it will be a string, not a Vector, which may be a problem with getItemValueArray().

With ODA (OpenNTF Domino API), we extended the getItemValue() method to take a second parameter and cast the result to that kind of object. That has a big benefit for this kind of scenario, allowing getItemValue("nameField", ArrayList.class) to always return an ArrayList even for a single value, plus ArrayList is a much better and more modern Java (so relevant also for SSJS) construct than a Vector.

Upvotes: 1

Related Questions