Requirements
- Android SDK 4.1 (API Level 16) or above
- 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
- Android SDK 4.1 (API Level 16) or above
Xamarin Requirements
- Visual Studio 7.2
- Mono .NET framework 5.4.1.6
Features
Web Screenlet lets you display any web page. It also lets you customize the web page through injection of local and remote JavaScript and CSS files. If you’re using Liferay DXP as backend, you can use Application Display Templates in your page to customize its content from the server side.
Module
- None
Views
- Default
Configuration
To learn how to use Web Screenlet, follow the steps in the tutorial Rendering Web Pages in Your Android App. That tutorial gives detailed instructions for using the configuration items described here.
Web Screenlet has WebScreenletConfiguration
and
WebScreenletConfiguration.Builder
classes that you can use together to supply
the parameters that the Screenlet needs to work.
WebScreenletConfiguration.Builder
has the following methods, which let you
supply the described configuration parameters:
Method | Return | Explanation |
---|---|---|
addLocalJs(fileName) | WebScreenletConfiguration.Builder | Adds a local JavaScript file with the supplied filename. The JavaScript files must be in the first level of your app’s assets folder. Create this folder at the same level of the res folder. |
addLocalCss(fileName) | WebScreenletConfiguration.Builder | Adds a local CSS file with the supplied filename. The CSS files must be in the first level of your app’s assets folder. Create this folder at the same level of the res folder. |
addRawJs(rawJs, name) | WebScreenletConfiguration.Builder | Adds a JavaScript file from your app’s res/raw folder. Create this folder if it doesn’t exist. Reference the file using R.raw.yourfilename . This method also takes a second parameter called name , which is only for debugging purposes. If there’s an error, the console displays it with this name value. |
addRawCss(rawCss, name) | WebScreenletConfiguration.Builder | Adds a CSS file from your app’s res/raw folder. Create this folder if it doesn’t exist. Reference the file using R.raw.yourfilename . This method also takes a second parameter called name , which is only for debugging purposes. If there’s an error, the console displays it with this name value. |
addRemoteJs(url) | WebScreenletConfiguration.Builder | Adds a JavaScript file from the supplied URL. |
addRemoteCss(url) | WebScreenletConfiguration.Builder | Adds a CSS file from the supplied URL. |
setWebType(webType) | WebScreenletConfiguration.Builder | Sets the WebType . |
enableCordova(observer) | WebScreenletConfiguration.Builder | Enables Cordova inside the Web Screenlet. |
load() | WebScreenletConfiguration | Returns the WebScreenletConfiguration object that you can set to the Screenlet instance. |
WebType
-
WebType.LIFERAY_AUTHENTICATED (default): Displays a Liferay DXP page that requires authentication. The user must therefore be logged in with Screens via Login Screenlet or a
SessionContext
method. For thisWebType
, the URL you must pass to theWebScreenletConfiguration.Builder
constructor is a relative URL. For example, if the full URL ishttp://screens.liferay.org.es/web/guest/blog
, then the URL you must supply to the constructor is/web/guest/blog
. -
WebType.OTHER: Displays any other page. For this
WebType
, the URL you must pass to theWebScreenletConfiguration.Builder
constructor is a full URL. For example, if the full URL ishttp://screens.liferay.org.es/web/guest/blog
, then you must supply that URL to the constructor.
Attributes
Attribute | Data type | Explanation |
---|---|---|
autoLoad | boolean | Whether to load the page automatically when the Screenlet appears in the app’s UI. The default value is true . |
layoutId | @layout | The layout to use to show the View. |
isLoggingEnabled | boolean | Whether logging is enabled. |
isScrollEnabled | boolean | Whether to enable scrolling on the page inside the Screenlet. |
Methods
Method | Return | Explanation |
---|---|---|
load() | void | Checks if the page’s URL is valid, and then loads it. The operation fails if the URL is invalid. |
clearCache() | void | Clears the Web Screenlet’s cache. |
injectScript(script) | void | Injects a script when the page is already loaded. |
Listener
Web Screenlet delegates some events to an object or class that
implements its
WebListener
interface.
This interface extends the
BaseCacheListener
interface.
Therefore, Web Screenlet’s listener methods are as follows:
-
onPageLoaded(String url)
: Called when the Screenlet loads the page correctly. -
onScriptMessageHandler(String namespace, String body)
: Called when theWebView
in the Screenlet sends a message. Thenamespace
parameter is the source namespace key, andbody
is the source namespace body. -
error(Exception e, String userAction)
: Called when an error occurs in the process. TheuserAction
argument distinguishes the specific action in which the error occurred.