cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying error message

Former Member
0 Kudos

Hi All,

Could someone please tell me how do i go abt displaying an error msg in Dynpro. I have an input field and a button , which when clicked takes me to the next view.

I have created the simple type in association view context.

I have typed the following code and it works,

if(wdContext.currentContextElement().get<my_att_name>().equals("first page or something")wdThis.wdFire<Plug1_name>()elsewdThis.wdFire<Plug2_name>()

but now instead of 2 fire plugs if i want to display an error msg when the input field is blank , how do i do this.I have tried inserting "wdThis.wdGetAPI().getComponent().getMessageManager().raisePendingException()" instead of 1 of the fire plugs but the msg from the msg pool is not called.

Nibu if your there pls help!

thanks

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi Sunil,

I don't think you can edit the default error message for the simple types. As far as I know SAP doesn't provide any interface or API for doing that.If someone has done that please let us know.

A suggestion is : why don't you use a built in type (integer or string) for your attribute and write your own methods for validation. Thereby you can achieve any kind of validations and can display messages of your own.

Best Regards,

Nibu.

Former Member
0 Kudos

Hi Sunil,

Sorry, I don't think I can help you with this. Even I had this problem with the default 0 coming in the input field, but couldn't find any solution for that. And I don't think there is any solution for that.

Best Regards,

Nibu.

Former Member
0 Kudos

Hi,

Try creating a simple type of base type integer,make it the type of value attr and map it to the input field...

Regards

Bharathwaj

Former Member
0 Kudos

Hi,

Is there any way I can change the error message displayed when a validation happens when I use simple types. I need to make the messages more user friendly.

thanks

Former Member
0 Kudos

You can create non-validating actions and use IWDValidationCheck and provide user friendly messages.

Hope this link would help

Former Member
0 Kudos

Hi Noufal,

I don know if You sent the link by mistake or its a problem at my end, but the link is opening the Web Dynpro forum page in sdn!

Former Member
0 Kudos

Hi create a method like ..CheckMandatory().

inside that write code like this.

IWDMessageManager messageManager = this.wdThis.wdGetAPI().getComponent().getMessageManager();

IWDAttributeInfo attributeInfo = this.wdContext.getNodeInfo().getAttribute("name");//"name" is a name of the context element that you have.

if (name == null || name.equalsIgnoreCase("")){

messageManager.reportContextAttributeMessage

(this.wdContext.currentContextElement(),

attributeInfo,

IMessageStartView.MISSING_INPUT,

new Object[]{"name"},

true);

Then on click of that button call this method:

public void onActionTest(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionTest(ServerEvent)

String name = wdThis.wdGetStartViewController().wdGetContext().currentContextElement().getC_name();

this.checkMandatory(name);

wdThis.wdGetAPI().getComponent().getMessageManager().raisePendingException();

wdThis.wdFirePlugToResultView();

//@@end

}

Is it useful or tell me.I'll try to help more.

Regards,

Karthick

Former Member
0 Kudos

Hi,

Thanks for that solution Karthick.

And Nibu, this is what i did:

1.set the simple type to 'integer'

2.gave min.inclusive value cuz i did not want it to take -ve values.This in turn made it mandatory to fill the field as it did not accept anythin that wasnt an integer(no coding)

The problems i have now are:

1.I have a default value of'0' entered in the field when I run it...i want the field blank at 1st.Is this possible?

2.Can I change the default error messages that are displayed to make it more user friendly?

thanks

Former Member
0 Kudos

Hi Sunil,

The best solution for this is as you told create a simple type of type buil in type 'int'. Then in the event handler of your input, write the code for checking if it is null(the code I gave in my earlier post).

Hope this helps,

Best Regards,

Nibu.

Former Member
0 Kudos

Hi Sunil,

Giving you an example where if an attribute(Associate_ID) is not populated, it will show a message :



if(wdContext.currentContextElement().getAssociate_ID()==null)						{
{
	IWDMessageManager messageMgr =this.wdComponentAPI.getMessageManager();	
	IWDAttributeInfo ai=this.wdContext.getNodeInfo().getAttribute("Associate_ID");
	messageMgr.reportContextAttributeMessage(this.wdContext.currentContextElement(),ai,IMessage<view component>.ASS__ID,null,true);
		
}

Hope this helps,

Best Regards,

Nibu.

Former Member
0 Kudos

Hi Sunil,

you can create your own messages in message pool of type error or text or warning etc., please go through this link

http://127.0.0.1:3725/help/index.jsp?topic=/com.sap.devmanual.doc.user/c9/d21e3e49c0a90be10000000a11...

Regards,

Sirisha.R.S.

Former Member
0 Kudos

hi,

This link is not opening here, but anyways i have created a msg in the pool. Now i needed to know if i could call this msg some how in the if loop? Or is there some long procedure? Could you please gimmmi some hints as i am unable to connect to the link you have given.

thanks

Former Member
0 Kudos

Hi,

messageMgr.reportMessage(IMessage<compname>.msgname, new Object[], false);

Regards

Bharathwaj

Former Member
0 Kudos

Hi Sunil,

Try out this link.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/webdynpro/a simple input form with message and error service support.pdf

its a pdf tat gives u whole description as to how to creat the error mesage and how to use it also.

Regards,

Sirisha.R.S

Former Member
0 Kudos

Hi all,

Thanks so much for all the help.

Now i have 1 more problem,

I have done the validation for the empty field in the way you guys told me.

Now what if I want to also put another validation for this field which allows me to enter only numerals. How do I do this?

I could associate a simple type with built-in type "int" but then i am not able to show any error msg when the field is empty.

thanks