cancel
Showing results for 
Search instead for 
Did you mean: 

code for retriving the selected multiple values of checkbox group

Former Member
0 Kudos

Hi

I have to display the selected checkboxs from checkbox group into a table

Accepted Solutions (1)

Accepted Solutions (1)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi Padma,

Can you describe how you are managing your context?

Regards

Abhimanyu L

Former Member
0 Kudos

it contains a node with name "Personal" and attributes under this node as firstName,SecondName,Gender(Radio buttons)Sports(checkbox group) and Interests(TextEdit)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi Padma

You might be filling values in Sports using Enumeration datatype or Value Set.

The Control CheckBoxGroup has an Event onToggle just create an action on that

event and add two parameters to that method in Action Tab of the View.

1. checked type boolean

2. index type integer

Also you need to map these parametrs

using the piece of code:

wdDoModifyView

if(firstTime){

IWDCheckBoxGroup chg = (IWDCheckBoxGroup)view.getElement("<UI element ID>");

IWDParameterMapping params = chg.mappingOfOnToggle();

params.addSourceMapping("checked","checked");

params.addSourceMapping("index","index");

}

now on each click of check box this method will get executed and you can directly

read the index of the check box and it is checked or unchecked ..

hope it is clear.

Regards

Abhimanyu L

Message was edited by:

Abhimanyu Lagishetti

Former Member
0 Kudos

The code which i used for creating sports checkbox group is .Here the prob is if i click on anyting it is not getting displayed..by default BaseBall is getting displayed that also one time only..if i go back to the view where this sports checkbox group is present BaseBall is not getting displayed and the previously selceted values are also not cleared


  String sports[]=new String[]
    {
    	"BaseBall",
    	"Cricket",
    	"Hockey",
    	"FootBall" ,
    	"Swimming",
    	"Running",
    	
    };
    List SportsNodeEle=new ArrayList();
    for(int i=0;i<sports.length ;i++)
    {
    	 IPrivateGeneralInfoView.IPersonalElement sportsVal=wdContext.createPersonalElement();
	     sportsVal.setSports(sports<i>);
		 SportsNodeEle.add(sportsVal);
			
    }
    wdContext.nodePersonal().bind(SportsNodeEle);

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi Padma,

You have to use this code to put the valid values for sports in the sports attribute.

You can put this code in wdDoInit().

IModifiableSimpleValueSet valueSet = wdContext.nodePersonal().getNodeInfo().getAttribute(IPublicTestComp.IPersonalElement.SPORTS).getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();

valueSet.put("CRICKET", "Cricket");

valueSet.put("BASKET", "Basket Ball");

valueSet.put("TT","Table Tennis");

Also check my previous reply which is modified.

Regards

Abhimanyu L

Message was edited by:

Abhimanyu Lagishetti

Former Member
0 Kudos

Hi by working in the way you suggested it is giving runtime error as given below...

I wrote the code in wdDoInit() method.

can u help me..its very urgent and one more thing..Instead of sports i took Months and the context is MonthsOfyear--Node

MonthName---Attribute



IWDAttributeInfo att=wdContext.nodeMonthsOfYear().getNodeInfo().getAttribute (IPrivateChkView.IMonthsOfYearElement.MONTH_NAME);

	 IModifiableSimpleValueSet values=att.getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();

		   values.put("0","January");

		   values.put("1","February");

		   values.put("2","March");

		   values.put("3","April");

		   values.put("4","May");

		   values.put("5","June");

		   values.put("6","July");

		   values.put("7","August");

		   values.put("8","September");

		   values.put("9","October");

		   values.put("10","November");

		   values.put("11","December");

	 wdContext.nodeMonthsOfYear().addElement(newElement);

and the error is

Error stacktrace:

com.sap.tc.webdynpro.progmodel.context.ContextException: AttributeInfo(ChkView.MonthsOfYear.MonthName): must not modify the datatype of a mapped attribute

at com.sap.tc.webdynpro.progmodel.context.AttributeInfo.getModifiableSimpleType(AttributeInfo.java:323)

at com.sap.tc.webdynpro.chkbox.ChkView.wdDoInit(ChkView.java:130)

at com.sap.tc.webdynpro.chkbox.wdp.InternalChkView.wdDoInit(InternalChkView.java:122)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.doInit(DelegatingView.java:61)

at com.sap.tc.webdynpro.progmodel.controller.Controller.initController(Controller.java:215)

at com.sap.tc.webdynpro.progmodel.view.View.initController(View.java:274)

at com.sap.tc.webdynpro.progmodel.controller.Controller.init(Controller.java:200)

at com.sap.tc.webdynpro.progmodel.view.ViewManager.getView(ViewManager.java:540)

at com.sap.tc.webdynpro.progmodel.view.ViewManager.bindRoot(ViewManager.java:422)

at com.sap.tc.webdynpro.progmodel.view.ViewManager.init(ViewManager.java:130)

at com.sap.tc.webdynpro.progmodel.view.InterfaceView.initController(InterfaceView.java:41)

at com.sap.tc.webdynpro.progmodel.controller.Controller.init(Controller.java:200)

at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.displayToplevelComponent(ClientComponent.java:134)

at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.init(ClientApplication.java:374)

at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:593)

at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)

at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:249)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doGet(DispatcherServlet.java:48)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:385)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:263)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:340)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:318)

at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:821)

at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:239)

at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)

at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:147)

at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)

at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(Native Method)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)

Former Member
0 Kudos

Move the code to modify the value set from the view controller context to the controller context that contains the mapping origin (probably the componnent controller in your example).

Armin

Former Member
0 Kudos

And what has this to do with a CheckBoxGroup?

Armin

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Abhimanyu L,

Can you show me how to "directly read the index of the check box and its checked and unchecked?

Thanks and WR,

Jane

Former Member
0 Kudos

Read the Javadoc for CheckBoxGroup:

" Data binding:

The context must provide a node X with X.cardinality = 0..n and X.selection = 0..n with an attribute y. The type of y must be a simple type like String. The number of check boxes is the number of node elements, their texts are the values of attribute y, and <b>the selection of the check boxes is determined by the (multiple) selection of the node.</b>

The property texts must be bound to the attribute y. "

To find out the selection, check the selection of the node. See

IWDNode.getLeadSelection()
IWDNode.isMultiSelected(int index)

Armin