Skip to Content
avatar image
Former Member

How to select a default value in a DropDownByIndex

Hi,

I have a dropdownbyindex in a table. I need to make default selection of an item in the dropdown.

I have prepopulated dropdown from bapi result, "1", "2", "3", "4". I have another bapi result which gives me a selected value "2". I need to default this to the dropdown when my page gets loaded.

1st bapi result - (model nodes)

_input

-


_output

-


_list

-


attribute (1,2,3,4) (list of elements)

I have a context node created for the table items.

nodeitems

-


str (2) -element to be defaulted.

I am writing this code:

int lead = 0;

for(int i = 0; i < X.size; i++){

IWDNodeElement elem = wdContext.nodeDataNode().getElementAt(i);

if(X.equalsIgnoreCase("2"))

{

lead = i;

break;

}

}

wdContext.nodeX.setLeadSelection(lead);

For size of X, I am taking

nodeInput.nodeOutput.nodeList.size()

But this gives me size of thelist 0 whereas it is populating the whole list.

Hope I have made it clear.

Please help.

Thanks

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Jun 14, 2007 at 03:36 PM
    Add comment
    10|10000 characters needed characters exceeded

  • Jun 14, 2007 at 03:42 PM
        IWDNode list = wdContext.nodeList();
        int size = list.size();
        int leadSelection = 0;
        
        for(int i=0;i<size;i++)
        {
    		IWDNodeElement element = list.getElementAt(i);
    		
    		String attribute = element.getAttributeAsText("attribute");
    		
    		if("2".equals(attribute)) 
    		{
    			leadSelection = i;
    			break;
    		}
        }
        
        list.setLeadSelection(leadSelection);
    
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Maksim Rashchynski

      Thanks for replying. I have got my mistake. On click of the button, I call action handler and create the whole page, but the bapi which populates the dropdown is called in ModifyView function of the next page. So, when I was trying to loop through the dropdown elements, the node was not populated, hence size was 0. My mistake.

      Thanks so much for replying.