on 08-10-2009 1:41 PM
Hi,
I am using FileUploadUIElement and I need to read filename, type and size in my Button click action.
I have seen the standard Test UI elements component WDR_TEST_EVENTS which does this in wdDoModifyView method.
But is there any way to read them outside wdDoModifyView ? In a normal custom action event?
Thanks and regards,
Amey Mogare
Hi,
Yes you can definately do the same in any of the custom events implemented.
You will have to create a global attribute in the component controller say g_upload type ref to cl_wd_file_upload ( mark the Public checkbox ).
Now create an action for you button and copy the rest of the code from view modfiy and place it in this method,
using wd_comp_controller->g_upload get the required values as follows.
" Now in your view modify instead of,
file_upload2 ?= view->get_element( 'FILEUPLOAD2' ).
" you say,
wd_comp_controller->g_upload ?= view->get_element( 'FILEUPLOAD2' ).
Regards,
Radhika.* get the content of the filename property
filename = wd_comp_controller->g_upload->get_file_name( ).
* get the content of the mime-type property
mime_type = wd_comp_controller->g_upload->get_mime_type( ).
wd_context->get_attribute( exporting name = 'FILECONTENT' importing value = filecontent ).
size = xstrlen( filecontent ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is absolutely NOT the recommended way of accessing these values. The direct interaction with the UI elements via coding in WDDOMODIFYVIEW should only used as a last resort for dynamically generated UI elements. You see this in some of the SAP test applications becuase of their dynamic nature. However this is NOT a best practice.
Instead you should data bind context attributes to the properties of the UI element. There are properties for fileName, dataType, and data:
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/b3/be7941601b1d09e10000000a155106/frameset.htm
There is no reason to go through all this trouble of saving the instance of the UI element in component controller attribute and accessing programatically when you can just get the information from the context.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.