cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to Display Checkbox Text

Former Member
0 Kudos

Hi All,

I am using a Checkbox group in my application.I have binded my checkboxvalue attribute to an simple type.The problem is at runtime I am unable to view the Texts that I have binded.I have given the cardinality for my node as 0-n and the selection as 0-n.If I give these properties I am unable to view anything.Kindly let me know what could me the problem.

Thankx,

Naaz.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ,

No none of the checkboxes are selected by default.

This is the code I have written in the button action to get all the checkbox values that I have selected:

String selected = null;

IPrivateWDSampleView.ICheckBoxNode node=wdContext.nodeCheckBox();

int size=node.size();

for(int i=0;i<size;i++)

{

IPrivateWDSampleView.ICheckBoxElement element=node.getCheckBoxElementAt(i);

if(node.isSelected(i))

{

selected=element.getCheckBoxVals();

wdComponentAPI.getMessageManager().reportSuccess("This is the selected value"+selected);

}

}

I am having three checkboxes namely:one,two,three.If i select two and press on submit button I am getting the output as :

This is the selected value:One

This is the selected value:Two

instead of just I have to get This is the selected value:Two.

Former Member
0 Kudos

To find out which checkboxes are selected use code like this:


for (int i = 0; i < wdContext.nodeCheckBoxNode().size(); ++i)
{
  if ( wdContext.nodeCheckBoxNode().getLeadSelection() == i
    || wdContext.nodeCheckBoxNode().isMultiSelected(i) )
  {
    /* checkbox at index i is checked */
  }
}

Armin

Former Member
0 Kudos

U can use thsi code to select witch check box is selected

for(int i=0;i<wdContext.nodeSport().size();i++)
		{
			IPrivateEditView.ISportElement ele=wdContext.nodeSport().getSportElementAt(i);
			IPrivateEditView.ISportNode node=wdContext.nodeSport();
			if(node.isMultiSelected(i)==true)
			{
				String batch=ele.getSport();
				wdComponentAPI.getMessageManager().reportSuccess(batch);
			}
		}

Reagrds,

Swathi

Answers (11)

Answers (11)

Former Member
0 Kudos

Hi Armin,

Ya now i got it thank you.

Thankx,

Naaz

Former Member
0 Kudos

Hi Armin,

I have used the same code but still I am not getting the correct output.This is the output I am getting if i select second dropdown.

Checkbox #0 is checked

Checkbox #1 is checked

whereas I have to get only Checkbox #1 is checked.

Thankx,

Naaz

Former Member
0 Kudos

Hi,

Don't give "+i" in for loop give "i+" and test.

Regards,

H.V.Swathi

Former Member
0 Kudos

Sorry, my mistake, I had table selection in mind. Remove the test for lead selection from my code.

Armin

Former Member
0 Kudos

That's nonsense.

Armin

Former Member
0 Kudos

Hi Armin,

It was showing really.I have written the same code that you have given to me.

Former Member
0 Kudos

Come on. When you use this code, do you get the correct output or not?


for (int i = 0; i < wdContext.nodeCheckBoxNode().size(); ++i)
{
  if ( wdContext.nodeCheckBoxNode().isMultiSelected(i) )
  {
    /* checkbox at index i is checked */
    wdComponentAPI.getMessageManager().reportSuccess("Checkbox #" + i + " is checked");
  }
}

Armin

Edited by: Armin Reichert on Dec 12, 2008 11:33 AM

Former Member
0 Kudos

Hi Armin,

Ya i tried Swathi's code it is working fine .The code which you have sent was showing the first checkbox value.

Thankx,

Naaz

Former Member
0 Kudos

I don't think so.

Armin

Former Member
0 Kudos

Hi ,

Thankx a lot Swathi my issue has been resolved.

Former Member
0 Kudos

Did you try Swathis code also for the case when just one checkbox is selected?

Armin

Former Member
0 Kudos

Thankx a lot Swathi.You resolved my issue.

Former Member
0 Kudos

Hi ,

I am still getting the same output.I am unable 2 understand why.

Former Member
0 Kudos

Did you use the code I have given?

Armin

Former Member
0 Kudos

Hi Swathi,

The code is working perfectly but when I am selecting any one of the checkbox I am getting the first checkbox by default.

I have given the cardinality as 0-n and selection as 0-n

Former Member
0 Kudos

Have u bind the texts property of check box to Value attribute. Rebuild project and deploy and then run it.

Regards,

H.V.Swathi

Edited by: H.V Swathi on Dec 8, 2008 10:29 AM

Former Member
0 Kudos

Hi,

what's the code you writtten onToggle of the checkBoxGroup. ?

Regards,

ramesh

Former Member
0 Kudos

What does that mean "I am getting the first checkbox by default."? Do you mean the first checkbox is selected by default?

Armin

lokesh_kamana
Active Contributor
0 Kudos

Hi,

U cannot use a simple type for insertind the text to the checkbox.

So continue with the way suggested by swathi.

Thanks & Regards,

lokesh

Former Member
0 Kudos

Hi Satya,

Thankx for the quick reply.Cant i get the values from the simple type instead of giving it manually.

Former Member
0 Kudos

hi,

no u cannot get for check box

Regards,

Satya.

Former Member
0 Kudos

No u cant use simple type for check box.

U can do this U can put this method in the wdInit() method.

public void wdDoInit()
  {
    //@@begin wdDoInit()
    String arr[]={"Cricket","Football","Tennis","Reading",
"Yoga","Swimming","Hockey","Softball",
"Teaching","Singing","Cooking","Dancing"};
for(int i=0;i<arr.length;i++)
{
	IPrivateEditView.ISportElement e=wdContext.nodeSport().createSportElement();
	wdContext.nodeSport().addElement(e);
	e.setSport(arr<i>);
}
    //@@end
  }

set that cardinality to 0..n and selection to 0..n.

Regards,

H.V.Swathi

Former Member
0 Kudos

hi,

in case of check boxes, it will not work with

a simple type

write code similar to this according to your requirement

if(firstTime){

String[] names = {"one","two","three"};

for(int i=0;i<names.length;i++){

IPrivateCheckView.IXElement nelem =wdContext.nodeX().createXElement();

wdContext.nodeX().addElement(nelem);

nelem.setName(names);

}

}

where X is a node ,

Name is attribute under node X

of type string

bind the texts property of the check box group to the Node X

Regards,

Satya.