cancel
Showing results for 
Search instead for 
Did you mean: 

UI elements validation

Former Member
0 Kudos

hi

i have done the validations for the UI elements

for the mutliple fields and using MESSAGE POOLING

for showing up the messages , so

i have FIRSTNAME , NAME , DOB , ....

if(fname==null)

{

IWDMesageManager msg=wdComponentAPI.getMessagemanager();

msg.reportmessage(IMessage<componentname>.firstname,null,false)

}

the above coding had been in all the IF Block

for Name and other UI elements , is this the correct way to

go , or there is nay other way that i could come up

where i could not repeat the

IWDMesageManager msg=wdComponentAPI.getMessagemanager();

for each IF block ,, other thing is the above statement

need to mandatory provided to each ,

once writting it enough

could any one go ahead with this issue ?

iam using a Pre-defined BAPI , this is the first going ahead

the issue , so any sort this out

regards

murali

Accepted Solutions (0)

Answers (5)

Answers (5)

former_member751941
Active Contributor
0 Kudos

Hi Murali,

Try this,

//@@begin others
  IWDMessageManager msgMgr;
  //@@end


  public void wdDoInit()
  {
    //@@begin wdDoInit()
    msgMgr =  wdComponentAPI.getMessageManager();
 }


Inside action method.

	if(wdContext.currentContextElement().getName() == null || wdContext.createContextElement().getName().trim().equals(""))
	{
		msgMgr.reportMessage(IMessageTest.Name_MESSAGE,null,true);	
	}
	if(wdContext.currentContextElement().getID() == null || wdContext.createContextElement().getId().trim().equals(""))
	{
		msgMgr.reportMessage(IMessageTest.Id_MESSAGE,null,true);	
	}

Regards,

Mithu

Former Member
0 Kudos

hi,

Hi, I guess your re you are putting your code in the implementation of the view.

Use the code on an action created:Say your node is "User" with attributes "Id" and "name"


public void wdDoInit()
  {
    //@@begin wdDoInit()
	wdContext.currentUserElement().setId("");
	   wdContext.currentUserElement().setName("");
    //@@end
  }


public void onActionsubmit(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionsubmit(ServerEvent)

	msg = wdComponentAPI.getMessageManager();
//fetch values of Name and ID
String val1 = wdContext.currentUserElement().getId();
String val2 = wdContext.currentUserElement().getName();

//Calculate length, and check if it is null
int length1 = (val1==null)?0:val1.length();  
int length2 = (val2==null)?0:val2.length();  

//raise message if Id and Name are null
	if(length1==0)
	{
	msg.raiseMessage(IMessageCompTodatDateTime.ERRORID,new Object[]{""},true)	;
	}

if(length2==0)
	{
	msg.raiseMessage(IMessageCompTodatDateTime.ERRORNAME,new Object[]{""},true)	;
	}

    //@@end
  }


//@@begin others
//Define msg
  IWDMessageManager msg = null;
  //@@end


regards,

pinki

Former Member
0 Kudos

Hi,

You can try this. You don't have to write "msg=wdComponentAPI.getComponent().getMessageManager();" again and again. You just write it before the if statement.This coding is written in method which is created in component controller.

public void checkempid( )

{

//@@begin checkempid()

msg=wdComponentAPI.getComponent().getMessageManager();

IPublicComp.IStudinfoNode node=wdContext.nodeStudinfo(); // studinfo is the name of node

IPublicComp.IStudinfoElement ele=node.currentStudinfoElement();

if(ele.getEmpid().length()>3 || ele.EMPID.equals(""))

msg.raiseMessage(IMessageComp.EMPID,new Object[]{""},true);

//@@end

}

Former Member
0 Kudos

Hi Murali,

Try this statement.

The right statement is


IWDMessageManager msg  = wdComponentAPI.getMessageManager();

if( Firstname.equals( null))
{
 // your statement
}


String str = IMessage<componentname>.firstname;

wdComponentAPI.getMessageManager().reportSuccess(  str);
wdComponentAPI.getMessageManager().reportWarning( str);
wdComponentAPI.getMessageManager().reportException( str);

Hope this is what you asking for!

Regards

- Vinod

*

Former Member
0 Kudos

Hi,

Follow the tutorial

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/837d9290-0201...

You can declare

IWDMesageManager msg=wdComponentAPI.getMessagemanager();

out side all the if loops and use the same msg

Regards,

Sudhir