cancel
Showing results for 
Search instead for 
Did you mean: 

How to display custom error message if the Required field is not entered?

Former Member
0 Kudos

Hi,

I have made one input field as required field in a view.

I want to display one custom error message ,if the required input field is not entered.

Please help me regarding this.

Thanks,

Deepika

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ,

If your input field is mapped to a value attribute , name.

validating name as required field

if(wdcontext.currentcontextelement.getName().length >0)

{

}

else

{

wdcomponentAPI.getMessageManager().reportException("Enter Name");

}

Regards,

Sunitha Hari

Answers (6)

Answers (6)

Former Member
0 Kudos

just follow these steps

1. Open message pool and add a message (i.e. custom message what ever u want) and enter appropriate message key & message type

2. write the following code in the button action function

IWDMessageManager messageMgr = wdComponentAPI.getMessageManager();

if(wdContext.currentContextElement.getfieldName()==null){

messageMgr.reportContextAttributeMessage(

wdContext.currentContextElement(),

attributeInfo,

IMessagecomponentName.MessagePoolKey,

new Object[] { "" },

true);

}

Former Member
0 Kudos

Thanks a lot to all my problem is solved.

Thanks,

Deepika

Former Member
0 Kudos

Hi Deepika,

Try this code



if( wdContext.currentContextElement().getFldValue() == null)
{
   wdComponentAPI.getMessageManager().reportSucessMessage( "String - sucess");
}else
{
wdComponentAPI.getMessageManager().reportErrorMessage( "String - error");
}
   

Regards

- Vinod

*

former_member201361
Active Contributor
0 Kudos

hi,

declare the error or warning or text messages in the message pool.

we can use those message in the view using the message manager .

IWDMessageManager messageMgr = wdComponentAPI.getMessageManager();

and check if the input field or any other ui element is null then throw error messages.

if(wdContext.currentContextElement.getfieldName()==null){

messageMgr.reportContextAttributeMessage(wdContext.currentContextElement(),attributeInfo,IMessageSimpleComp.EMAIL,null,true);

here email is the required field.

hop your problem get resolved.

thanks and regards

fazal

Former Member
0 Kudos

hi deepika....

First go to message pool under webdynpro components.

Create a new message there..of type error.

Enter your text.

Now to avoid null pointer exception , in wdDoInit(), initialise the value


wdContext.currentDateTimeElement().setDate("");

now create an action for submission of data. If field is empty, then within the button write:


  msg = wdComponentAPI.getComponent().getMessageManager();
    if(wdContext.currentDateTimeElement().getDate().equals(""))
    {
    msg.raiseMessage(IMessageCompTodatDateTime.ERROR,new Object[]{""},true)	;
    }

between begin others put:



regards,
pinki
  IWDMessageManager msg = null;

Former Member
0 Kudos

Hi Dipika,

U can do this through " Message Poll" which is availabel at Controller tree.

Double click on Message Poll new wendow will apear then at left most side there will be one button for creating message according to your need.

Regards,

Gurprti Bhatia

former_member365727
Active Contributor
0 Kudos

Hi,

Refer to this document - [Webdynpro messages|http://help.sap.com/saphelp_nw04/helpdata/en/72/1d6526263ff24995016a152705eab2/frameset.htm]

Regards

Srikanth KV