on 10-19-2005 12:10 PM
Hello everyone,
In my application, I have an inputField and a Label.
The labelFor property of the Label directs to the inputField.
How can I get the text of the label from the inputField ?
Any suggestions ?
Thanks.
Ruthie.
Hi Ruthie,
What do you mean by "get the text of the label from the inputField ".
You can write the following code in wdDoModifyView method
IWDLabel lbl=(IWDLabel)view.getElement("");
lbl.getLabelFor();
Regards, Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Nibu.
It didn't work.
I guess its not possible.
Let me give you some points.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please tell exactly what you tried and what did not work.
If the DDIC type has a label text, you can access this as described. If you set the label text in the Label element and want to access it from a controller method, then use data binding, i.e. bind the Label.text property to a context attribute and set it via the attribute value. In the controller method, you can read the attribute value.
Armin
Hi Armin,
If I use data binding it is going to work.
But I thought that I can make use of the property
"labelFor" which appears in the layout for each label
so I can get the text from the inputField which appears
in the "labelFor".I just don't get the meaning of the
"labelFor" property.
Thanks.
Ruthie.
The "labelFor" property connects the Label with the labelled element and is usually assigned in the NWDS view designer. The effect of setting this property is more "visible"/hearable in accessibility mode. Another effect is, if you click on the Label, the labelled element gets the focus.
In most cases, there is no need to access this property at runtime. If you need to access the property value from event handlers, use data binding.
Armin
Hi Ruthie,
Try this code:
IWDAttributeInfo info= wdContext.getNodeInfo().getAttribute(IPrivate<View>.IContextElement.<attrib_name>);
wdComponentAPI.getMessageManager().reportSuccess("Field Label::"+info.getSimpleType().getFieldLabel());
Hope this helps,
Best Regards,
Nibu.
Message was edited by: Nibu Wilson
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anilkumar,rahul,Valery.
I didn't explain it clear enough.
In my application I use the method reportContextAttributeMessage as follows:
private void checkMandatory(String fieldName, String fieldText){
IWDMessageManager messageMgr = wdControllerAPI.getComponent().getMessageManager();
IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute(fieldName);
String value = wdContext.currentContextElement().getAttributeAsText(fieldName);
if (value.length()==0){
messageMgr.reportContextAttributeMessage(wdContext.currentContextElement(),
attributeInfo, IMessageOpenUserApp.MISSING_INPUT,
new Object[] { fieldText },
true);
}
}
So,this method executes validity check to an input field
("fieldName").
In the layout I have an inputField and a Label.
The property labelFor of the Label is set to the inputField.
The parameter "fieldText" should be the text of the label.
Is there a way - that when knowing only the context attribute of the inputField - I can get the text of the Label ? what is the meaning of the labelFor property ?
Thanks.
Ruthie.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ruthie,
You must bind an IWDInputField to some context attribute. Then corresponding label (connected via labelFor property) will use metadata of attribute (unless you eclipse this value by setting label text explicitly for IWDLabel). Namely, it will show "Field Label" property of corresponding attribute's simple type.
So you have to create a simple type in local dictionary and assign "Field Label" to necessary value.
For model nodes (like Adaptive RFC) data dictionary with corresponding types and their metadata are retrieved from backend (R/3), so you get label texts automatically in this case.
P.S. Just in case I understand you wrong: if you have to display same text for InputFiled and Label, then just bind InputField.value and Label.text to same context attribute.
Valery Silaev
EPAM Systems
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ruthie,
go to Local dictionary create a simple type. inside the simple type go to 'representation' tab, then set the 'field label' to any value you want. Now create an attribute of this simple type and bind that to an inPut fields value property. then if you set the labelfor property of a label to this input field, the label will display the' field label' of simple type .
regards,
rahul.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.