on 01-30-2008 8:53 PM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.