cancel
Showing results for 
Search instead for 
Did you mean: 

Passing repeatable NodeElement between views

0 Kudos

Hi colleagues,

I will try to explain you my problem.

I have defined repeatable context node in Component controller

(For example: CompController.Node)

I Mapped this node in two views (For example IPrivateView1.Node and IPrivateView2.Node)

In first view View1 I have table with master column that is bind to this repeatable Node.

In master column I have LinkToAction element with "select" action

In this "select" action I pass NodeElement as parameter (I create mapping in wdDoModifyView method for this "select" action)

"select" action work fine - I get the correct selected element in this action

BUT How to pass this NodeElement to the View2

(View2 is open in new Popup window and how to get known for the selected element in View1)

May be the solution will be to create set/get methods in CompController, but how to cast the parameter

in set method (in View1) and in get method (in View2)

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Rosen:

The nodes and values are mapped by the Component Controller, and their values. ít´s is easy mapping them in the diagram view. The context of the Component Controller is used by all the views.

This link explains you how to do it:

http://help.sap.com/saphelp_erp2005/helpdata/en/7b/c10f2a93c8b84d8c8ee6105d8f64ed/content.htm

Good luck.

Josue

Message was edited by: Josue Cruz

0 Kudos

Hi Colleagues,

In general this is true for normal Context Node

But For repeatable Node this is not the true.

In repeatable node I can't use leadSelection- and I do not have selected (current) element in my table with master column.

PS: My table with Master column does not have selection. Only LinkoAction data and in the action I can find out the touched element (I get this information from addtional parameter in action method)

Message was edited by: Rosen Chaushev

Former Member
0 Kudos

Rosen,

You could setup set/get methods on the component controller to hold the selected element. View1 would set it and view2 would get it. Since the compoent controller has the original context, casting should not be an issue.

If it does turn out to be an issue, you could copy the element.

-Cindy

0 Kudos

Hi Cindy,

I define the method setShared(IPublicComp.ITestElement) in Componenet Controller

But when I try to use it in View1 as

public void onActionTest(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent,

IPrivateView1.ITestElement nodeElement )

{

//@@begin onActionTest(ServerEvent)

wdThis.wdGetCompController().setSharedElement((IPublicComp.ITestElement)nodeElement);

//@@end

}

I have compilation error:

Cannot cast from IPrivateView1.ITestElement to IPublicComp.ITestElement

So casting is a problem ( I agree that the data is the same in context of Comp and in context of View1 and View2 but this does not help me)

Also I have the data in context of Component Controller

I do not want to copy the data in context of views. Copy of my repeatable(recursive) data is too expensive operation and in my case and I can't afford this.

Rosen

Message was edited by: Rosen Chaushev

Message was edited by: Rosen Chaushev

Message was edited by: Rosen Chaushev

Former Member
0 Kudos

Rosen,

Change the method signature to <i>(IWDNodeElement)</i> instead of explicit specifications like <i>(IPublicComp.ITestElement)</i> or <i>(IPrivateView1.ITestElement nodeElement)</i>.

In this way, you can avoid the <i>type casting problem</i> by casting the NodeElement to the required type inside your method/action.

Bala

0 Kudos

Hi,

The problem now is that in Component controller I can not create method get that returns IWDNodeElement

Does someone have other ideas - How to pass IWDNodeElement between two views. (may be with event raise in first view and handle the event in second view ???

Thanks in advance

Rosen

Message was edited by: Rosen Chaushev

Message was edited by: Rosen Chaushev

Former Member
0 Kudos

Hi,

<i><The problem now is that in Component controller I can not create method get that returns IWDNodeElement></i>

What is the problem u r facing? You should be able to set the Return Type of the method to IWDNodeElement.Here are the steps to set it.

1.Go to the Methods Tab of the Custom/Component Controller (CC).

2.Select New --> Method.

3.Click the button "..." available to the right of the return Type Dropdown.

4.Choose "Java Native Type" in the Window that pops up.

5.Click "Browse" button and type in IWDNodeElement.

6.Click "Ok". (Probably in the two successive windows).

Thus you will be able to set the return type of the method to the Native Java Type of your choice.

Bala

0 Kudos

Thanks Bala for your reply

I created getMethod in my Component Controller ( The Browse button was hidden - and I saw it after enlarge the dialog Thanks for your advise.

I managed to set my shared object to this generic type IWDNodeElement

This code is from my setter in View 1

public void onActionShowSummary(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent,

IPrivateView1.ITestElement nodeElement )

{

//@@begin onActionShowSummary(ServerEvent)

wdThis.wdGetCompController().setSharedElement(nodeElement);

//@@end

}

But later in View 2

I do not managed to cast to the correct type:

and Now I have runtime error

in this code

IPrivateView2.ITestElement nodeElement=(IPrivateView2.ITestElement)

wdThis.wdGetCompController().getSharedElement();

Finally in View2 I want to iterate over TestElement

because instance of generic type IWDNodeElement is not so useful for me

Rosen

Message was edited by: Rosen Chaushev

0 Kudos

Thanks Bala

With little changes I think that I found the solution

In Setter I Pass

wdThis.wdGetTemplateInstallerCompController().setSharedElement(nodeElement.mappedTestElement);

And in View2 I get and cast to Component Controller Public element

IPublicComp.ITestElement nodeElement=(IPublicComp.ITestElement) wdThis.wdGetCompController().getSharedElement();

Now I think is OK

Thanks a lot again

Regards, Rosen

Message was edited by: Rosen Chaushev

Former Member
0 Kudos

Rosen,

Instead of using the getSharedElement() method, you can directly access the

context of the Custom/Component controller from the view 2.

wdThis.wdGetWD_WS_IntgrationComponentController().wdGetContext()
.currentTestElement().get<Attribute>();

will give you the required values from the required attributes.

Bala

0 Kudos

Bala , My case is a little diferent - I can not used the Current(selected) element in context - because I don't have such.

But with get/set methods I think it is OK for me

Thanks again

Rosen

Answers (1)

Answers (1)

Former Member
0 Kudos

Rosen,

When the element is selected, the context node knows it is the selected element. Since both views are mapped to the context node, the second view can just ask for the lead selection on the node to get the element that is selected.

-Cindy