cancel
Showing results for 
Search instead for 
Did you mean: 

Check Box

former_member1193316
Participant
0 Kudos

Hi,

How to work with check box kindly let me know.

i created a value attribute of type booaln and i binded to the UI element checkbox of property type checkd.

i coded like this

wdcontext.currentcontextelement.setcheck(true);

i m getting ant error "Null PointerException"

how to work with chek box

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

What is your node structure.Do you have a value node and under it value attribute or directly value attribute under root context.

If you have value attribute under valuie node then change the cardinality of the node to 1:n.

Regards,

Sudhir

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi

create a checkbox ui element.Then u create a value attribute (check) of type boolean.

Then u bind the checked property of checkbox to the above attribute.

Then if u want to check that one use the following code

wdContext.currentContextElement().setVAName(true);

In the above case va name is :Check

Hazrath

former_member1193316
Participant
0 Kudos

Here also i follwd the same what u mentioned.

but when i executed application its giving juva null pointer exception.

guide me how to read value.

like when i check checkbox, i should get success message

when i uncheck it, sohuld get warning message.

Former Member
0 Kudos

Hi,

> guide me how to read value. like when i check checkbox, i should get success message when i uncheck it, sohuld get warning message.

1. In wdDoModifyView() write this:


if(firstTime){
   IWDCheckBox chk = (IWDCheckBox) view.getElement("<ID of the CheckBox in the view>");
	  
   if(chk != null){
	  chk.mappingOfOnToggle().addSourceMapping("checked", "isChecked");
  }
}

2. Create an action for the onToggle event of the checkbox. Let's say "Toggle" and the corresponding event handler "onActionToggle".

3. Add one parameter of type "boolean" and name it "isChecked". After this step the eventhandler signature would look like:


public void onActionToggle(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, boolean isChecked){}

4. Write the following in the eventhandler method:


if(isChecked)
   wdComponentAPI.getMessageManager().reportSuccess("Success!!");
else
   wdComponentAPI.getMessageManager().reportWarning("Warning.");

Regards,

Satyajit.

Former Member
0 Kudos

Hi,

create a context attribute of type boolean lets say checkedState

Place a check box UI element

From the properties bind its "checked" property to the context attribute in our case checkedState

If you want to access the current state of the check box



wdContext.currentContextElement().getCheckedState();
//To set the state to selected
	  wdContext.currentContextElement().setCheckedState(true);

Regards

Ayyapparaj

Former Member
0 Kudos

Hi,

Where you are getting this error. Could you please post the log.

thanks & regards,

Manoj