Tuesday, April 12, 2016

Showing alert message to users

WebCenter Sites provides various customization hooks for customizing Contributor UI as mentioned in Developer's guide. But there is no illustration provided on showing custom message(s) to Contributor UI users either via simple alert or floating modal window.

When can custom messages be helpful? 
Few use cases of showing custom message(s) which can be:
1. Showing welcome message
2. Showing message for changing password every 3 months
3. Showing message for upcoming event or scheduled maintenance period

As WebCenter Sites provides customizing Contributor UI via SiteConfigHtml element, it is very easy to create alert messages.

Simple welcome message can developed by creating CustomElements/UI/Config/SiteConfigHtml element using either Admin UI or Sites Explorer. Add the following code within SiteConfingHtml.jsp as shown below:

Now whenever any user logins to WebCenter Sites Contribution UI, welcome message is visible as shown below for fwadmin.
Welcome message!!


























Above example is very simple one. In order to show message like scheduled maintenance, password change alert, deadline of a task to particular user or other important messages; one can simply make Ajax call to certain WebCenter Sites element and show corresponding results from the element in the alert message.

For e.g. Consider showing same welcome message via an element rather than defining within SiteConfigHtml.jsp.

1. Create a CSElement and add the code: Welcome <ics:getssvar name="username"/>! between opening and closing tag of <cs:ftcs>
2. Create a SiteEntry and associate the above CSElement (Wrapper=NO; pagelet=NO; uncached)
3. Make Ajax call from SiteConfigHtml.jsp to call the above SiteEntry and show the message only after Contributor UI is loaded. Add the following code within SiteConfigHtml.jsp:

Output should be same. Thus, it is very easy to create alert messages within Contributor UI which can be very useful sometimes when combined with other functionalities like system events, publishing, asset operations, etc.

Disclaimer: The code and/or the configurations posted are not official recommendations and should be used at sole's discretion with proper testing before deploying on live WebCenter Sites systems. Cheers!!

No comments:

Post a Comment

A simple code compare functionality

One of the most important aspect of any development cycle is deployment and while deployment, it is very important to note the changes don...