cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Radiobutton opitons text?

former_member182426
Active Contributor
0 Kudos

Hi,

I am not able to add text for radiobutton groups. Like

I have created one Radio Button Group. In public void wdDoInit() i am wrote code like this but it's not effecting...


public void wdDoInit()
  {
    wdContext.createRADIOGROUPElement().setEBELN("Red");
    wdContext.createRADIOGROUPElement().setEBELN("Blue");
    wdContext.createRADIOGROUPElement().setEBELN("Green");
  }

But its shoing empty in radiobuttongroupbyindex element in my Webdynpro Layout. I am using SAP NetWeaver Developer Studio.

But i am able to do this in SE80 tcode using WebDynpro ABAP.

Here i am not getting how to do this.

Plz any guidance on this...

Regards,

Shankar.

Accepted Solutions (1)

Accepted Solutions (1)

former_member197348
Active Contributor
0 Kudos

Hi Shankar,

Are you using the code shown exaclty? or posted the simplified code.

public void wdDoInit()
  {
    wdContext.createRADIOGROUPElement().setEBELN("Red");
    wdContext.createRADIOGROUPElement().setEBELN("Blue");
    wdContext.createRADIOGROUPElement().setEBELN("Green");
  }

If you are using exactly the same code, change and try with this .

public void wdDoInit()

{
   IPrivate<View>.IRADIOGROUPElement element1 = wdContext.createRADIOGROUPElement();
  element1.setEBELN("Red");
  wdContext.nodeRADIOGROUP().addElement(element1);

 IPrivate<View>.IRADIOGROUPElement element2 = wdContext.createRADIOGROUPElement();
element2.setEBELN("Blue");
wdContext.nodeRADIOGROUP().addElement(element2);

IPrivate<View>.IRADIOGROUPElement element3 = wdContext.createRADIOGROUPElement();
element3.setEBELN("Green");
wdContext.nodeRADIOGROUP().addElement(element3);
  }

Feel free to revert in case of any issues.

Regards,

Siva

former_member182426
Active Contributor
0 Kudos

Hi,

I am using same code which i posted.

And i tried as you given,

IPrivateStartView.IRADIOGROUPElement element1 = wdContext.createRADIOGROUPElement();
element1.setEBELN("Red");

Here StartView is view name. In above code when we type

IPrivateStartView.
it will show a list to choose. In the same way when i type
element1.
it's nothing is showing.

And it's showing the error like this.

IPrivateStartView.IRADIOGROUPElement cannot be resolved or is not a type

Regards,

Shankar.

gill367
Active Contributor
0 Kudos

Hi,

use the following code in your wddoinit()


IPrivateStartView.IRADIOGROUPElement EL1 = wdContext.nodeRadioButton().createRADIOGROUPElement();
    EL1.setEBELN("red");
    wdContext.nodeRADIOGROUP().addElement(EL1);
    
	IPrivateStartView.IRadioButtonElement EL2 = wdContext.nodeRadioButton().createRADIOGROUPElement();
	EL2.setEBELN("BLUE");
	wdContext.nodeRADIOGROUP().addElement(EL2);
	
	IPrivateStartView.IRADIOGROUPElement EL3 = wdContext.nodeRadioButton().createRADIOGROUPElement();
	EL3.setEBELN("GREEN");
	wdContext.nodeRADIOGROUP().addElement(EL3);

if you are getting that error

IPrivateStartView.IRADIOGROUPElement cannot be resolved or is not a type

then right click and select organise imports.

and yeah one more thing texts property of radiobuttongroupbyindex UI element should be bound to EBELN context attribute.

Hope this will solve your problem.

Sarbjeet Singh Gill

former_member182426
Active Contributor
0 Kudos

Hi,

I wrote code like this. It's worked.

String[] rbop = new String[]
    {
    	"Red", "Green", "Blue"
    };
    
    for(int i = 0; i < rbop.length; ++i)
    {
		IPrivateStartView.IRadioGroupElement el = wdContext.nodeRadioGroup().createRadioGroupElement();
		el.setEBELN(rbop<i>);
		wdContext.nodeRadioGroup().addElement(el);
    }

