on 12-03-2008 1:07 PM
Hi, experts,
I still have problems with the issue:
two views share the data stored in a data structure.
I created this structure as node of component controller and also as node of each of the two views using context mapping to that node in component controller. After the action in View 1 is triggered, the node in view controller will be filled with data (the data should be extracted using get attribute from another node element and transfered to this node using set attribute) and then it will be navigated to view 2.
And I think the data should be automatically stored in the node of component controller and also that of view 2. In view 2 the data will be represented.
But when I try to retrieve the attribute of this data structure in view 2, it failed: the data is not automatically stored in the corresponding node in view 2.
Do I still need to do something to transfer the data in node of view1 to the node of component controller and to node of view 2?
The following code is in view 1(I stored the data in the attribute)
DATA new_ele TYPE REF TO if_wd_context_element.
DATA ls_et_surveylist TYPE wd_this->element_et_surveylist.
DATA ele TYPE REF TO if_wd_context_element.
DATA node type REF TO IF_WD_CONTEXT_NODE.
DATA: guid LIKE ls_et_surveylist-guid,
id LIKE ls_et_surveylist-id,
description LIKE ls_et_surveylist-description,
proc_org_id LIKE ls_et_surveylist-proc_org_id,
category_id LIKE ls_et_surveylist-category_id,
product_id LIKE ls_et_surveylist-product_id,
creator LIKE ls_et_surveylist-creator,
create_dat LIKE ls_et_surveylist-create_dat.
get the context element whose linkToAction is triggered.
ele ?= wdevent->get_context_element( name = 'CONTEXT_ELEMENT' ).
get the attributes of this context element.
CALL METHOD ele->get_attribute EXPORTING name = 'GUID' IMPORTING value = guid.
CALL METHOD ele->get_attribute EXPORTING name = 'ID' IMPORTING value = id.
CALL METHOD ele->get_attribute EXPORTING name = 'DESCRIPTION' IMPORTING value = description.
CALL METHOD ele->get_attribute EXPORTING name = 'PROC_ORG_ID' IMPORTING value = proc_org_id.
CALL METHOD ele->get_attribute EXPORTING name = 'CATEGORY_ID' IMPORTING value = category_id.
CALL METHOD ele->get_attribute EXPORTING name = 'PRODUCT_ID' IMPORTING value = product_id.
CALL METHOD ele->get_attribute EXPORTING name = 'CREATOR' IMPORTING value = creator.
CALL METHOD ele->get_attribute EXPORTING name = 'CREATE_DAT' IMPORTING value = create_dat.
set the attributes of the node to be shared.
node = wd_context->get_child_node( name = 'SURVEY_ELEMENT' ).
new_ele ?= node->create_element( ).
new_ele->SET_ATTRIBUTE( name = 'GUID' value = guid ).
new_ele->SET_ATTRIBUTE( name = 'ID' value = id ).
new_ele->SET_ATTRIBUTE( name = 'DESCRIPTION' value = description ).
new_ele->SET_ATTRIBUTE( name = 'PROC_ORG_ID' value = proc_org_id ).
new_ele->SET_ATTRIBUTE( name = 'CATEGORY_ID' value = category_id ).
new_ele->SET_ATTRIBUTE( name = 'PRODUCT_ID' value = product_id ).
new_ele->SET_ATTRIBUTE( name = 'CREATOR' value = creator ).
new_ele->SET_ATTRIBUTE( name = 'CREATE_DAT' value = create_dat ).
wd_this->fire_survey_detail_plg(
).
Thanks
Fan
Hi, Thomas
I have solved the problem by setting the cardinality of node to 1..1. Then the lead selection works:-)
Thank you very much for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have debugged the code again and I found the problem:
lo_el_survey_element = lo_nd_survey_element->get_element( ).
is always initial.
The problem is indeed the lead selection. But I have set the node with cardinality 0...1, selection 0..n and initialization lead selection as checked.
Why could something like this happen?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, I have used the wizard to generate code:
DATA: et_survey TYPE TABLE OF ZSRMVE_SURVEYITM,
node TYPE REF TO IF_WD_CONTEXT_NODE,
subnode TYPE REF TO IF_WD_CONTEXT_NODE.
DATA lo_nd_survey_element TYPE REF TO if_wd_context_node.
DATA lo_el_survey_element TYPE REF TO if_wd_context_element.
DATA ls_survey_element TYPE wd_this->element_survey_element.
DATA lv_guid LIKE ls_survey_element-guid.
navigate from <CONTEXT> to <SURVEY_ELEMENT> via lead selection
lo_nd_survey_element = wd_context->get_child_node( name = wd_this->wdctx_survey_element ).
@TODO handle not set lead selection
IF lo_nd_survey_element IS INITIAL.
ENDIF.
get element via lead selection
lo_el_survey_element = lo_nd_survey_element->get_element( ).
@TODO handle not set lead selection
IF lo_el_survey_element IS INITIAL.
ENDIF.
alternative access via index
lo_el_survey_element = lo_nd_survey_element->get_element( index = 1 ).
@TODO handle non existant child
IF lo_el_survey_element IS INITIAL.
ENDIF.
get single attribute
lo_el_survey_element->get_attribute(
EXPORTING
name = `GUID`
IMPORTING
value = lv_guid ).
The runtime error occurs herein get_attribute.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you have Initialize Lead Selection checked for the noode? It might just be that you don't have a lead selection - so you can't get a conext element by lead selection. Have you set a breakpoint in this second block of code and used the Web Dynpro debugger to view what the context looks like at this point?
Hi, Thomas
I have checked the mapping and I think the mapping is right. The mapping paths of the node in both view 1 and 2 is ..componentcontroller.survey_element.
Still when I retrieve the data in view 2 with get_attribute method, the error msg is
"Access via 'NULL' object reference not possible". The error is in get_attribute method according to the debugging process.
Best Regards
Fan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you truely used context mapping between the component controller and the views, then the data doesn't actually get copied. You only have one set of data objects in the component controller and both views access this same object via references. There is no sync points or copying that needs to take place. Double check your view contexts and make sure you are actually doing context mapping and not copying the context nodes from one place to another.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.