cancel
Showing results for 
Search instead for 
Did you mean: 

How to get label text for the Input Field in code

Former Member
0 Kudos

Hi,

I have created Two UI elements InputField and Label. I set the property 'labelFor' of the UI element Label to 'InputField'.

This is my requirement . I am having the Id of InputField in the code . I want to get the value of 'text' of the UI element Label.

Please suggest how to proceed.

Points will be rewarded for helpful answers.

Best Wishes

Idhaya R

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Set this properties to ur Input field and Label:

Lable Property->Label for:Ictx_nputField1

Input Filed Property -->id:ctx_InputField1

Create one Context element like:ctx_inputfield

Set the value for label(if ur getting the value from and u want to diplay that)

wdContect.crtContextElement.setctx_inputField1("LABLE');

(ur getting the ID of inputfld from ur code i.e LABEL right)

Regards,

Lavanya.G

Edited by: Lavanya Goriga on Mar 19, 2008 7:24 AM

Former Member
0 Kudos

Hi All,

Thanks for ur immediate replies.

I don't know the id of label inside the code.

I know only the id of the input field.

I want to get the property of the label using the id of Input field.Please let me know if there is any possibilities.

Best Wishes,

Idhaya R.

former_member197348
Active Contributor
0 Kudos

Hi Idhaya,

Using the ID of the label, you can get the ID of the UI Element for which the labelFor property is set. But you can not get the vice versa.

As for as I know the reason is the property of the label it is not property of the UI Element.

regards,

Siva

Former Member
0 Kudos

Not sure why you really need this, but you could do something like


IWDInputField field = (IWDInputField) view.getElement("inputFieldID");
IWDLabel fieldLabel = null;
for (Iterator children = field.getContainer().iterateChildren(); children.hasNext(); )
{
  IWDUIElement child = (IWDUIElement) children.next();
  if (child instanceof IWDLabel)
  {
    IWDLabel  label = (IWDLabel) child;
    if ( field.getId().equals(label.getLabelFor())
    {
      fieldLabel = label;
      break;
    } 
  } 
}

Armin

Former Member
0 Kudos

Thanks a lot Armin.

I got the solution from ur post.

Its a bad practice to check all the labels inside that container.

Will it take time if I put this code in production scenario??

Best Wishes,

Idhaya R

Former Member
0 Kudos

No, time efficiency is not a problem. But I don't understand why you need this.

Armin

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi

small suggestion if ur doubt has cleared.

then select the radiobutton problem resolved

Hazrath

Former Member
0 Kudos

Hi

//first get the ref of Label

IWDLabel label=(IWDLabel)view.getElement("labelid");

//now get the labeltext

label.getText()

write the above code in the wdDoModifyView() method

Hazrath.G

Former Member
0 Kudos

Hi

You don't have to use the InputField inorder to get the Label text.

Follow the code and it is under the method WDdoModifyView()


IWDLabel label = (IWDLabel)view.getElement( "Label");
label.getText();

Regards

- Vinod

*

Edited by: Vinod V on Mar 19, 2008 11:45 AM