cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Checkboxgroup

Former Member
0 Kudos

Hi!

I unfortunately have a problem with checkboxgroups. For the action onToggle I mapped the Parameters in wdDoModifyView() the following:

if (firstTime) {

// Get references to all checkboxgroups

IWDCheckBoxGroup cg1 = (IWDCheckBoxGroup) view.getElement("CheckBoxGroup1");

// Link the client-side event parameter 'index' to the server-side action parameter 'cgindex'

cg1.mappingOfOnToggle().addSourceMapping("index", "cgindex");

cg1.mappingOfOnToggle().addSourceMapping("checked", "cgchecked");

// Hardcode the checkboxgroup name for each action parameter

cg1.mappingOfOnToggle().addParameter("cgname", cg1.getId());

}

In my onToggle action, how can I find out now whether the checkbox at index cgindex is checked??

Would be great if you can help me with that.

Bye,

Timo

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

The mapped parameter 'checked' will give you what the checked value of the toggled checkbox has. It will be a boolean of what the new entry is.

Cindy

Former Member
0 Kudos

Hi Cindy,

for my understanding:

'checked' contains the value of the toggled checkbox, not if there is any checked chaeckbox in the checkboxgroup??

I mean, is 'checked' the checked-value for checkbox with the index 'index'??

Bye,

Timo

Former Member
0 Kudos

Timo,

Yes, the checked value is for the checkbox indicated by the index that the user just toggled.

You might want to look at the UI element guide for CheckBoxGroup at: http://help.sap.com/saphelp_nw04/helpdata/en/0a/16e94d251a164392f3a3415c6d643a/frameset.htm

Cindy

HuseyinBilgen
Active Contributor
0 Kudos

Hi Bogi,

Althought I've created a value node, add a value attribute, map the attribute to a simple type created, and set texts property of checkboxgroup to this value attribute, nothing displayed on view when deployed?

Answers (1)

Answers (1)

Former Member
0 Kudos

Sorry for my poor English ><

Step1. Create a Value Node under Root Element


       Name : CheckBoxGroup
       cardinality : 0 .. n
       selection : 0 .. n
	   
	   Context
	      |--- CheckBoxGroup 

Step2. Create a context element under CheckBoxGroup


       Name : CKItem ( type : String )

	   Context
	      |--- CheckBoxGroup 
		            |---- CKItem
	   

Step3. Put an CheckBoxGroup UI object on Layout .


       Property colcount : 3 ( for example )
       texts : CheckBoxGroup.CKItem
	   

Step4. Create a new Action named "ChkGroupToggled"


       with two parameter
       1. cgIndex ( int )
       2. cgChecked ( boolean )
	   

Step5. Code implementation


  public static void wdDoModifyView(IPrivateTest941124View wdThis, IPrivateTest941124View.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
  {
    //@@begin wdDoModifyView
    try{
		if (firstTime) {
		  IWDCheckBoxGroup cg1 = (IWDCheckBoxGroup) view.getElement("CheckBoxGroup1") ;
		  cg1.mappingOfOnToggle().addSourceMapping("index", "cgIndex") ;
		  cg1.mappingOfOnToggle().addSourceMapping("checked", "cgChecked") ;
		  
		}
 
    }
    catch( Exception e ){
		
    }
    //@@end
  }

Step6. Code implementation


  public void onActionChkGroupToggled(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, int cgIndex, boolean cgChecked )
  {
    //@@begin onActionChkGroupToggled(ServerEvent)
    try{
		// Context Element "Info" is just for debug prupose only
		wdContext.currentContextElement().setInfo( cgIndex + " : " + cgChecked ) ;
    }
    catch( Exception e ){
    }
    //@@end
  }
  

Step7. Add an UI object ( ex : TextEdit ) on Layout and bind the "value" parperty with context element "Info"

Step8. Bind action with onToggle Event in the UI element created in Step3.

Step9. Deploy and Run your webdynpro