Web Content Display Screenlet for iOS

Requirements

  • Xcode 9.3 or above
  • iOS 11 SDK
  • Liferay Portal 6.2 CE/EE, Liferay CE Portal 7.0/7.1, Liferay DXP 7.0+
  • Liferay Screens Compatibility app (CE or EE/DXP). This app is preinstalled in Liferay CE Portal 7.0/7.1 and Liferay DXP 7.0+.

Compatibility

  • iOS 9 and above

Xamarin Requirements

  • Visual Studio 7.2
  • Mono .NET framework 5.4.1.6

Features

The Web Content Display Screenlet shows web content elements in your app, rendering the inner HTML of the web content. The Screenlet also supports i18n, rendering contents differently depending on the device’s current locale.

JSON Services Used

Screenlets in Liferay Screens call JSON web services in the portal. This Screenlet calls the following services and methods.

ServiceMethodNotes
DDMStructureServicegetStructureWithStructureId
JournalArticleServicegetArticleWithGroupId
JournalArticleServicegetArticleContent
ScreensddlrecordService (Screens compatibility plugin)getJournalArticleContentWith entryQuery

Module

  • WebContent

Themes

  • Default

The Default Theme uses a standard UIWebView to render the HTML. Other Themes may use a different component, such as iOS 8’s.

The Web Content Display Screenlet using the Default (default) Theme

Portal Configuration

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, please refer to the Creating Web Content section of the Liferay User Guide.

Offline

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:

PolicyWhat happensWhen to use
remote-onlyThe Screenlet loads the content from the portal. If a connection issue occurs, the Screenlet uses the delegate 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.
cache-onlyThe Screenlet loads the content from the local cache. If the content isn’t there, the Screenlet uses the delegate 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.
remote-firstThe 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 delegate 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.
cache-firstThe 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.

Required Attributes

  • articleId

If you have structured web content, you can alternatively use templateId or structureId with articleId.

Attributes

AttributeData typeExplanation
groupIdnumberThe site (group) identifier where the asset is stored. If this value is 0, the groupId specified in LiferayServerContext is used.
articleIdstringThe identifier of the web content to display. You can find the identifier by clicking Edit on the web content in the portal.
templateIdnumberThe identifier of the template used to render the web content. This is applicable only with structured web content.
structureIdnumberThe identifier of the DDMStructure used to model the web content. This parameter lets the Screenlet retrieve and parse the structure.
autoLoadbooleanWhether the content should be retrieved from the portal as soon as the Screenlet appears. The default value is true.

Methods

MethodReturnExplanation
loadWebContent()booleanStarts the request to load the web content. The HTML is rendered when the response is received. Returns true if the request is sent.

Delegate

The Web Content Display Screenlet delegates some events to an object that conforms to the WebContentDisplayScreenletDelegate protocol. This protocol lets you implement the following methods:

  • - screenlet:onWebContentResponse:: Called when the web content’s HTML is received.

  • - screenlet:onWebContentError:: Called when an error occurs in the process. The NSError object describes the error.

  • - screenlet:onRecordContentResponse:: Called when a web content record is received.

  • - screenlet:onUrlClicked:: Called when a URL is clicked in the web content. Return true to handle the navigation, or false to cancel it.

« Asset List Screenlet for iOSWeb Content List Screenlet for iOS »
この記事は役に立ちましたか?
0人中0人がこの記事が役に立ったと言っています