Skip to Content
0
Former Member
Jun 25, 2008 at 09:41 AM

Problem selecting a radiobutton

37 Views

Hi all,

I've a problem that is troubling me.

I'm developing a dynamic form which mainly uses radiobuttongroupsbykey, initially I recover with a RFC the options of every question and I store it into a node ("DynamicNode.str.xxx") that I use later.

This part works correctly, the radiobuttons are displayed correctly, the problem comes when I try to set a selected option. If the question has a selected answer c.getRating_text has a length superior to 1, but nothing happens. c.getRating_text contains the selected option, it's a string which is exactly one the radiobutton options.

Can you help me? I can provide you more code if you need it.

wdDoInit
=======
.....
wdContext.currentZhr_Bapi_Appraisal_Getdetail_InputElement().setAppraisal_Id(codeBapi2);
wdContext.currentZhr_Bapi_Appraisal_Getdetail_InputElement().setPernr(pernBapi2);
String planVersion = "01";
wdContext.currentZhr_Bapi_Appraisal_Getdetail_InputElement().setPlan_Version(planVersion);
// execute RFC
wdThis.wdGetBapiEvaluacionesCust0Controller().executeZhr_Bapi_Appraisal_Getdetail_Input();

IAppraisal_DataDetailsOutNode dataSalidaNode = 
 wdContext.nodeOutputDetailsOut().nodeAppraisal_DataDetailsOut();
// I use a hashmap to create the dynamic nodes that contain the posible answers
HashMap map = new HashMap();
IWDNodeInfo node = wdContext.getNodeInfo().addChild("DynamicNode", null,
true,true,false,false,false,true,null,null,null);
		
for (int i=0; i<dataSalidaNode.size(); i++){
	for (int j=0; j<wdContext.nodeOutputScaleOut().nodeProficiencies_QualityScaleOut().size(); j++){
		IWDAttributeInfo info=node.getAttribute("str"+dataSalidaNode.
		getAppraisal_DataDetailsOutElementAt(i).getCounter());
		ISimpleTypeModifiable stm=info.getModifiableSimpleType();
		IModifiableSimpleValueSet svs=stm.getSVServices().getModifiableSimpleValueSet();
		svs.put(""+j, wdContext.nodeOutputScaleOut().nodeProficiencies_QualityScaleOut().
		getProficiencies_QualityScaleOutElementAt(j).getRating_Text());

	}

	Node n;

	// I have two type of elements parents (Grup) and childs (Criteri--->VC)

	if(element.getElement_Type().equals("VC")){
		n = new Criteri(element);
	} else{
		n = new Grup(element);
	}
			
	IAppraisal_DataDetailsOutElement dataSalidaElement =
	wdContext.nodeOutputDetailsOut().nodeAppraisal_DataDetailsOut().
	getAppraisal_DataDetailsOutElementAt(i);
			
	String counter = dataSalidaElement.getCounter();
	String parent = dataSalidaElement.getParent();
// the first element I read from the output of the RFC has 0000 in its counter
	if(parent.equals("0000")) {
		root = n;
	}else if (!parent.equals("0000")){				
		Node nodeParent = (Node) map.get(parent);
		nodeParent.addChild(n);				
	}				
	map.put(counter,n);
}
....

wdModifyView
===========
 private static void pintarForm(Node n, IPrivateDetalleView.IContextNode wdContext, 
com.sap.tc.webdynpro.progmodel.api.IWDView view, IPrivateDetalleView wdThis, 
IWDUIElementContainer containerParent) {
  if(n instanceof Grup) {
	Grup g = (Grup) n;
	for(int i=0; i< g.getChilds().size(); i++) {
		pintarForm((Node)g.getChilds().get(i), wdContext, view, wdThis, theGroup);  			
  	}
} else {
	Criteri c = (Criteri) n;
// I create radiobutton
	IWDRadioButtonGroupByKey theRadioGroup =(IWDRadioButtonGroupByKey) view.
	createElement(IWDRadioButtonGroupByKey.class, "rbg" + c.getCounter());
	// I populate radiobutton with options
	theRadioGroup.bindSelectedKey("DynamicNode."+"str"+c.getCounter());

	if (c.getRating_text().length()>1){
// I select predifined answer?
		theRadioGroup.setSelectedKey(c.getRating_text());
	}
}
}

Edited by: Joan Roda on Jun 25, 2008 2:14 PM

Edited by: Joan Roda on Jun 25, 2008 2:16 PM

Edited by: Joan Roda on Jun 25, 2008 2:31 PM