cancel
Showing results for 
Search instead for 
Did you mean: 

Name of label?

Former Member
0 Kudos

Hi, i want know the name of a label associated to an input. I write:

String nombre = wdContext.getNodeInfo().getAttribute(CampoFecha).getSimpleType().getFieldLabel();

but don´t work, why?

Thanks,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Victor,

String nombre = wdContext.getNodeInfo().getAttribute(CampoFecha).getSimpleType().getFieldLabel();

for you to get the label of the input field in the way metioned above follow the steps below:

1. Create a context named CampoFecha

2. In your project Dictionaries>Local Dictionary>Data Type>Simple Types> Right Click and create Simple Type. You can name it as Name and the type should be string. Goto Representation tab and put the text value of the label that is displayed on your screen in the field called field label.

3. Goto Context CampoFecha Properties and specify its type to the simple type being created by us.(browse button ... at the end).

4. Bind this context to your Input Field.

Now, your above code will give you the value that you are trying to fetch.

Regards,

Murtuza

Former Member
0 Kudos

It´s a good solution, but the input field has another value...

Former Member
0 Kudos

Hi Victor,

You can use input field name and not its value as some common text

Say ur input field <b>Id</b> is 'Name' whose value is Victor

Then Label Id can be 'Name_label'

Regards

Smruti

Message was edited by:

Armin Reichert

Former Member
0 Kudos

Hi Victor,

This is used when you want to get the values dynamically for the error messages based upon the context binded to those UI elements.

Input field value is different than the field label in simple types.

Regards,

Murtuza

Former Member
0 Kudos

I create a new simple type, in the tab representation in field label write Fecha.

I go to the layout, and in the field label in text assignt the new simple type... but when i execute the application, the label field is blank...

Former Member
0 Kudos

Victor,

Assign that simple type to your Context attribute binded to your Input Field.

Regards,

Murtuza

Former Member
0 Kudos

Ok, i assign it.

The simple type is fecha.

The context is fecha_context.

The label is FechaNacimiento_label.

The input is FechaNacimiento.

Now?

String nombre = wdContext.getNodeInfo().getAttribute(xxxxxxx).getSimpleType().getFieldLabel();

Former Member
0 Kudos

I obtain it.

Thanks,

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Victor,

Do you want the Label UI element associated with Inputfield UI element?

If yes, then when you create the UI elements you must follow a naming convention

e.g. if attribute is name then

label id = name_label & inputfield id = name

Then u can search label as

IWDLabel label_name = (IWDLable)view.getElement(<name>+"_label");

As for your labelFor Query, it is used to get Inputfield name from label and not viceversa

e.g.

IWDLabel label_in = (IWDLabel)view.getElement(<label_id>);

String in_id = label_in.getLabelFor(); //retuns id of inputfield

Regards,

Smruti

Message was edited by:

Armin Reichert

Former Member
0 Kudos

Hi Victor Capi,

To fetch label name, create context value attribute "Name" and associate this with label property. You can access label name by

wdContext.currentContextElement.getName();

Regards,

Ganga.

Former Member
0 Kudos

I don´t unsertand... the label has the property "labelFor" --> Nombre that it´s the inputField... I think that if i have the inputfield, i can get the name of the field associate to it.

Former Member
0 Kudos

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

String text = label.getText();

Former Member
0 Kudos

Hi Victor,

R you binding the text property of label to a context attribute that is a simple type?

If yes then in that simple type under representation tab you will get a field called <b>Field Label</b> and you need to set the property there after that you will get the value the way you are reading.

Regards,

Murtuza

Former Member
0 Kudos

I don´t understand... I have a label and an input. The property of labelFor is associate to the input... I want the name of the label, how?

CampoFecha is --> IPrivateDatosView.IContextElement.FECHA_NACIMIENTO

Thanks,

Message was edited by:

Victor Capi

Former Member
0 Kudos

Hi Victor,

Write this in WDDoModifyView()

IWDLabel lab = (IWDLabel)view.getElement("<LabelID>");

lalab.getText();

But the way you were mentioning before for that you need to bind the text property of your lable to a context that is a simple type defined in local dictionary and then follow the steps given by me in the previous reply.

Regards,

Murtuza