Skip to main content

WebContent

Purpose

The WebContent ViewTemplate embeds external web content or generated HTML into a View by rendering it inside an IFrame. The content is supplied through an EntityField whose value is typically generated by a valueProcess.

Behavior

The rendering depends on the contentType of the referenced EntityField:

contentTypeBehavior
LINKLoads the provided URL in the IFrame.
HTMLRenders the provided HTML content in the IFrame.

The component is always read-only and enabled. Visibility can still be controlled through the state logic of the underlying Entity.

Configuration

The following ViewTemplate properties control the rendering:

PropertyDescription
entityFieldProvides the content to be rendered.
heightDefines the height of the IFrame.
widthDefines the width of the IFrame.
unitDefines whether the size values use px or %.

Example usage

One example is the ViewTemplate Timeline of FacebookTimeline_view in Context Social. It uses the EntityField FACEBOOK_TIMELINE, whose valueProcess returns the content to be rendered.

This ViewTemplate is exposed in the client through the Dashlet ADITO Facebook Feed in the Dashlet group Social Media.

Implementation hints

The following state handling applies:

StateEffect
READONLYNo effect, because the component is always read-only.
EDITABLENo effect, because editing is not supported.
DISABLEDIgnored, because the component is always enabled.
AUTODefault visible state.
INVISIBLEHides the IFrame.

Common misconfigurations include nested IFrames in HTML mode and normal links that open inside the same IFrame instead of in a new tab. For links embedded in HTML content, use target="_blank" and rel="noopener noreferrer" if the linked page should open externally.

Example implementation

The following example shows a valueProcess that returns HTML content:

import { vars } from "@aditosoftware/jdito-types";
import { result } from "@aditosoftware/jdito-types";

var account = vars.get("$param.Account_param");
result.string(`
<html onmouseover=this.className='scroll' onmouseout=this.className='noscroll' class='noscroll'>
<head>
<style>
.scroll { overflow: auto; }
.noscroll { overflow: hidden; }
</style>
</head>
<body>
<a class="twitter-timeline" href="https://twitter.com/${account}?ref_src=twsrc%5Etfw">
Tweets by ${account}
</a>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</body>
</html>
`);

Notes

WebContent should be configured carefully because display issues are often caused by the content provided by the underlying EntityField, not by the ViewTemplate itself.