cancel
Showing results for 
Search instead for 
Did you mean: 

onLeadSelect Event:: IWDTable: read row data

Former Member
0 Kudos

Hi,

I have a dynpro page with a IWDTable, that lists the flights from the BAPI_FLIGHT_GETLIST BAPI .

Now I would like to display some details of a special

flight, that I select from the IWDTable. I created a

onLeadSelect Event to indicate on which flight I'd like

to get more information.

In the corresponding method of the View class

there is the onLeadSelect event handling method

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

{

...

}

To get flight details I use another BAPI: BAPI_FLIGHT_GETDETAIL. This BAPI needs three input parameters: 1. Airlineid 2. Connectid 3. Flightdate

All these parameters are displayed in the IWDTable.

Now I need to extract these parameter values from the selected row of the table to get the flight details from the BAPI_FLIGHT_GETDETAIL BAPI.

I already tried the

IWDCustomEvent.getString("<parameter>"); with "Airlineid", "Connectid", "Flightdate" for <parameter>. These three values correspond with the column identifiers of the IWDTable. I always get null values when I use the IWDCustomEvent.getString() Method.

What I have to do retrieve the parameter values of the selected table row?

In Swing for example there is a special event handler with a method "rowSelected(XYEvent event)". With the

XYEvent it is simple to get the selected row data.

Did somebody do this already?

Greets Simon

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Let X be the view context node used as the table's data source.

After selection of a new table row, the lead selection of node X is changed to the new row index and you can get the value of attribute Y by


wdContext.currentXElement().getY()

(In many cases, master-detail-views can be implemented completely using data binding without need for event handlers.)

Armin

Former Member
0 Kudos

Hi Armin,

Thank you for your reply. The context, or more precisely,

the special node of the context is updated or initialized

by the WebDynpro Framework when the event has been fired.

Simon

Former Member
0 Kudos

Hi Simon,

the context model node which is bound to the dataSource property of the table has the current lead selection already. One possibility to get this lead selected element in a view is

int leadSelection = wdContext.node<Model>.getLeadSelection();
if (leadSelection != IWDNode.NO_SELECTION) {
  IPrivate<ViewName>.I<Model>Element el = wdContext.node<Model>.get<Model>ElementAt(leadSelection);
  // Do something with the element... 
}

Insert this into the action handler method and exchange the <Model> placeholders by the name of the dataSource node.

Hope that helps.

Regards

Stefan

Former Member
0 Kudos

Hi Stefan,

Thanks for your answer. I inserted the code that you have supposed.

I got the IWDNodeElement Objekt from:

IPrivate<ViewName>.I<Model>Element el = ... .

I could not get the row values of the when trying IWDNodeElement.getAttributeAsText("<e.g. Airlineid>")

or

IWDNodeElement.getAttributeValue("<e.g. Airlineid>");

I still will have to invest more time in the dynpro api.

Greets Simon

Former Member
0 Kudos

Hi Simon,

it is not necessary to use the generic getters to access the attribute values of the node element. Assume you have a node named "Flight" with the attribute "AirlineID" type string, then, according to Armin's proposal getting the current node element (thx Armin), you can simply do:

String airlineID = wdContext.currentFlightElement().getAirlineID();

This is much more convenient, isn't it?

Regards

Stefan