cancel
Showing results for 
Search instead for 
Did you mean: 

Parameter Mapping for LinkToAction in A Table

Former Member
0 Kudos

Hi everyone, i confused how to pass parameter in onAction for LinkToAction in A Table. I search in this forum and i find section "Parameter Mapping" but i'm still confused how this can solve my problem.

My Problem like this.

First I have a table, we can call this TablePerformance,there is a 6 column, and 2 of them have LinkToActionUIElement as TableCellEditor.

A

B

C

D

x

Lta

Ltb

...

y

Lta

Ltb

....

  • Lta and Ltb is LinkToAction UI Element

This table has binded to context with the same name (TablePerformance)

- TablePerformance (value node)

|__CellA (value attribute)

|__CellB (value attribute)

|__CellC (value attribute)

|__CellD

- ...

- Languange (value attribute)

I need to open popup window that will display a list based on column A from tablePerformance, Languange and Type (Constant Value) --> if Lta is clicked Type = "XXX" else if Ltb is clicked Type = "YYY"

so I did this :

public static void wdDoModifyView(IPrivateCompetencyView wdThis, IPrivateCompetencyView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)

{

//@@begin wdDoModifyView

if (firstTime)

{

IWDLinkToAction theLink = (IWDLinkToAction)view.getElement("Lta");

theLink.mappingOfOnAction().addSourceMapping("TablePerformance.CellA","objectID");

theLink.mappingOfOnAction().addSourceMapping("Languange","lang");

}

void OnActionLtaClicked(... objectId, ... lang)

{

}

Is this correct ? Because i am not sure with

"theLink.mappingOfOnAction().addSourceMapping("TablePerformance.CellA","objectID");"

will get column A correctly (get value x or y)

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

No, that's not correct.

To get the table row / node element for the cell editor with ID "Lta" (here a LinkToAction), just do


if (firstTime)
{
  IWDLinkToAction editor = (IWDLinkToAction) view.getElement("Lta");
  editor.mappingOfOnAction().addSourceMapping("nodeElement", "row");
}

Now, add parameter "row", type = ITablePerformanceElement, to your action.

void onAction<ActionName>(..., ITablePerformanceElement row)
{
  row.getCellA(); /* this is value of attribute CellA in row where link was clicked */
}

Armin

Answers (1)

Answers (1)

former_member286976
Active Participant
0 Kudos

Hi Satria,

Since here you have to pass the parameter values to the action try setString() function instead of addSourceMapping(). Also debug and see whether you are getting the correct values in the action.

Code sample

==========

IWDLinkToAction theLink = (IWDLinkToAction)view.getElement("Lta");
theLink.mappingOfOnAction().setString("TablePerformance.CellA","objectID");
theLink.mappingOfOnAction().setString("Languange","lang");

Regards,

Sudeep

Former Member
0 Kudos

Hi Sudeep,

Thank you for your answer but i can't find method setString from mappingOfAnAction.I have running with my way and i get error when i run this application.

com.sap.tc.webdynpro.services.exceptions.WDIllegalArgumentException:

Parameter Languange not found

Please, is someone can help me ?

Regards,

Satria

former_member286976
Active Participant
0 Kudos

Hi Satria,

You are right. setString() is available only in advanced version that outside customers don't have access to.

The error what you are referring to will come if you haven't added the parameters properly in your action and corresponding function. Kindly check whether you have added the parameter 'Language' in your Action and corresponding function. If not, do it and run the application again.

Regards,

Sudeep

Former Member
0 Kudos

Hi Sudeep,

You said i must add parameter 'Languange' in my Action but I define it in my context. In my action I define parameter lang. Is it correct?

Root Context

|_Languange

void OnActionLtaClick(... event,String lang)

{

}

wdModifView(...)

{

......

theLink.mappingOfOnAction().addSourceMapping(Languange,lang);

}

former_member286976
Active Participant
0 Kudos

Hi Satria,

You are right. lang should be the parameter name. See the javadoc for the function below

void com.sap.tc.webdynpro.services.event.api.IWDParameterMapping.addSourceMapping(String sourceName, String newName)

Adds a new parameter to the parameter mapping. The parameter is read from the mapping source and stored in this instance.

Parameters:

sourceName name of the parameter in the mapping source object

newName name of the parameter after mapping

Regards,

Sudeep