cancel
Showing results for 
Search instead for 
Did you mean: 

Issue when trying to move attribute from Context attribute to View Context.

Former Member
0 Kudos

Hi All, I have an attribute defined in Context of Component controller. I wanted to know whether we can move the same attribute to a view context from component controller. When i am trying to do this i am getting an error message "Mapping for root node CONTEXT not possible".

Thank you ,

Regards,

Swaroop

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Swaroop,

Right click on the context of the view :

Create using the wizard-->Copy nodes of different context

In the next screen , in the field u201Cview/controller namesu201D enter the u201CCOMPONENTCONTROLLERu201D ( you can do it by hitting F4 button also ) and select the radio button

u201CDo not copy node itself, but attributes and sub nodes onlyu201D.

Select the context in the next screen and select continue.

The sudnodes and attributes get mapped with the view controller.

Regards,

Sravanthi

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Swaroop,

Directly, you can not move from Component controller context to View context. What pankaj said is correct, and after mapping to view context, just read only the attribute, it may fullfill your requirement.

Regards,

Xavier.p

Former Member
0 Kudos

Hi,

U need to put your attribute in a node, then only you will be able to do mapping.

First create a node and then put the context attribute of component controller in the created node.

There after you can do the mapping of attribute.

Thanks,

Pankaj Aggarwal

Former Member
0 Kudos

Hi Pankaj, Ya we can do that moving it to a node but i was more curious to know is there any particular reason for not doing the same with an attribute which was defined in context controller?

Thank you,

Regards

Swaroop Patri

Former Member
0 Kudos

Hello,

Please see this: .

Regards.

Former Member
0 Kudos

Hi David, I understand that a view context can make use of attribute defined in Component controller(as this is global). The issue which i am facing is I have an attribute defined in component controller, and I am trying to move this attribute to view context. Its working fine with a Node but with attribute i am getting the error which i mentioned.

I am actually new to WebDynpro but what i think is if we can move a node then we can also move the attribute from component controller to view context. let me know the reason for this error message.

Thank You,

Regards,

Swaroop Patri

Former Member
0 Kudos

I think you cannot map on context node of a view context.

Former Member
0 Kudos

Hi Swaroop,

What you said is correct.We can map the controller context attribute to view context when it is under the node with out context node we cann't map to view context directly.

But we have other way to access the controller context in view.You have an instance of Component controller in your view i.e WD_COMP_CONTROLLER .You can use this and access the attribute of controller in this way.

data:
    lo_el_context type ref to if_wd_context_element,
    lv_attribute  type wd_comp_controller->element_context-attribute.

Former Member
0 Kudos

Hi Suman, I think this might work but can you let me know how to retrieve the value which is populated in the controller. Also, any idea why we cannot access a controller's attribute directly in the view with out a node?

Regards,

Swaroop Patri

Former Member
0 Kudos

Hi Swaroop,

Do in this way.You have attribute WD_CONTEXT in the Component controller this is nothing but a reference to your component controller context.So you can access the component controller context attribute any of the view directly.Check the below code.

data lo_el_context type ref to if_wd_context_element.
data ls_context type wd_context->element_context.
data lv_a_table_visibility like ls_context-a_table_visibility.

* get element via lead selection
  lo_el_context = wd_context->get_element(  ).

* get single attribute
  lo_el_context->get_attribute(
    exporting
      name =  `A_TABLE_VISIBILITY`
    importing
      value = lv_a_table_visibility ).