cancel
Showing results for 
Search instead for 
Did you mean: 

How occur error messages when don't type data in required inputfield?

Former Member
0 Kudos

Hi, experts,

I create 6 inputfields in the view(main_view) in Webdynpro for java application.

I have set 5 inputfield to required state, and I can see red "*" beside left in these 5 inputfields.

My problem is:

I need occur 5 error messages in the page if I don't type data in these required inputfields when I click a button to other page.

I need use the following code in Webdynpro for abap for resoling, But I don't know how to do the same thing in Webdynpro for java.

cl_wd_dynamic_tool=>check_mandatory_attr_on_view(

EXPORTING

view_controller = wd_this->m_view

display_messages = abap_true

IMPORTING

messages = messages

).

How can I do it? Do you give me some hint?

Thanks a lot.

Best regards,

tao

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You may refer [this|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/837d9290-0201-0010-1381-e633fe17cb14] tutorial. All please read the [IWDMessageManager|https://media.sdn.sap.com/html/submitted_docs/60_sp2_javadocs/webdynpro/com/sap/tc/webdynpro/progmodel/api/IWDMessageManager.html] API.

Bala

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi wang,

write this in wdModify of view:


 public boolean checkName( )
  {
    //@@begin checkName()
    
	IWDMessageManager messageMgr =
		 wdThis.wdGetAPI().getComponent().getMessageManager();

	   if (wdContext.currentContextElement().getName() instanceof String) {
		 return true;
	   }
	   else {
		 messageMgr.reportContextAttributeMessage(
		   this.wdContext.currentContextElement(),
		   this.wdContext.getNodeInfo().getAttribute("Name"),
		   IMessageAssn1comp.DESIRED_NAME,
		   null,
		   true);
		 return false;
	   }

now go to message pool of WD project..n nw give DesiredName in message key field og message editor..select message type as error...n give ur text message in text...

now call this method on sme action like:

boolean checkName = this.checkName();

hpe it hlps u

Regards,

Khushboo

Former Member
0 Kudos

Hi,

Please post in SAP Webdynpor ABAP forum for ABAP.

Regards

Ayyapparaj

Former Member
0 Kudos

Hi,

There are few way to achieve this.

1> suppose you have create one Name Input fiels and forl that context attribute is va_Name. then on action of button write the below code:-

String strName=wdcontext.current<nodename>.getva_Name();

if(strName.equalIgnoreCase(" "))

wdcomponentApi.getMessageManager.reportException.("Error msg",true);

repeate the same for the all needed input field.

2> in this way you can bind the error msg with the respective in put field. You need to use message pooling for that.

steps:-

1) open the compont of you project on that Message Pool is there. Open it.

2)create keu for that.

3)String strName=wdcontext.current<nodename>.getva_Name();

if(strName.equalIgnoreCase(" "))

wdComponentAPI.getMessageManager().reportContextAttributeMessage(<curretnt context>,<context attribute info>,<mesg key>,<object>,boolean value)

Hope this may help you.

Regards,

Deepak

Former Member
0 Kudos

create 1 method of type boolean n write code as following.

public boolean chkname( )

{

//@@begin chkname()

IWDMessageManager messageMgr = wdThis.wdGetAPI().getComponent().getMessageManager();

if (wdContext.currentContextElement().get<urs value attribute of your input field>() instanceof String)

{

returns true;

}

else

{

messageMgr.reportException("Enter your name",true);

return false;

}

hope this will help u.

Thanks

Abhilasha