- Android SDK 4.0 (API Level 15) or above
- Liferay Portal 6.2 (CE or EE), Liferay 7.0 CE, Liferay DXP
- Liferay Screens Compatibility plugin (for Liferay Portal CE or Liferay Portal EE).
- Android SDK 4.0 (API Level 15) and above
- Visual Studio 7.2
- Mono .NET framework 22.214.171.124
The Web Content Display Screenlet shows web content elements in your app, rendering the web content’s inner HTML. The Screenlet also supports i18n, rendering contents differently depending on the device’s locale.
Screenlets in Liferay Screens call JSON web services in the portal. This Screenlet calls the following services and methods.
The Default View uses a standard
WebView to render the HTML.
For the Web Content Display Screenlet to function properly, there should be web content in the Liferay instance your app connects to. For more details on web content, see the Web Content Management section of the Liferay User Guide.
This Screenlet supports offline mode so it can function without a network connection. For more information on how offline mode works, see the tutorial on its architecture. Here are the offline mode policies that you can use with this Screenlet:
|Policy||What happens||When to use|
|The Screenlet loads the content from the portal. If a connection issue occurs, the Screenlet uses the listener to notify the developer about the error. If the Screenlet successfully loads the content, it stores the data in the local cache for later use.||Use this policy when you always need to show updated content, and show nothing when there’s no connection.|
|The Screenlet loads the content from the local cache. If the content isn’t there, the Screenlet uses the listener to notify the developer about the error.||Use this policy when you always need to show local content, without retrieving remote content under any circumstance.|
|The Screenlet loads the content from the portal. If this succeeds, the Screenlet shows the content to the user and stores it in the local cache for later use. If a connection issue occurs, the Screenlet retrieves the content from the local cache. If the content doesn’t exist there, the Screenlet uses the listener to notify the developer about the error.||Use this policy to show the most recent version of the content when connected, but show a possibly outdated version when there’s no connection.|
|The Screenlet loads the content from the local cache. If the content isn’t there, the Screenlet requests it from the portal and notifies the developer about any errors that occur (including connectivity errors).||Use this policy to save bandwidth and loading time in case you have local (but probably outdated) content.|
Note that if your web content uses
structures and templates,
you can use
structureId in conjunction with
|The layout used to show the View.|
|The site (group) identifier where the asset is stored. If this value is |
|The identifier of the web content to display. You can find the identifier by clicking Edit on the web content in the portal.|
|The corresponding asset’s class primary key. If the web content is an asset (from Asset List Screenlet, for example), this is the asset’s identifier. This attribute is used only if |
|The identifier of the template used to render the web content. This only applies to structured web content.|
|The identifier of the |
|A comma-delimited list of |
|Whether the content should be retrieved from the portal as soon as the screenlet appears. Default value is |
|The offline mode setting. See the Offline section for details.|
|Starts the request to load the web content. The HTML is rendered when the response is received.|
|Returns the value, according to the device locale, of a field of the |
The Web Content Display Screenlet delegates some events to an object that
WebContentDisplayListener interface. This interface lets you
implement the following methods:
onWebContentReceived(WebContent webContent): Called when the web content’s HTML or
DDMStructureis received. The HTML is available by calling the
getHtmlmethod. To make some adaptations, the listener may return a modified version of the HTML. The original HTML is rendered if the listener returns
onUrlClicked(String url): Called when a URL is clicked. Return
trueto replace the default behavior, or
falseto load the url.
onWebContentTouched(View view, MotionEvent event): Called when something is touched in the web content. Return
trueto replace the default behavior, or
falseto keep processing the event.
error(Exception e, String userAction): Called when an error occurs in the process. The
userActionargument distinguishes the specific action in which the error occurred.