on 10-08-2008 3:30 PM
Hi,
In my abap web dynpro application, I have an Xstring that I want to view in my brower as HTML.
Do you know how to do this?
Thanks in advance
Karim
Thanks Thomas,
What do you suggest for displaying my custom html?
Karim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well me being an SAP employee, I guess I can't technically recommend the iFrame since it is depreciated; but technically it will meet your needs. Just keep in mind that there is no session handling or authentication for the iFrame. However if your passing it HTML directly this doesn't appear to be a problem. If I could recommend this, then I would suggest that you place the HTML into a cached response object in the ICM and generate a temporary URL pointing to it. You know something like this (not that I'm recommending that you do that):
data lo_el_text type ref to if_wd_context_element.
data lv_html_text type wd_this->element_text-html_text.
data lv_iframe_url type wd_this->element_context-iframe_url.
lo_el_text = wd_context->get_child_node( name = wd_this->wdctx_text )->get_element( ).
lo_el_text->get_attribute(
exporting
name = `HTML_TEXT`
importing
value = lv_html_text ).
****Create the cached response object that we will insert our content into
data: cached_response type ref to if_http_response.
create object cached_response
type
cl_http_response
exporting
add_c_msg = 1.
* cached_response->set_compression( options = cached_response->IF_HTTP_ENTITY~CO_COMPRESS_IN_ALL_CASES ).
try. " ignore, if compression can not be switched on
call method cached_response->set_compression
exporting
options = cached_response->co_compress_based_on_mime_type
exceptions
others = 1.
catch cx_root.
endtry.
****set the data and the headers
data: l_app_type type string.
cached_response->set_cdata( lv_html_text ).
l_app_type = 'text/html'.
cached_response->set_header_field( name = if_http_header_fields=>content_type
value = l_app_type ).
cached_response->set_status( code = 200 reason = 'OK' ).
cached_response->server_cache_expire_rel( expires_rel = 60 ).
data: guid type guid_32.
call function 'GUID_CREATE'
importing
ev_guid_32 = guid.
concatenate '/sap/public' '/' guid '.' 'html' into lv_iframe_url.
****Cache the URL
cl_http_server=>server_cache_upload( url = lv_iframe_url
response = cached_response ).
wd_context->get_element( )->set_attribute(
name = `IFRAME_URL`
value = lv_iframe_url ).
Well the iFrame UI element is technically depreciated and shouldn't be used any longer, but technically it is about the only way to currently display custom HTML inside of Web Dynpro. In later SP levels you also have the formattedTextView, but the elements from HTML that it can display are very limited.
To convert the XSTRING, you would just have to convert the XSTRING to STRING. For that I would suggest using the CL_ABAP_CONV_IN_CE class.
data:
convin type ref to cl_abap_conv_in_ce,
buffer type xstring
text_buffer type string.
call method cl_abap_conv_in_ce=>create
exporting
input = buffer
receiving
conv = convin.
call method convin->read
importing
data = text_buffer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
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.