Trace
Trace

Reputation: 13

"Visible" property on XPages edit boxes based on checkbox selection(s)

I am new to XPages, and I have a Check Box Group ('checkBoxGroup1') as one of my design elements that contains three choices ("CBChoice1", "CBChoice1", "CBChoice1"). Underneath that Check Box Group, I have three edit box fields which correspond to the three checkbox choices. Each time one of the checkbox choices is chosen, I want the corresponding edit box to become visible.

Whenever one of the checkboxes is chosen, I have it partially refreshing the panel that the edit boxes are in, but I cannot figure out the code in each of the edit box's visible property. I started with

getComponent('checkBoxGroup1').getValue() == "CBChoice1"

which kind of works, but isn't the answer. I also tried

var valueArray = getComponent('checkBoxGroup1').getSelectedValues();
valueArray[0] == "CBChoice1";

which seems more on target, but I was getting the following browser error:

Error 500 HTTP Web Server: Command Not Handled Exception

I notice that in the computed code for the visibility property, it is SSJS. I feel like I am close, but have been banging my head for too long. Any help would be greatly appreciated.

Upvotes: 1

Views: 160

Answers (1)

Michael G. Smith
Michael G. Smith

Reputation: 665

A better method might be to bind the checkbox group to either a document data source or a scope variable.

Then, your visible property might look something like:

@Contains(myDoc.getItemValueArray("checkBoxFieldName"),"CBChoice1");

or

@Contains(viewScope.get("checkBoxScopeVar"),"CBChoice1");

Upvotes: 3

Related Questions