cancel
Showing results for 
Search instead for 
Did you mean: 

Make a string as bold

Former Member
0 Kudos

Hi Expert,

I have a scenario like I need to show the paragraph in one text view , so I created one attribute.And

I wrote the following code in init method ,

data lv_string type string.

lv_string =

I hearby acknowledge and confirm that I have read ,reviewed and understood the policy on personel securities investment ( the ' Policy' ) of Mapletree group of companies ( the 'company' ).

'

lo_nd->set_attribute( exporting name = 'PARAGRAPH' value = lv_string ).

so it will display like following.

I hearby acknowledge and confirm that I have read ,reviewed and understood the policy on personel securities investment ( the ' Policy' ) of Mapletree group of companies ( the 'company' ).

but in which I want to make the text ' Policy' and 'Company' only bold, like following,

I hearby acknowledge and confirm that I have read ,reviewed and understood the policy on personel securities investment ( the ' Policy' ) of Mapletree group of companies ( the 'company' ).

So , What I have to do in coding for this ...

Regards,

Sankar.M

Edited by: ManoSankar on Jan 3, 2011 8:49 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mano

a bit change in arun idea use Format text view not FT edit

I have tested your requirement & able to achive it

1. create a Formatted text view UI in your View

2. create a attribute with type string and bind to the text property of the Formatted text view UI

3. write the code to set the text attribute with formatting

reffer the sample code below

METHOD wddoinit .
  DATA lv_string TYPE string.
  DATA formatted_text TYPE string.
  DATA formatted_text_obj TYPE REF TO cl_wd_formatted_text.
  DATA ex                 TYPE REF TO cx_wd_general.
  DATA element            TYPE REF TO if_wd_context_element.
  DATA current_controller TYPE REF TO if_wd_controller.
  DATA message_manager    TYPE REF TO if_wd_message_manager.
 

  DATA lo_el_context TYPE REF TO if_wd_context_element.
  DATA ls_context TYPE wd_this->element_context.
  DATA lv_fromat_text TYPE wd_this->element_context-fromat_text.
  lo_el_context = wd_context->get_element( ).

" use tag <strong> to make the words bold .
  lv_string = 'I hearby acknowledge and confirm that I have read ,reviewed and understood the policy on personel securities investment  the  <strong> (Policy)</strong> of Mapletree group of companies <strong> ( the company )</strong>'.

  formatted_text_obj = cl_wd_formatted_text=>create( xml_text =  lv_string  ).
  lo_el_context->set_attribute( name =  `FROMAT_TEXT` value = lv_string ).
  TRY.
      formatted_text_obj->validate( ).
    CATCH cx_wd_general INTO ex.
*      " Error in formatted text
      current_controller ?= wd_this->wd_get_api( ).
      message_manager = current_controller->get_message_manager( ).
      element = wd_context->get_lead_selection( ).
      message_manager->report_attribute_exception(
          message_object = ex
          element        = element
          attribute_name = `FROMAT_TEXT`
      ).
  ENDTRY.
ENDMETHOD.

check out the result here [http://i55.tinypic.com/qrd8ya.jpg|http://i55.tinypic.com/qrd8ya.jpg]

Regards

Chinnaiya P

Edited by: chinnaiya pandiyan on Jan 3, 2011 4:10 PM

Former Member
0 Kudos

Hi Chinnaiya,

Its very useful for me and its solved my issues also..

thanks a lot for the quick reply .

Thanks & Regards,

Sankar.M

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

Formatted_text_edit is suitable for you.

Former Member
0 Kudos

Hi ManoSankar ,

If you need to make entire text vieew bold you can do it by the properties.

But in case of a part of the text :- Please have a look in the below forum discussions.

[;

[;.

Thanks & Regards,

Monishankar C

former_member206441
Contributor
0 Kudos

Hi

Check this Web Dynpro sample application demo_uiel_formatted_text_edit.

Go thru this [link|http://help.sap.com/saphelp_nw70ehp1/helpdata/en/44/2772f505605447e10000000a422035/frameset.htm] it might be helpful for you.

Regards

Arun.P

gill367
Active Contributor
0 Kudos

I dont think taht it is possible inside a text edit.

If this is the specific requirement use text views instead of text edit. and use different text views for policy and company part

in the string.

Thanks

Sarbjeet Singh