cancel
Showing results for 
Search instead for 
Did you mean: 

get view element property from component Controller ?

Former Member
0 Kudos

Hi,

I have the following code inside a view(resultView) in my java webdynpro project which works properly and  dynamically gets me the header text of a table column  to be displayed in a popup message

IWDTableColumn TabCol;

String fldName;


TabCol =(IWDTableColumn)((IWDView)wdThis.wdGetAPI()).getElement(fldName);

fldName1= TabCol.getHeader().getText();

My question is – How can I access the same table column header text from the component controller(of this view)?

Accepted Solutions (1)

Accepted Solutions (1)

daniel_ruiz2
Active Contributor
0 Kudos

Hi Simi,

As per my understanding, you shouldn't be able to play around with view lifecycle in web dynpro - not that you cannot do that, pretty sure you can achieve the same using some reflection.

However, I would suggest you a different approach since seems you have a code working in the View, you need to access the same 'String' in the Component Controller.

1. Create a Attribute in the Component Controller Context, type string;

2. Map that Attribute in the View that you want to extract the "Header" string;

3. Implement wdModifyView, and keep that 'Context Attribute' always up-to-date;

  -- This way, each 'Roundtrip' you will be updating the value into the Component Controller's Context;

4. Access the Component Controller Attribute instead of a 'View Attribute' in your Component Controller;

Also note, if you have 'defined times' or 'known scenarios' where this Header is updated, could add a little performance updating the context attribute 'only' when that attribute really has changed.

Hope it helps,

D.

Former Member
0 Kudos

HI Daniel,

For accessing elements from view to controller or vice versa... you need to create a context mapping between the two and this can be done by using below steps:-

1) create context attribute/node as per the schmea you have ,in view and controller and map them by drag and drop(from right to left)

2) write a code in controller for context binding(as you need to access the view elements into controller)

i hope this way you will be able to access the result view elements in your controller.

daniel_ruiz2
Active Contributor
0 Kudos

Hi Priyanka,

I think you should have addressed your answer to the original thread poster... However, case you are commenting the approach I suggested, there seems to be a ' code snippet ' in the question where the header is being accessed dynamically transversing the View ( his snippet is probably placed inside the wdModifyView ).

One " would / could " dynamically bind the header element as well and access it through the Context, but I took my time to consider the fact he is not accessing a ' bound ' attribute; instead it would appear he is already in wdModifyView with his snippet and " maybe " there is a reason for that...

😃

Hope this clarifies my answer...

D.

Answers (1)

Answers (1)

junwu
Active Contributor
0 Kudos

what's your original requirement?

Former Member
0 Kudos

i have to get the header text of table column in a view from the component controller.

junwu
Active Contributor
0 Kudos

why not bind the header to the context?