cancel
Showing results for 
Search instead for 
Did you mean: 

Custom style manager don't work

0 Kudos
459

Hello!

I'm trying to use WebDynPro property styleClassName.

I've found component WDR_TEST_CUSTOM_STYLES with examples + there is a sample code in if_wd_custom_style documentation.

Everything looks quite simple (sample code I'm using below). New, empty WDP component, only with button + init code.

But! In WDR_TEST_CUSTOM_STYLES its works, in my app - not.

When I tried to copy WDR_TEST_CUSTOM_STYLES to my $TMP it stopped working too (endless loading on views with style).

I didnt find where bug happens - somewhere deep in standart AFTER my code.

Any hints why it could be?

============================

DATA l_style_manager  TYPE REF TO if_wd_custom_style_manager.

   DATA l_style          TYPE REF TO if_wd_custom_style.

   " Get the custom style manager

   l_style_manager =

     wd_comp_controller->wd_get_api( )->get_application( )->get_custom_style_manager( ).

   " Create a new custom style with name myButtonStyle for BUTTON elements

   l_style =

     l_style_manager->create_custom_style( style_class_name = 'STYLE'

                                              element_type  = 'BUTTON' ).

   " Set font color to red

   l_style->add_style_property( name  = 'FONTCOLOR'

                                value = 'RED' ).

   " Add custom style

   l_style_manager->add_custom_style( l_style ).

View Entire Topic
harsha_jalakam
Active Contributor
0 Kudos

Hi Maxim,

Did you add style class name in the button properties of the view designer.

Regards,

Harsha

0 Kudos

Hi Harsha,

Yes, I did.

harsha_jalakam
Active Contributor
0 Kudos

Hi Maxim,

it is working pretty fine for me, with the following code,

I did this in doinit of component controller

data l_style_properties type if_wd_custom_style=>t_style_properties.

   l_style_properties = value #( ( name = `fontSize` value = `15px` )

                                 ( name = `fontWeight` value = `bold` )

                                 ( name = `fontColor` value = `rgb(95,95,95)` ) ).

   data(l_custom_style_manager) = wd_this->wd_get_api( )->get_application( )->get_custom_style_manager( ).

   data(l_custom_style) = l_custom_style_manager->create_custom_style( style_class_name = `myText`

                                                                       library_name     = 'STANDARD'

                                                                       element_type     = 'TEXT_VIEW'

                                                                       style_properties = l_style_properties ).

   l_custom_style_manager->add_custom_style( l_custom_style ).

Regards,

Harsha

0 Kudos

Thx, Harsha.

I think provided code will work for majority or people, but not me

I've created new WDP component, copy-paste your code in wdoinit and created textview with 'myText' style.

In debug everything goes fine - objects created, styles added, but nothing happens -

font color still black.

Maybe some note / basis settings.

The strangest thing is WDR_TEST_CUSTOM_STYLES is works while it in his package.

harsha_jalakam
Active Contributor
0 Kudos

can you chck it on chrome or any latest version of IE?

0 Kudos

I have no words

It works!! In Chrome.

Thx a lot.

IE 11.0.9600.17914 - looks like new enough.

Strange that original sap application still works in IE.

Former Member
0 Kudos

you can resolve the IE11 issue but adding WDPREFERREDRENDERING    STAND_ONLY to the parameter list of the web dynpro application.