Show TOC Start of Content Area

Procedure documentation Creating Formatted Text  Locate the document in its SAP Library structure

To display text in a FormattedTextView or a FormattedTextEdit, you have to provide the content that you want to display as type FormattedText. For the FormattedTextView, you can set the content to be displayed by choosing This graphic is explained in the accompanying text. For a string to be converted into FormattedText, it must contain a well-formed and valid XML document.

To create this type, use the IWDFormattedTextFactory.

The IWDFormattedTextFactory provides two methods to create a FormattedText from a string:

      IWDFormattedText valueOf(String text)

Use this method to create FormattedText from a markup language-formatted string.

      IWDFormattedText fromPlainText(String text)

Use this method to create FormattedText from plain text. The following escape sequences will be ignored.

\b

backspace

\n

newline

\f

formfeed

\r

carriage return

\t

horizontal tabulator

Procedure

...

       1.      In your Web Dynpro DC, navigate to the corresponding view and insert a FormattedTextView or a FormattedTextEdit.

       2.      Select the Context tab and create an attribute called FormattedTextAttr.of type FormattedText.

       3.      Bind the relevant property to this context attribute:

       For FormattedTextView, bind property text

       For FormattedTextEdit, bind property value

       4.      Insert the following source code into the wdDoInit method of your view controller:

wdDoInit()

IWDFormattedTextFactory instance = (IWDFormattedTextFactory) WDHelperFactory.getInstance(IWDFormattedTextFactory.class);

String value = "text to be displayed";

IWDFormattedText formtext = instance.fromPlainText(value); wdContext.currentContextElement().setFormattedTextAttr(formtext);

Result

The following screenshot illustrates the result:

This graphic is explained in the accompanying text

See also:

Binding Data to Predefined Dictionary Simple Types

 

End of Content Area