cancel
Showing results for 
Search instead for 
Did you mean: 

Highlight Required DropDownByIndex with dotted red border

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member197348
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

chintan_virani
Active Contributor
0 Kudos

Isabel

Check this thread :

Chintan

Former Member
0 Kudos

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)

Former Member
0 Kudos

Hi Isabel.

Check the method i suggest at the bottom on this thread

[Dynamic validation Regardless UI element|;

Regards.

Julio Herrera

Former Member
0 Kudos

Hi Julio, I tried to use your code even before posting this thread. I can´t make it work because it gives me a NullPoniterException on the following line:

//Let's get the attribute value

attributeValue = node.getCurrentElement().getAttributeValue(attributeName);

The problem is that node.getCurrentElement() is NULL because no item is selected on the dropdown

I´ll appreciate your help

Former Member
0 Kudos

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