cancel
Showing results for 
Search instead for 
Did you mean: 

Link to Action UI Element

Former Member
0 Kudos

Hi ,

I would like to know , how can I pass the name of the string used in Link to Action UI Element in the event handler method for the link .

Say , I am using a table UI Element with one of the column or table cell editor as a link to action .

Now , when I click the column , I want the value of the column to be passed in the event handler method .

Best Regards

Sid

Accepted Solutions (0)

Answers (10)

Answers (10)

lakshmi_narayana2
Active Participant
0 Kudos

Armin

you are right

"SelctedUsers" is typo

lakshmi_narayana2
Active Participant
0 Kudos

Armin

So what is the solution how can i get the value stored in my context for the clicked link

Former Member
0 Kudos

Read my posts again, it contains the solution.

Armin

lakshmi_narayana2
Active Participant
0 Kudos

Armin

I already tried it, but i get a Null Pointer Exception

In my init() method i set the following

selUserElement.setSelectedusers(entry.getPrincipal().getDisplayName());

selUserElement.setUserID(entry.getPrincipal().getId());

selUserElement.setUMEID(entry.getPrincipal().getUMEId());

and when i retrieve any of these values in action method

strUID = row.getUMEID+ ".usr";

strUID = row.getSelectedusers()+".usr";

strUID = row.getUserID()+".usr";

all these values return me null.

Former Member
0 Kudos

You told that your URL after clicking a link was

http://sape7s:50000/irj/servlet/prt/portal/prtroot/com.sap.netweaver.kmc.people.PeopleDetails?Uri=/u...

This means that

- the parameter "row" contained indeed a node element

- the node is in the view controller "ResourcePermissionView"

- the node is named "SelctedUsers" (is this a typo?)

- the link was at row with index 0

Armin

lakshmi_narayana2
Active Participant
0 Kudos

Armin

now my URL looks like this:

http://sape7s:50000/irj/servlet/prt/portal/prtroot/com.sap.netweaver.kmc.people.PeopleDetails?Uri=/u...

but the expected URL is:

http://sape7s:50000/irj/servlet/prt/portal/prtroot/com.sap.netweaver.kmc.people.PeopleDetails?Uri=/u...

"USER.CORP_LDAP.pdave" value is already stored in my context of "SelctedUsers".

So how can i get that value so that my URL is properly built ???

Former Member
0 Kudos
public void
onActionOpenUserDetails
(
  com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent,
  com.nvidia.ep.km.wdp.IPrivateResourcePermissionView.ISelctedUsersElement row)
{
  String strUID = "";
  String strURL = "";
  IWDWindow window = null;
  /* This is wrong: */
  strUID = row+".usr";
  /* Use something like this: */
  strUID = row.getSelectedUseUMEID()  + ".usr";
  strURL =   "http://sape7s:50000/irj/servlet/prt/portal/prtroot/com.sap.netweaver.kmc.people.PeopleDetails?Uri=/ume/users/"+strUID;
  window =wdComponentAPI.getWindowManager().createExternalWindow(strURL,"User Details",false);
  window.open();
}

Armin

lakshmi_narayana2
Active Participant
0 Kudos

Armin

Following is my code for doModify() and my action methods.

Am getting the user(row value) as null in my action method.

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

{

IWDLinkToAction link = (IWDLinkToAction) view.getElement("selectedLink");

IPrivateResourcePermissionView.ISelctedUsersElement element = wdContext.createSelctedUsersElement();

if(view.getElement("selectedLink") != null)

{

link.mappingOfOnAction().addSourceMapping("nodeElement","row");

}

}

public void onActionOpenUserDetails(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, com.nvidia.ep.km.wdp.IPrivateResourcePermissionView.ISelctedUsersElement row)

{

String strUID = "";

String strURL = "";

IWDWindow window = null;

strUID = row+".usr";

strURL = "http://sape7s:50000/irj/servlet/prt/portal/prtroot/com.sap.netweaver.kmc.people.PeopleDetails?Uri=/ume/users/"+strUID;

window = wdComponentAPI.getWindowManager().createExternalWindow(strURL,"User Details",false);

window.open();

}

