cancel
Showing results for 
Search instead for 
Did you mean: 

display already formatted text

Former Member
0 Kudos

Hi Guys,

I call a Bapi in R3 system which sends me already formatted text.

Is it possible to display this text and keep its formatting as it is possible with <PRE>... </PRE> tags in html ?

Thanks,

Marc

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Dear VS

Pls guide me how to take print in webdynpro

Send me the code one by one i.e From the scratch.

B'cos i am new to webDynpro.

Regrads

Dhinakar

Former Member
0 Kudos

Hi Marc,

Excepts numerous options proposed let me suggest another one. It sounds wired, but it works:

1. Place IFrame UI control on WD View (we will use it to display formatted text).

2. Create in context attribute <b>AttrContent</b> of type <b>binary</b>

3. Setup binary attribute in view controller wdDoInit:

final ISimpleTypeModifiable mtype = attr.getModifiableSimpleType();
final IWDModifiableBinaryType btype = (IWDModifiableBinaryType)mtype;
btype.setFileName( attr.getName() + ".html" );
btype.setMimeType( WDWebResourceType.HTML );

5. Save reference to <i>mtype</i> in private controller variable, say <i>_contentType</i>;

6. Create <b>string</b> attribute AttrUrl in context, and bind IFrame <b>source</b> property to it.

7. Whenever you need to update content use the following:


final String formattedStr = ...; /* Get it from backend */
wdContext.currentContextElement().setAttrUrl
(
  _contentType.format
  ( 
    (
      "<html><head /><body><pre><code>" +
      formattedStr + 
      "</code></pre></body></html>"
    ).getBytes("UTF-8") 
  )
);

Done.

VS

Former Member
0 Kudos

I just came across this post, and have a few questions about your example

1. where is step 4?

2. why do you create AttrContent, but not use it?

3. where did attr come from?

4. I don't understand what step 5 refers to.

Former Member
0 Kudos

Hi,

1.

2. sorry, the firsl line in code should be:

final IWDAttributeInfo attr = wdContext.getNodeInfo().getAttribute("AttrContent");

3. see above

4. what exactly? Declare non-static field in view controller and set it to variable mentioned (for future use).

VS

Message was edited by: Valery Silaev

Former Member
0 Kudos

Hi Valery,

I tried your suggestion !It works but i have a small problem ! its asking to open or save the file .. and not displaying it in the IFrame .

What is problem :)?what should i do to put it in the IFrame itself !

And by using the simple modifiable type and setting it to string does it mean that the string attrurl will have all the filename and mimetype details also stored ! ??

The trick seems to be the smtype.format ! Obviously .tostring of the acquired bytes wont work!

Why !

(Even if u answer i cant award points ! :(... sorry ! )

Regards

Bharathwaj

Former Member
0 Kudos

Bharathwaj,

The trick here is ISimpleType.format(), of course. It place binary content into binary cache on server and returns formatted url. Using this url it is possible to load content. When placing content corresponding file name and MIME are stored as well. Afterwards WebAS should response with correct Content-type and Content-disposition headers. For HMTL type it should be not attachment, but rather inline. In you case it seems to be treated as attachment. Probably not specifying file name will work?

VS

Former Member
0 Kudos

Hi,

No luck valery ! Same output !

What decides if the content is a attachment or inline !??

Regards

Bharathwaj

Former Member
0 Kudos

Actually, this part of code:


btype.setFileName( attr.getName() + ".html" );
btype.setMimeType( WDWebResourceType.HTML );

WDWebResourceType class constructor defines parameter isAttachment, for WDWebResourceType.HTML it is false (and this what exactly necessary).

I do not know what is wrong

VS

Former Member
0 Kudos

Nevermind

Former Member
0 Kudos

Hi Valery,

I did get the code to work (needed a try catch statement).

But I'm having the same issue that Bharathwaj is having, where it asks to open or save the file.

We noticed that btype is set, but it is never associated with mtype or anything else, so how does the server know that it is to use mtype with btype?

I'd love to get this to work if you have any more suggestions!

Thanks,

Jonathan

Former Member
0 Kudos

Gentelmen,

I do not know what is a problem, but I've just re-created application and everything works as expected. But it was created using SP11 but deployed on NW4s

Please send me your address to vsilaev AT gmail DOT com and I send you NW project to test.

VS

Former Member
0 Kudos

Gentelmen,

What java type for declare variable _contentType ?

Thaks for ur kind

Former Member
0 Kudos

Hi Valery,

Our portal verison is EP 7 01 SP5. I have created some webdynpro forms and Iviews for them on the portal. I want to Print these forms from the portal.

I came across this thread where you have provided information regarding a solution to the print problem.

Can you let me know the complete Code that is required for this Print to work fine.

Thanks,

Sujata

Former Member
0 Kudos

Hi

I have some options for you...

option 1 - If the long formatted text in sap table is in single column with multiple rows in terms of having each line as one record and when displayed looks like a paragraph statement. So use your RFC call from SAP and make a binding with a webdynpro table to populate the rows and make invisible the row/column lines. So When you run it on the browser it will display like a long text. By default, SAP table will have column some length of 72 characters, which you change to 140 charcs( through another rfc which takes care of the carriage returns,formatting..etc), to get a long sentence formation.

option 2 - If the long text is not from SAP table and its kind of direct information, then just keep on pasting the text in the text view by providing spaces appropriately, so that the display will be a continous form of paragraph. This is a trial and error way and providing the spaces between the lines.

option 3 - Store the long text in a text file and call a import parameter, which will read the whole text and store it in string (node) and display it text view. ( alignment cannot be gauranteed - not a good option)

option 4 - Last one, is to call a office (msword) or a pdf control , which will display the long text through the word editor or a pdf form

since your text is already formatted, try with a table having multiple rows, (each containing one line).

However, the normal formatted way of having Bold,italics, different font faces, underlines cannot be done with the current versions. You can have line breaks only.

Hope this gives you a brief idea on how to go about on it.

Former Member
0 Kudos

Hi Marc

Try rendering this through a jsp and display it in a Web Dynpro IFRAME

Regards

Pran