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

Validation for Drop down by index

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Jan 29, 2008 at 07:06 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 07:19 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 29, 2008 at 05:30 PM

    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.

    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.