Skip to Content
avatar image
Former Member

Validations in drop down

Hi,

I'm having some 5 to 6 drop down UI elements. In all the dropdowns it has a some 10 names listed.

I have to check the condition that, no name has been selected twice.

how to get the selected name of the dropdown and check it with the other dropdowns selected name.

help me out with detailed procedure.

thanks & regards,

Suresh

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Feb 21, 2008 at 07:47 AM

    Hi get the selected item by using the folloeing code

    java.lang.String name=wdContext.currentContextElement().getVAName();

    Then compare the above value with the other values selected in the dropdownlist

    Hazrath.G

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi ,

      let you have 5 drop downs binded to value nodes test1,test2,test3,test4,test5 respectively.

      The validate method would be

      String [] testArr={wdContext.currentTest1Element().getTest(),
      		wdContext.currentTest2Element().getTest(),
      	wdContext.currentTest3Element().getTest(),
      	wdContext.currentTest4Element().getTest(),
      		wdContext.currentTest5Element().getTest()};
      for(int i=testArr.length-1; i>1; i--)  
           for(int j=0; j<i; j++) 
       	  if( testArr<i>.equals(testArr[j]) ){
       	  	wdComponentAPI.getMessagemanager.reportWarning("Twice values selected  "+testArr<i>);
       	  	return;
         }

      Regards,

      Naga