cancel
Showing results for 
Search instead for 
Did you mean: 

how to throw error when dropdown by index is blank

Former Member
0 Kudos

Hi,

In the dropdowm by index, I want to throw error if the selected value is blank, how can I do that?. I tried to get value something like here.

String = wdContext.currentT_Material.getMatnr();

if I select blank, I am getting null pointer exception.

T_material is from R/3. How can I throw error if I select blank?.

Thanks,

Sunita.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos
if (wdContext.currentT_Material() == null)
{
  /* nothing selected */
}

Armin

Former Member
0 Kudos

Hi Armin,

can u plz check once again, how can we write that statement, I am getting error when I write like that,

as currentT_Material() is undefined.

I want to write a message when we select blank field, and press the next button. So we should select something.

One more thing, whats the standard way (efficient way) to process the mandatory field. Since I have more than 10 fields, If mandatory field is blank, I want to throw error.

Thanks-a-lot for help.

Sunita.

Message was edited by: sunita

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi Sunita,

See this thread

Regards, Suresh KB

roberto_tagliento
Active Contributor
0 Kudos

if (wdContext.nodeT_Material().getLeadSelection() == -1)

{

/* nothing selected */

}

Former Member
0 Kudos

Hi

One more thing, whats the standard way (efficient way) to process the mandatory field. Since I have more than 10 fields, If mandatory field is blank, I want to throw error.

public void checkMandatory(String name,String filedContextID)

{

String attributeValue = wdContext.currentContextElement.getAttributeAsText(filedContextID);

String attributeinfo = wdCotext.getNodeInfo().getAttribute(filedContextID);

if(attributeValue ==" ")

{

msgMgr.reportContextAttributeMessage(this.wdContext.currentContextElement(), attributeInfo,

IMessageSimpleErrors..MISSING_INPUT, new Object[] {"Name"},true);

}

}

Declare u context attribute name in current View method

Where you used this method.

This.checkMandatory("Ur errorMsg",Attributeof declaredView);

Or Do u need to * red color ur input filed label do follow.

set the property state as required for the input Field

In the Label's property labelFor set the coressponding text field's Id.

Thanks,

Lohi

Answers (1)

Answers (1)

Former Member
0 Kudos

Sunita,

I think the one which Roberto suggested will work fine. If u wanna throw an error message, u can either catch the exception and 'throw' it or u can use 'message manager'.

if (wdContext.nodeT_Material().getLeadSelection() == -1)

{

IWDMessageManager msgmgr = wdComponentAPI.getMessageManager();

msgmgr.reportException("No lead selection in dropdown", true);

}

Regards,

Aparna .P