Monday, February 22, 2016

Introduction to OWCS 12c

Overview
This document is created to provide an idea on the news features of Oracle WebCenter Sites 12c. This new version of WCS introduces various marketing tools which can be used by marketers to generate web pages personalized based on the characteristics (interests, social category, context, etc.) of an individual or group of users, therefore providing them with a tailored user experience.

DEVELOPER’S PERSPECTIVE
    • Oracle has introduced new MVC pattern of coding in 12c which follows the following flow:
Controller Flow.pg.png
    • General idea is to write all the business logic in controller (WCS_Controller asset type) which serves as CONTROLLER, Templates or SiteEntry+CSElement can include controllers and should contain only basic HTML code and output from controller using <fragment> tags and thus, serve as VIEW. Output from controllers i.e. asset data are saved in MAP objects which serve as MODEL. Hence, the MVC pattern.
    • REST api was already present in older version of Oracle WebCenter Sites to access data but 12c provides simpler ways to access data in different ways. Check out this section for more details.
    • Improvements in eclipse-csdt plugin and csdt command line feature.

CLIENT’S PERSPECTIVE
    • Visitor services is a separate module which can be installed and configured with WCS 12c to capture visitor’s activity data from various multiple platforms like google, fb, twitter, etc. and saves as a unified profile within webcenter sites so that marketers can segmentize visitors on basis of these unified profiles/data and thus, target users with desired content. Details related to configuration are present here. This is very advanced topic in terms of capturing visitors data and providing personalized data. Engage is already a part of WCS 12c OOTB and can be used in tandem with Visitors services and Insights (described later) components to target end-users efficiently.
    • This component is kind of reporting tool to check specific visitor action that one can identify for tracking for e.g. number of clicks on certain asset or promotion, specific link, amount of time a visitor watches video, stays on a webpage or an ad.
    • Conversion assets can be created by marketers and works in tandem with Insights component and A/B testing to generate conversion reports.
    • The Insights component delivers a comprehensive real-time view of your website's ROI.
    • This component is again a marketing tools for marketers to drill down marketing initiatives from webpage to single asset.
    • It also provides information on the contributors which worked for contributing content within WCS during a period by generating reports.
    • Marketers can analyse website traffic and user behaviour to segmentize them at very specific content level and target them using either both Engage and Visitors Service component or just with Engage only.
    • This marketing functionality within WCS contributor interface works in tandem with Conversions and Insights components; to test a piece or group of content against each other to determine which can be best for visitors targeting and/or serving best content by testin g performance among variations of content before delivering the content to end-users. This is more of hit-and-trial kind of creating variation of content (assets), capturing data and analysing for targeting users. For A/B testing, insights component should be enabled.
  • Rest of the features are few improvements, functionality and accessibility in the WCS product itself.

Need help? Click here.

Implementing pagination on search in 12c

Pagination on search pages is quite a common requirement and with introduction of WebCenter Sites 12c, it has become even more easier to do so. If you are looking for implementing pagination on search results for 11g, you can check my old post here.

With introduction of new server-side api, its very easy to perform CRUD operation on assets. For searching assets, Searcher helper class provides methods to include various options which is very easier to implement.
Note: For using Searcher, global indexes for the assettype should be enabled.

Following is simple illustration of searching product assets of particular locale (en_US) in FirstSiteII, it can also search on product name, order by date and shows 10 results per page.

Click here to download this sample groovy class.

Need help? Click here.

Sunday, January 3, 2016

Using controllers for development

Welcome to Oracle WebCenter Sites 12c development! After the introduction of MVC framework in Oracle WebCenter Sites, it is now very very easy to perform CRUD operations on assets as OOTB Controller assets are sufficient to carry out nearly 99% of your WCS development. Developers now need to learn little bit of groovy but its okay even if you know JAVA and jstl programming. But still in current release of 12c, legacy tags and asset api can also be used.

If you browse through Samples site, all new concepts are described aptly in the site's sections itself so its redundant to write the same thing in this post. I just wanted to list down few simple cases which are not present or not explained in detail in Samples or Avisports site.

1. Debugging using watchers:

Debugging is little bit difficult when it comes to WebCenter Sites; if not aware of various core functions which are used in background. And seems like that hasn't changed much as it is same case while using controllers. Whenever there is error thrown from controller, you get detailed error log in sites.log but sometimes it may be difficult to decipher the root cause. Thus, the role of watchers is very useful not only during debugging but also gives detail on output of your data in the model object. For every function, you can just add your own watchers and print them in your JSP code.

Syntax to define in controller: watch("__my_watch__")
Syntax to print output in JSP: $("__my_watch__")

Watchers are very useful when you just want to check output from your controller's method. For e.g. Create one controller and add any method which is defined in Samples site and then create one template (applies to various asset type, can be called from browser, uncached) and assign your controller. In template code, just add the following line of code within <cs:ftcs> opening and closing tag, which is basically default watcher: ${__$WATCH$__}
Now, call your template directly from browser using following url: <hostname>:<port>/sites/Satellite?pagename=<sitename where template was created>/<template name>&c=Page&cid=<Some random id> --> which should print the output of your controller's method. Note: Output will be from the asset of what c and cid is used in controller.

2. Accessing attribute values:

To fetch attributes of data type: string, text, number, float, date, int, money ; use the following syntax in JSP template or CSElement:
${asset.YOUR_ATTRIBUTE_NAME} or ${asset["YOUR_ATTRIBUTE_NAME"]}  
where asset is the model object containing the map values which was defined in controller.

To fetch asset of type blob, use the following syntax:  
${asset._bloblink_} or ${asset.YOURATTRIBUTENAME_bloblink_}

To fetch hyperlink for an asset: ${asset._link_}

To fetch attribute of type - asset: ${asset.YOURATTRIBUTENAME} but it will just provide your associated asset id. So to get detail/summary/link template fragment of this associated asset, fetch id in your controller using following syntax: models.asset.YOURATTRIBUTENAME whose output is basically an arraylist. Loop through list and get each id values. Create one empty List<Fragment> and add as TemplateFragment or SiteEntryFragment or ElementFragment to it to be used in Template or CSElement code. For eg: Suppose product assets are associated to one attribute: RelatedProducts and you want to show them using Summary template, then your code will be as followed:

 
and jsp code as followed (don't forget to include jstl core library at top of your element):

<c:if test="${not empty relatedProducts}">
   <c:forEach begin="0" end="${relatedProducts.size()-1}" var="product">
      <fragment:include name="relatedProducts" index="${product}"/>
   </c:forEach>
</c:if>

3. Formatting date is now very simple using jstl fmt:formatDate tag. Just pass ${asset.DATE_ATTRIBUTE_NAME} and desired format to get the formatted date.

4. Apart from watchers, you can directly log the desired output using already defined logger for controller:  
log.info("AssetMap: " + assetMap) OR log.info(JsonOutput.prettyPrint(JsonOutput.toJson(assetMap)))

5. Although methods related to search are explained but fails to provide info on how to sort and search against locale/dimension content. Following code searches against Page of only particular locale - en_US, sorts by updateddate descending and sets only the latest updated page into model object.

That's all for now, will share as I explore more.

Need help? Click here.