Skip to Content
avatar image
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 05, 2008 at 04:50 AM
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 05, 2008 at 04:57 AM

    Hi,

    Please post in SAP Webdynpor ABAP forum for ABAP.

    Regards

    Ayyapparaj

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 05, 2008 at 05:17 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 05, 2008 at 04:39 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 05, 2008 at 04:46 AM

    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

    Add comment
    10|10000 characters needed characters exceeded