on 02-12-2008 11:10 AM
I was trying to bind an action with onSelect event of dropdownbykey, but I couldn't get figure out how to get selected value in the action defined.
I was trying to access the selected key by using following code but it prints nothing.
wdEvent.getString("key");
Any idea what I have been doing wrong.
regards,
Jawed Ali
Hi,
Use
wdContext.current<Your Node>Element().get<Your Attribute>()
Ex:
lets say the node name is orders and the attribute ordertype is bound to the drop down by key the following code will return you the selected.
wdContext.currentOrdersElement().getOrderType()
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have value Node Line Item with elements, productid, price and quantity.
lineitem
|----productId
|----price
|----qty
as I have multiple line items so I have mutiple dropdown boxes when users select a product on any row from the dropdown how I am gonna find which was the currentnodeElement() for line item.
Hi,
Create a parameter of type string to onSelect action, lets say "key"
Go to the outline view
select the drop down by key right click and select parameter mapping.
from the right side drag the "key" previously created to the left side "key"
access this parameter from code this will return you the selected key.
Ex your method signature will look as follows
public void onActionTest(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, java.lang.String key )
{
//@@begin onActionTt(ServerEvent)
wdComponentAPI.getMessageManager().reportSuccess(key);
//@@end
}
Regards
Ayyapparaj
Map the (implicit) event parameter named "nodeElement" to a corresponding action parameter "row" of type "ILineitem" (or however the node name is). You can do this either with the parameter mapping editor (Outline -> right-click -> "Parameter Mapping") or, if this is not available in your version, by code in wdDoModifyView():
if (firstTime)
{
IWDDropDownByKey ddList = (IWDDropDownByKey) view.getElement("ddListID");
ddList.mappingOfOnSelect().addSourceMapping("nodeElement", "row");
}
In the action handler, you can get the selected key for the given table row by
String selectedID = row.getProductId();
Armin
Thanks Armin and Ayyapparaj KV, I have solved my problem by integrating your suggestions:
I first added following lines in ModifyView method:
public static void wdDoModifyView(IPrivateDynamicView wdThis, IPrivateDynamicView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
//@@begin wdDoModifyView
if (firstTime)
{
IWDDropDownByKey ddList = (IWDDropDownByKey) view.getElement("DropDownByKey");
ddList.mappingOfOnSelect().addSourceMapping("nodeElement", "key");
}
//@@end
}
I have added a parameter "key" of type ILineItemElement to ProductSelect action and mapped this action to Dropdown's onSelect event.
public void onActionProductSelect(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, com.dynamic.ui.wdp.IPrivateDynamicView.ILineItemElement key )
{
//@@begin onActionProductSelect(ServerEvent)
wdContext.currentContextElement().setTestValue(key.getProductId());
//@@end
}
Thank you,
Jawed Ali
Hi,
The currentContextElement of the node will give you the selected value.
Regards,
Sudhir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.