cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Checkbox Group

Former Member
0 Kudos

Hi,

In my program I have some dropdowns and a checkbox group. The checkbox group's labels are created dynamically by what is chosen in one of the dropdowns. All of the dropdowns and the checkbox group are all mapped to the Component Controller’s Context. The problem I am having is that I am binding the text to the checkbox group right after the dropdown is chosen (in its own function and NOT in wdDoInit or wdDoModifyView), and it’s clearing the dropdown's selection (and any other dropdowns in the form).

Is there a better way to dynamically assign the values to the checkbox group so that it doesn't clear those values?

Thanks,

Jonathan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Can u restate your problem

Especially these few lines ?

<b>The problem I am having is that I am binding the text to the checkbox group right after the dropdown is chosen (in its own function and NOT in wdDoInit or wdDoModifyView), and it’s clearing the dropdown's selection (and any other dropdowns in the form).</b>

Regards

Bhaarthwaj

Former Member
0 Kudos

For the dropdown onSelect, it executes makeCoursesVisible.

makeCoursesVisible, first makes the checkbox group visible, then assigns values to the checkboxes depending on what value was selected, it then binds the coursename to the node.

As soon as it does this, it clears out the values from the dropdowns. If I comment the bind line out, it doesn't clear them out, but it also doesn't assign the values to the checkboxes.

If you want to see the code, let me know.

-Jonathan

Former Member
0 Kudos

Hi,

Yep ! Paste the code plz. And as much of it as possible...:)

Former Member
0 Kudos

 public void onActionmakeCoursesVisible(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionmakeCoursesVisible(ServerEvent)
		wdContext.currentContextElement().setCoursesVisible(WDVisibility.VISIBLE);
		wdContext.currentContextElement().setTextVisible(WDVisibility.NONE);
		String department = wdContext.currentDropDownElement().getDepartment();
		String[] courseNames = null;
		List coursesNames = new ArrayList();
		if (department.equals("English"))
		{
			courseNames =
				new String[] { "ENG 010", "ENG 020", "ENG 030", "ENG 100", "ENG 101", "ENG 200", "ENG 400" };
		}
		else if (department.equals("Music"))
		{
			courseNames =
				new String[] { "MUS 010", "MUS 020", "MUS 030", "MUS 100", "MUS 101", "MUS 200", "MUS 400" };
		}
		else if (department.equals("Computer Science"))
		{
			courseNames =
				new String[] { "CIS 010", "CIS 020", "CIS 030", "CIS 100", "CIS 101", "CIS 200", "CIS 400" };
		}
		else
		{
			wdContext.currentContextElement().setTextVisible(WDVisibility.VISIBLE);
			wdContext.currentContextElement().setCoursesVisible(WDVisibility.NONE);
			courseNames = new String[] { "" };
		}
		for (int i = 0; i < courseNames.length; ++i)
		{
			IPrivateChooseCoursesToRoll.ICourseNameElement aCourse = wdContext.createCourseNameElement();
			aCourse.setCourse(courseNames<i>);
			coursesNames.add(aCourse);
		}
		wdContext.nodeCourseName().bind(coursesNames);
    //@@end
  }

Former Member
0 Kudos

Did you bind the CheckBoxGroup.texts property at design time to attribute CourseName.Course?

The code looks ok to me. But how did you bind the drop-down lists? Changing the content of the CourseName node should have no influence on the drop-down lists.

You can also omit the ArrayList if you replace the line

coursesNames.add(aCourse);

by

wdContext.nodeCourseName().addElement(aCourse);

and delete the last line

wdContext.nodeCourseName().bind(coursesNames);

Armin

Former Member
0 Kudos

Thanks Armin,

That fixed it right up!

-Jonathan

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Jonathan,

Assign a defaultvalue to a new attribute created . change its value on select of dropdownbykey

and check its value in modify and do the rest

Regards

Rohit

Former Member
0 Kudos

Could you be a little more specific? I've already tried checking in WdDoModifyView to see if the value equals what was chosen in the dropdown, but i always get a java.lang.NullPointerException error.