cancel
Showing results for 
Search instead for 
Did you mean: 

add an element to a node.

Former Member
0 Kudos

Hi,

Any help to add an element to a node.

I have a node in a view context and I would like to add its content to a component controller context node which has the same structure ( subnodes and attributes) .

Thanks in advance.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Can not be done.

I added a node of node to achieve it.

Former Member
0 Kudos

Hi dyngry,

So what is stopping you to add the new attributte to the context node in the component controller. Just right click and add attribute of that type.

I think you have keep the dictionary structure of some type and from that you have added attribute as add attribute from structure. Now this is going to stop you to add other attribute which is not in the structure.

You can remove the dictionary structure from the field as i think it is not going to effect , then add one attribute.

Alternatively create a node in component controller with required attributes and map it with the view context.

In case of any issue reply.

Regards,

Monishankar C

Former Member
0 Kudos

Hi,

Sorry , i think i misspoke. I'll try to be clearer.

It's as simple as you have a registration screen of a game. and then players must register one by one in the same screen.

So you have the same screen with the same structure behind and each time when a player press submit button after its registration you add a new entry in the table and clear all fields of the same screen for the next player.

I want to do some thing like a table of node in the component controller.

For this i just use a main node with cardinality 0..n.

Then in each view i have the same node structure that i use.

When the user press submit i want to add all what he has filled-in as a new entry in the principal node in the component controller context. And then pass to the next view which use the same structure.

Here is the wrong code in the submit method to have an idea

method ONACTIONSUBMIT .

*-----------------------------------------------------------
**   prepare Usage table
*-----------------------------------------------------------

  DATA: lo_node_1 TYPE REF TO if_wd_context_node.
  DATA: l_prop_usage_tab  TYPE STANDARD TABLE OF bapi1077du,
        l_prop_comp_tab TYPE STANDARD TABLE OF bapi1077vp.

*-----------------------------------------------------------

  DATA :  lo_component TYPE REF TO if_wd_component,
          lo_context TYPE REF TO if_wd_context,
          lo_controller TYPE REF TO if_wd_controller,
          lo_node TYPE REF TO  if_wd_context_node,
          lo_child TYPE REF TO if_wd_context_node.

  lo_component = wd_comp_controller->wd_get_api( ).
  lo_controller ?= lo_component.

* get controller context node
  CALL METHOD lo_controller->get_context
    RECEIVING
      context = lo_context.

* get root node component controller
  lo_node = lo_context->root_node.

* get prop_component node of component controller
  lo_node = lo_node->get_child_node( 'GENERAL_COMPO' ).

*-----------------------------------------------------------
  DATA lo_element type ref to IF_WD_CONTEXT_ELEMENT.
  lo_node_1 = WD_CONTEXT->get_child_node( name = 'GENERAL_COMPO' ).
  lo_element = lo_node->create_element( STATIC_ATTRIBUTE_VALUES = lo_node_1 ).

  lo_node->BIND_ELEMENT( new_item = lo_element set_initial_elements = abap_false ).



*  lo_child = lo_node->get_child_node( 'COMPOSITION' ).
*  lo_child->BIND_ELEMENT( l_prop_comp_tab ).

*  lo_child = lo_node->get_child_node( 'USAGE' ).
*  lo_child->BIND_ELEMENT( l_prop_usage_tab ).

endmethod. 

General_comp is the main node. it is with 0..n cardinality in the controller context.

And with 1..1 cardinality in the view context and there is no mapping between them.

It contains 2 sub-node "usage" and composition.

Hopefully it is clearer

Thanks for help

Edited by: dyngry on Apr 21, 2011 9:31 AM

vineetrrakesh
Explorer
0 Kudos

Hi,

I think we can't add the element from the view context to the compponent contytroller's context. But you can acheive your requiremnt as below.

1. Create a method "ADD_NEW_PLAYER" in your component controller which has importing parameter as a node i.e. "IF_WD_CONTEXT_NODE"

2. Now inside the method "ADD_NEW_PALYER" Read the attributes from the incoming node. Append this structure to the component controllers node.

3. In your View just call this method by passing the context node of the View. (You should be able to call the component controller method anyway so you have to basically append the filled in data to the compoenent controller.)

I hope it would be of any help for you.

Regards

Vineet

Former Member
0 Kudos

Hi,

You can map Component controller context to view context but vice versa is not possible.

cheers,

Kris.