on 03-06-2006 11:16 AM
Hi,
I am very new to this domain and need a help in the UI element DateNavigator.
On selection of a particular week, the action method created for the view gets invoked but parameter values haven't passed.
For the action I had created two parameters week(int) and year(int).On debugging I find that none of the parameters were passed.
Rahul
Thanks for all the inputs.
Sebastian, you mentioned of binding the value (selected date) of Date Navigator to context. I find two properties of DateNavigator firstSelectedDate and lastSelected date, which one to bind (there is no date range involved in my case).
Should I then parse the date and get the week and year values from it.When I select a week from the Navigator would the date attribute hold some value.
In the dateNavigator API, in events section it is mentioned
onWeekSelect
Specifies the action that is carried out when the user chooses a week. Event parameters are the chosen weeks (in the range of 1 to 53) and the chosen year.
Event Parameter Type
week int
year int
I would like to use this method.Please tell me how to map parameters.I have written the following lines in the view
public void onActionWeekSelect(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, int week, int year )
{
//@@begin onActionWeekSelect(ServerEvent)
Integer weekNum = new Integer(week);
Integer yearNum = new Integer(year);
wdContext.currentContextElement().setWeekNumber(weekNum.toString());
wdContext.currentContextElement().setYear(yearNum.toString());
//@@end
}
On debugging it shows null parameters and week and year has initial values.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Add the following code inside method wdDoModifyView():
if (firstTime)
{
IWDDateNavigator dn = (IWDDateNavigator) view.getElement("ID-of-datenavigator");
dn.mappingOfOnWeekSelect().addSourceMapping
(
"week", /* name of event parameter */
"week" /* name of action parameter */
);
dn.mappingOfOnWeekSelect().addSourceMapping
(
"year", /* name of event parameter */
"year" /* name of action parameter */
);
}
In newer versions there is an interface IWDDateNavigator.IWDOnWeekSelect containing constants for the event parameter names.
Armin
if (firstTime)
{
IWDDateNavigator dn = (IWDDateNavigator) view.getElement("ID-of-datenavigator");
dn.mappingOfOnWeekSelect().addSourceMapping
(
IWDDateNavigator.IWDOnWeekSelect.WEEK, /* name of event parameter */
"week" /* name of action parameter */
);
dn.mappingOfOnWeekSelect().addSourceMapping
(
IWDDateNavigator.IWDOnWeekSelect.YEAR, /* name of event parameter */
"year" /* name of action parameter */
);
}
or better: If your version of NWDS supports graphical editing of event parameters, use this.
To do so, open context menu in Outline view on UI element and select entry "Parameter Mapping".
Armin
Message was edited by: Armin Reichert
Hi,
Thx for the reply, i tried to do what you told.
I created an Action (onWeekSelect) with 2 parameters (firstday (date) and year (date) ). When i look at the Methods tab, there is a method called onActionWeekSelect this method has the same to parameters.
In my wdDoModifyView i put this code:
if (firstTime)
{
IWDDateNavigator dn = (IWDDateNavigator) view.getElement("DateNavigator");
dn.mappingOfOnWeekSelect().addSourceMapping
(
IWDDateNavigator.IWDOnWeekSelect.FIRST_DAY, "firstday"
);
dn.mappingOfOnWeekSelect().addSourceMapping
(
IWDDateNavigator.IWDOnWeekSelect.YEAR, "year"
);
}
I created 2 context attributes of type Date (Year & Firstdate).
In the onActionWeekSelect i put the following code:
wdContext.currentContextElement().setFirstday(firstday);
wdContext.currentContextElement().setYear(year);
When i run the application and select a week, i get the following error:
java.lang.IllegalArgumentException
at java.sql.Date.valueOf(Date.java:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
... 31 more
I think i do something wrong, but have no idea. I hope somebody can help me.
Kind Regards,
Maarten.
Armin,
Thx for your reply.
The attributes "Firstday" and "Year" are of type Date. In the properties tab, i selected "Date" there. Is this the DDIC type? I gave the action parameters the java.sql.Date type but still got the IllegalArgumentExeption. I hope you will still help me.
Thx in advance.
Kind regards,
Maarten.
Thankyou Armin, for explaining me parameter mapping.
Rahul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is a Tree example of how you map attributes...
public static void wdDoModifyView(IPrivateWoChooseTUDTree wdThis, IPrivateWoChooseTUDTree.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
//@@begin wdDoModifyView
IWDTreeNodeType treeNode = (IWDTreeNodeType) view.getElement("TreeNodeType1");
treeNode.mappingOfOnAction().addSourceMapping( "path", "element");
//@@end
}
The TreeNode's attribute "path" is mapped to the attribute "element" of the onAction:
public void onActionObjectSelected(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, com.vattenfall.pm.wdp.IPrivateWoChooseTUDTree.ITUDNotifobjprt_TreeElement element )
{
//@@begin onActionObjectSelected(ServerEvent)
..
//@@end
}
/Mikael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Rahul,
your have to bind the value (selected date) of the DateNavigator to your context. Then you can evalute this value in your action handler method.
Btw, parameters in action handler methods are only useful when you are using dynamically created action. You can pass a value to determine which control has fired the action. In your case you should use the context for data transport.
Sebastian
Message was edited by: Sebastian Voss
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<i>Btw, parameters in action handler methods are only useful when you are using dynamically created action. You can pass a value to determine which control has fired the action. In your case you should use the context for data transport</i>
That's not correct. Action handler parameters are also useful for statically created actions. Event parameter values may be transported into action handler parameters using <i>parameter mapping</i>.
Armin
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.