cancel
Showing results for 
Search instead for 
Did you mean: 

How to find out date when user clicks on a date of Date Navigator

Former Member
0 Kudos

Hi Experts,

I have created WD application. It contains DateNavigator. User clicks on a particular date. We want to display the clicked date. How we can do so? I have done following coding. What I should type after "hi" + ????? to display the selected date.

public void onActionSelectDate(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionSelectDate(ServerEvent)
    wdComponentAPI.getMessageManager().reportSuccess("hi ");
    //@@end
  }

Regards,

Gary

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Gary,

You can do it in two ways:

1) bind the firstSelectedDate property of the Date Navigator to an attribute and then on your action (which can be a button click) you can retrieve the value of the same

2) or you can write an action method for event onDaySelect()

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Create an attribute(dateSelected) of date type and bind it to the "firstSelectedDate" of the Date Navigator.

Create the below action & bind it to the onDaySelect() event of the Date Navigator.'

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

{

//@@begin onActionSelectDate(ServerEvent)

wdComponentAPI.getMessageManager().reportSuccess("hi "+wdContext.currentcontextelement.getdateSelected());

//@@end

}

Regards

Shruti

gill367
Active Contributor
0 Kudos

HI Gary,

You can do this by binding the context attribute of type date to the firstSelectedDate property of the datenavigator Ui element.

then suppose context attribute to which you have bound the UI element has the name date then create an action for the event onDaySelect. then write the following code in the event handler

public void onActionselectdate(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionselectdate(ServerEvent)
    String str = wdContext.currentContextElement().getDate().toString();
    wdComponentAPI.getMessageManager().reportSuccess("HI" + str);
    //@@end
  }

It will solve your issue.

But the date format here will be YYYY-MM-DD if you want to change it then either you have to use one simple type or modify it in the code itself by using some string operation.

Regards,

Sarbjeet