Skip to Content
author's profile photo Former Member
Former Member

getting the text of a Label from an inputField

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 19, 2005 at 11:27 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 19, 2005 at 11:27 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 19, 2005 at 11:28 AM

    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

    http://www.NetWeaverTeam.com

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 23, 2005 at 06:45 AM

    Thanks Nibu.

    It didn't work.

    I guess its not possible.

    Let me give you some points.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Oct 19, 2005 at 11:53 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 19, 2005 at 12:03 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.