on 10-01-2008 11:26 AM
Hi Experts ,
I want to create dynamic text edits and groups.
Thank You.
Hi Radhika,
Do go through the links passed on to you by Ashutosh. They are very good blogs written by Thomas Szuecs for working with dynamic programming in webdynpro ABAP. Please use the coding as below to create a group & an textedit element within it.
1) Obtain the reference to the ROOTUIELEMENTCONTAINER
2) Set the desired layout information to it
3) Create the group & textEdit elements with all the default values
4) Provide the layout information to even the group & textEdit elements
5) Add the elements as children to the screen container element
Hope that this is useful for you.
Regards,
Uday
METHOD wddomodifyview .
DATA: lr_container TYPE REF TO cl_wd_uielement_container,
lr_group TYPE REF TO cl_wd_group,
lr_caption_group TYPE REF TO cl_wd_caption,
lr_textedit type ref to cl_wd_text_edit.
check first_time = ABAP_TRUE.
lr_container ?= view->get_root_element( ). " Get reference of ROOTUIELEMENTCONTAINER
cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).
lr_group = cl_wd_group=>new_group( id = 'GROUP' ). " Create the GROUP element
lr_group->set_width( value = '50%' ).
cl_wd_matrix_layout=>new_matrix_layout( container = lr_group ).
cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_group ).
lr_caption_group = cl_wd_caption=>new_caption( text = 'Group Header' ).
lr_group->set_header( the_header = lr_caption_group ).
" Create the textEdit element
lr_textedit = cl_wd_text_edit=>new_text_edit( id = 'TVIEW' " Provide a unique id to your textedit element
cols = 20 " Specify the number of columns
rows = 20 " Specify the number of rows
width = '90%' " Specify the width
bind_value = 'TEXT' ). " Here we should pass an attribute name to which we want to bind the textedit element to
cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_textedit ).
" Add the group & textEdit elements as children to the ROOTUIELEMENT container
lr_container->add_child( the_child = lr_group ).
lr_group->add_child( the_child = lr_textedit ).
endmethod.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Radhika,
Its quite possible to do so.
lr_textedit = cl_wd_text_edit=>new_text_edit( id = 'TVIEW'
cols = 20
rows = 20
width = '90%'
bind_value = 'TEXT' ).
As shown above we are trying to bind the value to be displayed in the textEdit with the context attribute named TEXT. So if we can just fill the data in this attribute in the same format then we would get the desired output. You can use the example coding below to get an idea as to how you can populate the attribute that way.
Note: I have declared attribute TEXT of type STRING directly under the root node CONTEXT
METHOD wddoinit .
DATA: lr_element TYPE REF TO if_wd_context_element,
s TYPE string.
lr_element = wd_context->get_element( ).
CONCATENATE 'Testing'
'the'
'idea!' INTO s SEPARATED BY cl_abap_char_utilities=>newline.
lr_element->set_attribute( EXPORTING name = 'TEXT'
value = s ).
ENDMETHOD.
Regards,
Uday
Hi Radhika,
Sorry was busy with some other tasks. Just go through this sample code snippet which does the following.
1) It dynamically creates a context node named CHILD and then creates 4 attributes ATTR1, ATTR2,..
2) Creates a GROUP UI element with a caption attached to it
3) Create 4 textEdit UI elements bound to the 4 context attributes created earlier and embed them within the group
Regards,
Uday
METHOD wddomodifyview.
DATA: lr_container TYPE REF TO cl_wd_uielement_container,
lr_group TYPE REF TO cl_wd_group,
lr_caption_group TYPE REF TO cl_wd_caption,
lr_textedit TYPE REF TO cl_wd_text_edit,
lr_node_info TYPE REF TO if_wd_context_node_info,
lr_node TYPE REF TO if_wd_context_node,
lr_element TYPE REF TO if_wd_context_element,
lr_attribute_info TYPE wdr_context_attribute_info,
content TYPE string,
attribute_name TYPE string,
lv_textview_id TYPE string.
CHECK first_time = abap_true.
lr_node_info = wd_context->get_node_info( ).
CALL METHOD lr_node_info->add_new_child_node
EXPORTING
name = 'CHILD'
is_mandatory = abap_false
is_multiple = abap_true
is_multiple_selection = abap_true
is_singleton = abap_false
is_initialize_lead_selection = abap_true
is_static = abap_false
RECEIVING
child_node_info = lr_node_info.
lr_container ?= view->get_root_element( ).
cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).
lr_group = cl_wd_group=>new_group( id = 'GROUP' ).
lr_group->set_width( value = '50%' ).
cl_wd_matrix_layout=>new_matrix_layout( container = lr_group ).
cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_group ).
lr_caption_group = cl_wd_caption=>new_caption( text = 'Group Header' ).
lr_group->set_header( the_header = lr_caption_group ).
DO 4 TIMES.
MOVE sy-index TO attribute_name.
** Preparing the data to be displayed in the textEdit i.e, data for context attribute
CONCATENATE 'This'
'is the'
'data for textEdit number: '
attribute_name INTO content SEPARATED BY cl_abap_char_utilities=>newline.
CONCATENATE 'ATTR'
attribute_name INTO attribute_name.
** Condense the ID to ensure that the format is consistent with SAP standard
CONDENSE attribute_name NO-GAPS.
** Prepare properties of attribute & add to context node CHILD
lr_attribute_info-name = attribute_name.
lr_attribute_info-type_name = 'STRING'.
lr_attribute_info-value_help_mode = '0'.
lr_node_info->add_attribute( EXPORTING attribute_info = lr_attribute_info ).
lr_node = wd_context->get_child_node( name = 'CHILD' ).
lr_element = lr_node->create_element( ).
lr_element->set_attribute( name = attribute_name
value = content ).
lr_node->bind_element( new_item = lr_element
set_initial_elements = abap_false ).
** Compute the attribute path dynamically i.e, like CHILD.ATTR1
CONCATENATE 'CHILD.'
attribute_name INTO attribute_name.
CONDENSE attribute_name NO-GAPS.
lr_textedit = cl_wd_text_edit=>new_text_edit( cols = 10
rows = 5
width = '90%'
bind_value = attribute_name ).
cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_textedit ).
lr_group->add_child( the_child = lr_textedit ).
ENDDO.
lr_container->add_child( the_child = lr_group ).
ENDMETHOD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.