cancel
Showing results for 
Search instead for 
Did you mean: 

passing parameter to Eventhandler

Former Member
0 Kudos

hi all

i have created a confirmation dialog box which is invoked on selecting a date from the Datenavigator.

the confirmation dialog box does have two buttons viz "yes" & "no".

dependindg on the button chosen by the user i hav to manipulate the selected date. now my problem is with passing that date as parameter to the actionhandler of the button on the dialog box.

the eventhandler i have created does hav parameter named selectedDate but how shall i pass the value since i am not calling that eventhandler in my code.

Thanks in advance

Deepak

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Why dont you use the context attribute that is mapped to the date field directly in the event handler as

wdContext.current<Your elememt>().getdate()

and then do the rest of the process.

If this is a different screen try to map the attibute and use.

Regards

Ayyapparaj

Former Member
0 Kudos

hi Ayyapparaj

thakns for the suggestion.

currently that is what i am doing in my program. but just wanted to know if is there any way to pass the parameter in such way.

Deepak

former_member182294
Active Contributor
0 Kudos

Hi Deepak,

The main purpose of passing parameter to event handler is to identify the source of event. As per the webdynpro programming style you can use the same event handler with different event sources like InputField, CheckBox etc., in such scenarios if you want to identify from where the event is generated we use paramers.

In wdModify we can map paramters in this way:

IWDInputField inputField = (IWDInputField)view.getElement("editor");

inputField.mappingOfOnEnter().addParameter("inputFieldName", "value");

I hope this is helpful.

Regards

Abhilash

Former Member
0 Kudos

hi guys

i think i have not explained you my problem clearly.

i have mapped the selected date of the datenavigator to the eventhandler onactiondateselect() using the piece of code in wddomodify as said by abhilash.

there in action i am checking whether selected date is holiday or not.if it is holiday then i give informative msg to the user saying "its holiday still do you want to proceed?"

in case he cancels(CANCEL button on dialog) it then its ok i have nothing to do.

but if he proceeds with that(OK button on dialog) then i have to add entry in table with that date.now i can get the that date from context by mapping the lastselecteddate/firstselecteddate.

but i wanted to check if is there any way so that i can pass that parameter to the evenhandler of the button on the dialog.since its cinfirmationdialogbox i can't do mapping in wddomodify as well while creating the confirmationdialogbox i can't send that parameter.

i hope i have cleared the situation

Deepak

former_member182294
Active Contributor
0 Kudos

Hi Deepak,

Still some confusion, correct me if im wrong:

1) Assume context attribute is varDate and you are validaiting this date to check if its holiday or not.

2) If its holiday your displaying a dialog box with OK, Cancel actions.

3) If OK, then you want to add that particular date to the table.

I really do not understand where is the problem, you can still read the context attribute in OK action and add it to the table. As I mentioned earlier parameter passing purpose is completely different than the way you are thinking. You can refer the [blog|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/8325] [original link is broken] [original link is broken] [original link is broken]; to understand the usage.

Regards

Abhilash

former_member751941
Active Contributor
0 Kudos

Hi Deepak,

Directly it is not possible. You can pass parameter to an even handler like this way.

Create 2 Event handler

1>OK with no parameter

2>callOK with parameter stDate of type date

try this.

public void onActionOutput(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionOutput(ServerEvent)
  //  wdComponentAPI.getMessageManager().reportSuccess(" Value : "+ wdContext.currentVenameElement().getVnamea());
    String dialog = "Date";
    IWDConfirmationDialog confDialog = wdComponentAPI.getWindowManager().createConfirmationWindow(dialog,wdThis.wdGetAPI().getViewInfo().getViewController().findInEventHandlers("OK"),"OK");
    confDialog.setTitle("Test Window");
    confDialog.show();
    //@@end
  }

  //@@begin javadoc:OK(ServerEvent)
  /** Declared validating event handler. */
  //@@end
  public void OK(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin OK(ServerEvent)
	java.sql.Date dt = new java.sql.Date(System.currentTimeMillis());
      <b>wdThis.callOK(wdEvent,dt);</b>
    //@@end
  }

  //@@begin javadoc:callOK(ServerEvent)
  /** Declared validating event handler. */
  //@@end
  public void callOK(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, java.sql.Date stDate )
  {
    //@@begin callOK(ServerEvent)
	wdComponentAPI.getMessageManager().reportSuccess("Date : "+stDate);
    //@@end
  }

Regards,

Mithu

Former Member
0 Kudos

hi Abhilash

thanks for the Blog link

Deepak

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Deepak,

You must be using the following code for your requirement.


IWDControllerInfo contInfo = wdControllerAPI.getViewInfo().getViewController();
   	
IWDConfirmationDialog dialog = wdComponentAPI.getWindowManager().createConfirmationWindow( "String Message", contInfo.findInEventHandlers( "ok"), "Ok");
dialog.addChoice( contInfo.findInEventHandlers( "cancel"), "Cancel");
 dialog.show();


public void ok(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
     // Add this line that will get you the result
   wdContext.currentContextElement().getDateElement();
  }

I don't think you have to pass the date value as parameter

Regards

- Vinod

*

Former Member
0 Kudos

Adding to Ayyaparaj reply, in properties of DateNavigator, there is property firstSelectedDate and lastSelectedDate. Map those property to a context attribute say, sDate (which must be of type date). So whatever date is selected in DateNavigator will then be mapped to context attribute, sDate.

Regards,

Gopal