And, Now my dought is, Why it's not worked when i wrote code like this...

String[] rbop = new String[]
    {
    	"Red", "Green", "Blue"
    };
    
    for(int i = 0; i < rbop.length; ++i)
    {
		wdContext.nodeRadioGroup().addElement(rbop<i>);
    }

Plz can you tell me the difference....

Regards,

Shankar.

gill367
Active Contributor
0 Kudos

HI

The other method is not working because in that you are trying to add a string varibale inplace of element type which is not possible.

AddElement( ) is method related to context node which will except only IWDNodeElement type of argument. Here you are trying to pass string which is not correct.

So thats why first you have to create an element and then set what ever attribute you want to set and then add it to the node.

Hope it is clear.

regards,

sarb

former_member182426
Active Contributor
0 Kudos

Hi,

Thank you very much sarbjeet singh , Actually i am trying this concept as

There will be 3 Radio Button options. When ever i select any radio button that corresponding option text has to display in

TextView element.

I tried in this way but it's not working.

public void onActionSELECTITEM(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {    

    String seloption;
    int i;
    i = wdContext.nodeRadioGroup().getLeadSelection();
    seloption = wdContext.nodeRadioGroup().currentRadioGroupElement().getEBELN(i);
 
  }

I am new to JAVA coding concepts Plz guide me....

Regards,

Shankar.

gill367
Active Contributor
0 Kudos

Hi

use the following code

public void onActionSELECTITEM(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {    
 
    
   String  seloption = wdContext.currentRadioGroupElement().getEBELN();
 
  }

it will directly put the current selected value of EBELN in the string Seloption.

Then you can use it to display in the textview.

regards,

Sarbjeet Singh,

former_member182426
Active Contributor
0 Kudos

Hi,

I got it. I wrote like this code and it's working fine.

public void onActionSELECTITEM(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    String seloption;
    int i;
    i = wdContext.nodeRadioGroup().getLeadSelection();
    seloption = wdContext.nodeRadioGroup().currentRadioGroupElement().getEBELN().toString();
    wdContext.currentContextElement().setVIEWTEXT(seloption);
  }

Thanks for all your Guidence.....

Regards,

Shankar.

Former Member
0 Kudos

The Web Dynpro way of doing that is to just bind the "text" property of the TextView to the attribute that provides the text for the radio buttons. Then the text view will always display the selected button's text without any code.

Armin

Answers (2)

Answers (2)

Former Member
0 Kudos

Verify that you have bound the "texts" property of RadioButtonGroupByIndex to attribute "EBELN" and that you have added the context elements to the "RADIOGROUP" node. Your code only creates context elements but doesn't add them to the node.

Armin

chander_kararia4
Contributor
0 Kudos

Hi Shankar,

You may do this like -

1. Go to Dictionaries -> Data Types -> Simple Types

2. Create a simple type, say RadioOptions.

3. Under Enumerations, do the enteries as you require. In values - you need to write there id & In Discription - Text you want in GUI.

4. Create a context, say X (cardinality - 1:n & Type - select simpletype "RadioOptions" created in above step)

5. In your properties view - Add child RadioButtonByKey / Index

6. Map SelectedKey / texts property with context X

Its done....deploy & enjoy.

Best Regards

Chander Kararia

Edited by: Chander Kararia on Oct 9, 2009 5:35 PM

former_member182426
Active Contributor
0 Kudos

Hi,

Create a context, say X (cardinality - 1:n & Type - select simpletype "RadioOptions" created in above step)

In this Type- Select Simpletype from where we have to do this. In properties tab i didnt find any property Type

So i have created a ValueNode and ValueAttribute.

For Value Node i have set the properties like this.

Cardinality 1:n

For Value Attribute i have set the properties like this.

Type com.sap.examples.welcome.RadioOptions

In Output it's showing only one radiobutton with out description .

Regards,

Shankar.