Former Member
0 Kudos

public static void wdDoModifyView
(
  IPrivateResourcePermissionView wdThis,
  IPrivateResourcePermissionView.IContextNode wdContext,
  com.sap.tc.webdynpro.progmodel.api.IWDView view,
  boolean firstTime
)
{
  if (firstTime)
  {
    IWDLinkToAction link = (IWDLinkToAction)
      view.getElement("selectedLink");
    link.mappingOfOnAction().addSourceMapping
    (
      "nodeElement",
      "row"
    );
  }
}
}

Please verify that the ID of the LinkToAction (table cell editor) is really "selectedLink". Case matters here!

Armin

lakshmi_narayana2
Active Participant
0 Kudos

Armin

My Scenario is this.

I have a link to Action as table cell editor.When i click on the link (which is a user id frm UME) i need to pass that clicked user id to a URL and open it in a new window.

I couldn't understand the parameters "nodeElement" and "row" in your code.

editor.mappingOfOnAction().addSourceMapping

(

"nodeElement", /* name of (implicit) event parameter */

"row" /* name of action parameter */

);

Also my Context for the tables is as follows:

-SelectedUsers (value node)

--selectedUserName (value attribute)

--selectedUseUMEID (value attribute)

Former Member
0 Kudos

You have assigned some action A to the LinkToAction element.

Create an action parameter "row" of type ISelectedUsersElement.

Then the parameter mapping statement will map the implicit event parameter named "nodeElement" to the action parameter "row". This means that when the link is clicked, the action handler is called and the parameter "row" contains the node element (table row) where the link has been clicked.

The name of the action parameter can be freely chosen, but the event parameter name "nodeElement" is predefined and must be used exactly like this.

Armin

lakshmi_narayana2
Active Participant
0 Kudos

How can i excatly check whether the view element is created or not ??

Former Member
0 Kudos

If you have created the view element at designtime (with the view design tool), it is created if method wdDoModifyView() is entered for the first time.

Generally, you can check inside wdDoModifyView() with a statement like

if (view.getElement("ID-of-view-element") != null)
{
  /* view element exists */
}

Armin

lakshmi_narayana2
Active Participant
0 Kudos

Armin

In your code it is mentioned

if(firsttime){

}

I tried implementing your solution without including the if(firsttime) condition and am getting a null pointer. can u pl explain how can i check for the " firts time" condition

Thanks

Former Member
0 Kudos

The parameter mapping statement should only be executed once after view element creation. That's the reason I put it inside the if-statement.

Why you get a NPE is difficult to say without seeing the code.

Armin

Former Member
0 Kudos

Hi ,

I would lile to know the text assigned to that particular UI element - Link to action , want to access it in the event handler method .

Which parameter is the text in the WDEVENT !!

Best Regards

Sid

Former Member
0 Kudos

I have the impression that you really want to determine the <b>row</b> where the link has been clicked. Is that the case?

To do this, add a parameter "row" of type IWDNodeElement to your action, and implement a parameter mapping:

wdDoModifyView(...)
{
  if (firstTime)
  {
    IWDLinkToAction editor = (IWDLinkToAction) view.getElement("ID-of-editor");
    editor.mappingOfOnAction().addSourceMapping
    (
      "nodeElement", /* name of (implicit) event parameter */
      "row" /* name of action parameter */
    );
  }
}

Then you get the node element corresponding to the table row where the link has been clicked as action parameter "row".

The text of the link may then be taken from the attribute (of the passed node element) to which the "text" property of the link is bound.

Armin

Former Member
0 Kudos

I want to pass the value of the table column with the action .

Will it be possible .

Best Regards

Sid

Former Member
0 Kudos

Why not simply assign an exclusive action to the link (table cell editor). If the action handler is called, you <b>know</b> the table column.

Armin

Former Member
0 Kudos

In principle, you can pass fixed values using the IWDLinkToAction.mappingOfOnAction().addParameter() methods.

But in the case of a table, this is not necessary, because there is exactly one table cell editor per column (in NW04).

Armin