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

Highlight Required DropDownByIndex with dotted red border

Hello, I have a context node named "copy". This node has 2 String attributes "key" and "value".

I also have a DropDownByIndex in which the texts are mapped to "copy.value".

This DropDownByIndex is mandatory/required so i need to validate if it is selected. In order to do that i have this code on the onAction of the submit button.

int selected=wdContext.nodeCopy().getLeadSelection();

if (selected==-1) //No item of the dropdown is selected

{

IWDAttributeInfo info = wdContext.nodeCopy().getNodeInfo().getAttribute("value");

msgMgr.reportContextAttributeMessage(wdContext.currentCopyElement(),info, IMessageTarjetasVentaComp.MISSING_INPUT, new Object[] {"COPY IS EMPTY"},true);

}

The issue here is that i need to display an error message and highlight the DropDown with the red dotted border. I can´t get it work because wdContext.currentCopyElement() is null when no item is selected for the DropDown.

I also test selecting one item of the DropDown and removing the condition "if (selected==-1)". I got the massage displayed but could not see the red dotted border.

I´m also doing like a validation with InputFileds and is working fine, i see the message and the red dotted border.

I appreciate any help.

Thanks in advance.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Jan 30, 2008 at 10:11 PM

    Hi Isabel.

    Check the method i suggest at the bottom on this thread 😊

    [Dynamic validation Regardless UI element|Check mandatory dropdownbykey;

    Regards.

    Julio Herrera

    Add a comment
    10|10000 characters needed characters exceeded

    • EDIT: I just tried it, and you're right, at first i didnt have this problem because i was using NODE Cardinality: 1..n, Selection :1..1, this way can't be empty.

      Then i made the node Cardinality: 0..n, Selection: 0..1 (The way you have been trying) and yes, that Nullpointer happens.

      You could just set the node Cardinality: 1..n, Selection :1..1 so that dotted red border wouldn't be needed.

      But if you really need that option to leave it empty, I'll look for a solution anyways 😊

      Regards.

      Julio Herrera

  • Posted on Jan 30, 2008 at 10:16 PM

    Isabel

    Check this thread : Validation for DropdownbyIndex

    Chintan

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Chintan, i can´t get the code to wirk because i´m getting a ClassCastException when calling the getModifiableTypeOf method.

      The initial exception that caused the request to fail, was:

      java.lang.ClassCastException

      at com.sap.tc.webdynpro.progmodel.context.Paths.getAttributeInfoFor(Paths.java:234)

      at com.sap.tc.webdynpro.progmodel.context.Context.getModifiableTypeOf(Context.java:175)

  • author's profile photo Former Member
    Former Member
    Posted on Jan 31, 2008 at 07:21 PM

    Hi,

    Can you modify and try with this code when no item is selected

     msgMgr.reportContextAttributeMessage(wdContext.createCopyElement(),info, IMessageTarjetasVentaComp.MISSING_INPUT, new Object[] {"COPY IS EMPTY"},true);
    

    regards,

    Siva

    Add a comment
    10|10000 characters needed characters exceeded

    • Problem is, we can't even get the node info required for that line, because node is null, getNodeInfo will fail.

      I only see 2 solutions so far, make it mandatory through cardinality and selection. Or convert it to a dropdownbykey with key value pairs like "Text - Text".

      Dropdownbykey work perfectly with error report and get the dotted red border just fine.

      Regards

      Julio Herrera

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.