cancel
Showing results for 
Search instead for 
Did you mean: 

Validation for Drop down by index

Former Member
0 Kudos

Hi,

I created a drop down by index UI element. I want to display the validation message when we select and empty value. I am not able to display the validation message.

Code Sample:

//Code for creating UI element

List ddbiList = new ArrayList();

temp = wdContext.nodeDropDownByIndex().createDropDownByIndexElement();

temp.setAttributeValue("value", "INDEX 1");

ddbiList.add(temp);

temp = wdContext.nodeDropDownByIndex().createDropDownByIndexElement();

temp.setAttributeValue("value", "INDEX 2");

ddbiList.add(temp);

temp = wdContext.nodeDropDownByIndex().createDropDownByIndexElement();

temp.setAttributeValue("value", "INDEX 3");

ddbiList.add(temp);

wdContext.nodeDropDownByIndex().bind(ddbiList);

When I am using the below code to display the validation I am getting null pointer exception stating that node, attributeinfo is null. I am getting this exception only when we didn't select any value.Even if I kept this statement in catch block, it is throwing the exception.

msgMgr.reportContextAttributeMessage(nodeElement, attributeInfo, IMessageValidationRuleComp.TEST_MANDATORY, null, true);

Can anyone help me in solving this.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi, xD i posted the solution to this at the bottom on this thread:

[Dynamic validation regardless UI element|;

Regards

Julio César Herrera

PD: That nullpointer ur getting... i guess its because validation against null its no checked first, in my solution i get the attribute value as object, like this i can check it against null with no probs, in case its not null, get its string value toString( ) , then you can compare that string length against zero.

Former Member
0 Kudos

Hi,

Try this:

if(wdContext.nodeDropDownByIndex().currentDropDownByIndexElement().get<ATTR_NAME>() != null){

// Do your code

} else {

msgMgr.reportContextAttributeMessage(nodeElement, attributeInfo, IMessageValidationRuleComp.TEST_MANDATORY, null, true);

}

Make sure that attributeInfo is for ATTR_NAME.

thanks & regards,

Manoj

former_member214651
Active Contributor
0 Kudos

Hi Vallabhaneni,

Have u written the following code after u have created the attribute info object???

objAttributeInfo = wdContext.node<ValueNodeName>.getNodeInfo.getAttribute("<valueAttribute>");

try this out. Hope this helps u

Regards,

Poojith MV