I am getting a servlet response as an HTML page and I want to display as an html page. How can I make this happen ?
I tried using html component but not all element display correctly. I tried using a text component and mark as contains html and it doesn't even display the text as html. It just displays the text pasted below.
The sample servlet response is here:
http://www.heypasteit.com/clip/2RB1
Any help would be greatly appreciated
display Servlet response as html page in forms
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 29
- Joined: Mon Nov 02, 2015 7:19 pm
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
- dvanhussel
- Ebase User
- Posts: 161
- Joined: Fri Oct 19, 2007 12:45 pm
- Location: Haarlem, the Netherlands
In a project where 'no iframes' was a requirement, we have used the '<object>' HTML tag for this.
http://www.w3schools.com/tags/tag_object.asp
http://www.w3schools.com/tags/tag_object.asp
0 x
-
- Ebase User
- Posts: 29
- Joined: Mon Nov 02, 2015 7:19 pm
Thanks Jon. I used displayUrl instead and it works for my purpose. It happens so that the html displays correctly in IE11 but doesn't render as html in chrome, it just display as text in chrome. Would you know where to look, the sample of html code is here http://www.heypasteit.com/clip/2RB1
0 x
-
- Ebase User
- Posts: 29
- Joined: Mon Nov 02, 2015 7:19 pm
I dig further and found out that by manually changing the javascript inside the returned servlet response and manually pasting it into textbox and highlighting contains html renders correctly. But when I tried to automate the process using replace string. It stopped working.
Manually edited script is here
http://www.heypasteit.com/clip/2RG0
Original script
http://www.heypasteit.com/clip/2RB1
Did this to automate the process
text field has test1 variable.
I get following error when I try to automate the process.
In javascript I would get error as "ufsmain:459 Uncaught ReferenceError: writeLabel is not defined"
In manual text entry I don't get such error. writeLabel is defined function in script tag in the html response from servlet.
Manually edited script is here
http://www.heypasteit.com/clip/2RG0
Original script
http://www.heypasteit.com/clip/2RB1
Did this to automate the process
Code: Select all
fields.test1.value = getResponseText(input1);
fields.test1.value= fields.test1.value.replace('Labels = document.all("domLabels").XMLDocument;', 'Labels = document.getElementById("domLabels");');
fields.test1.value = fields.test1.value.replace('if (Labels.parseError.errorCode != 0)',"");
fields.test1.value = fields.test1.value.replace("alert('Please contact your System Administrator","");
fields.test1.value = fields.test1.value.replace("' + Labels.parseError.reason);","");
fields.test1.value = fields.test1.value.replace("labelsError = true;","");
fields.test1.value = fields.test1.value.replace('Label = Labels.getElementsByTagName(label).item(0);', 'Label = document.getElementsByTagName(label).item(0);');
I get following error when I try to automate the process.
In javascript I would get error as "ufsmain:459 Uncaught ReferenceError: writeLabel is not defined"
In manual text entry I don't get such error. writeLabel is defined function in script tag in the html response from servlet.
0 x
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
It's always going to be difficult to include a complete HTML page inside an Ebase page as part of an HTML control or as a text containing HTML (these two are really the same thing). The reason is that the Ebase page contains a structure:
<html>
<head>
JS and style sheets loaded here
</head>
<body>
controls go here
</body>
</html>
If you add an external page as part of a control, you end up with that page's <html>, <head>, <body> sections embedded inside the Ebase page's <body> tag, and this is invalid HTML. You are then relying on the tolerance of different browsers to get it working and there are no guarantees. So this approach is always flawed. It's better and more reliable to embed an external page in an <iframe> or <object> tag using an Ebase HTML control. This way you will have syntactically correct HTML and it's much easier to get it working.
<html>
<head>
JS and style sheets loaded here
</head>
<body>
controls go here
</body>
</html>
If you add an external page as part of a control, you end up with that page's <html>, <head>, <body> sections embedded inside the Ebase page's <body> tag, and this is invalid HTML. You are then relying on the tolerance of different browsers to get it working and there are no guarantees. So this approach is always flawed. It's better and more reliable to embed an external page in an <iframe> or <object> tag using an Ebase HTML control. This way you will have syntactically correct HTML and it's much easier to get it working.
0 x
Who is online
Users browsing this forum: No registered users and 6 guests