on 07-15-2010 11:42 AM
Hello.
In an adobe form, I am trying to use html in a richtext field to display formatted text. The form is being generated in ABAP by calling the FM associated with it and the data passed to it is, among others, a character string with valid HTML (like the following:)
<b> text </b>
The problem is that the html arrives at the form escaped ( '<' is substituted by <, '>' by >, etc.) and the result of it is that the text field shows the literal html instead of the text formatted.
Do you know a way to prevent this automatic escaping? Does it have to be unescaped with javascript?
Moreover, I believe the form's richtext field is correctly configured because it works fine in the livecycle preview (field type="Text Field", field format="Rich Text" and data format set to "XHTML").
Thanks a lot in advance.
Best regards,
Tiago Almeida
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello. Thank you for your reply.
However, I don't think this is the same problem.
The texts being passed to the form are generated dinamically in ABAP and they are passed perfectly to the function module generated from the form. Example:
CALL FUNCTION 'FP_JOB_OPEN'
(...)
CALL FUNCTION p_formname
EXPORTING
* /1BCDWB/DOCPARAMS = fp_docparams
rich_text_test = '<b>bold</b>not bold'
IMPORTING
/1bcdwb/formoutput = gs_formoutput
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4.
(...)
but it shows up (in the pdf) literally as
<b>bold</b>not bold
instead of boldnot bold as it should be..
If I print the value of rich_text_test in theform (using javascript) I see '<b>bold</b>not bold' which is html escaped.
My question is how to disable this automatic escaping...
Many thanks.
Tiago Almeida
I use the following in the initialize event of the rich text field:
var b64 = this.rawValue;
if (b64 == undefined) {
this.presence = "hidden";
}
else {
var xhtml = base64.Base64.decode(b64);
this.value.exData.loadXML(xhtml);
}
base64 is a global script variable containing the JavaScript Base64 en/decoder from http://www.webtoolkit.info/javascript-base64.html
Best regards,
Sebastian
Thanks a lot for your answers. Finally found the time needed to test this and got it working (found a workaround for my original problem).
To create the global script object Sebastian refers, go to "Insert script object" in adobe livecyle (right click on the form hierarchy root), rename the new object to "base64" and then paste there, the code Sebastian links (Base64).
Afterwards, edit the initialize event code to decode the base64 encoded string and load it as XML.
e.g.
b64 = this.rawValue;
xhtml = base64.Base64.decode(b64);
this.value.exData.loadXML(xhtml);
and that's it!
I originally had 2 problems: First I was passing the xhtml in plain text so it got escaped (that's why you need to first encode it in base64 and then decode it, in javascript, in the form (thank you Sebastian!)).
Then, the string which gets ultimately passed to the loadXML method, must be a proper XML document (with the body and the namespace etc.) not just an XML fragment like I was testing initially.
e.g (this should work if pasted on the initialize event of the rich text field)
this.value.exData.loadXML('<body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p><b>this should be bold</b>this is not bold</p></body>');
BR,
Tiago
Hi
I needed this for adobe fragments in the output scenario.
Here we are rendering some texts in a text configured as footer for master page (manage my texts app) in footer area of the master page template form.
We added something like this sample code in the initialize event of a rich text field using javascript:
// gather data from context for footer
var lv_data = xfa.resolveNode("$record.FormMaster.Footer.FooterBlock1Text").value;
//this.rawValue = "test"+lv_data;
// render in html into a rich text text field this.value.exData.loadXML('http://www.w3.org/1999/xhtml" xmlns:xfa="'+lv_data+'http://www.xfa.org/schema/xfa-data/1.0/">'+lv_data+'>');
or in one line:
this.value.exData.loadXML('http://www.w3.org/1999/xhtml" xmlns:xfa="'+$record.FormMaster.Footer.FooterBlock1Text.value+'http://www.xfa.org/schema/xfa-data/1.0/">'+$reco...
Our context is from root node navigate to FormMaster then Footer then FooterBlock1Text ($record.FormMaster.Footer.FooterBlock1Text)
Regarding output carry returns are skipped and you will need to add <br/> to each line in the manage text app text
For bold characters as stated by Thomas use <b> text </b>
Please help
I have the same requirement, The data is gathering from web dynpro component in rich text format and I want to display it on my PDF.
But the problem is that, The data which is to be display are coming from table having a line type tdline.So how can I decode such large number of data into base64 format and show it on my PDF....
Please suggest..........Its very important and urgent for us, we not able to handle this issue and now it becomes so critical.
Regards,
Mandar Gavkar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi guys,
i have tried your solution for the same problem but i got a script error as below (just remove the dot)
accessor 'base64.Base64.decode("<.b> BOLD <./b>")' is unknown.
can anyone help me on this?
thanks in advance!
maria
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Maria,
perhaps your routine/variable isn't on the correct place in scripting. Even then it wouldn't work, because the string is not in base64-Format.
By trying the solution of the collegues above I found out, that it is not necessary to encode ABAP-xhtml in base64 and to decode it in the form (I had some problems with base64 in special texts, so I want to leave out this en-/decoding).
Tiago gives the short way too: Just embrace your ABAP-xhtml-string with the body-Tags Tiago mentioned. That works very well.
So I wrote the small scripts (thanks to Sebastian because of the check to "undefned") to the Rich Text fields in my form:
---
this.value.exData.loadXML(textconv.TC.makexml(this.rawValue));
---
I put the called routine/variable textconv.TC.makexml() in the hierarchie as variable (use popup menu "Insert ScriptObject" to insert the variable named textconv) with the following code:
---
var TC =
return xmlstr;
}
}
---
With this scripts, the allowed XHTML-Tags in the ABAP-string are interpreted in the correct way.
Regards
Raphael
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.