Saturday, November 8, 2014

Carousel in ADF using Slick plugin

ADF Faces ships in with its own carousel component which is pretty much easy to use but it has limited options in terms of UI, not responsive and not very slick ;-) 

Slick  is a light weight  jquery plugin, which is used to build, glossy, responsive carousels with lot of cool options but it requires a requires a specific HTML  to    function -

<div class="your-class">
        <div>your content</div>
        <div>your content</div>
        <div>your content</div
</div>
 
Before we go on, Have a look at the awesome Slick plugin and its options for carousels.

Since it is highly recommended not to use HTML in ADF pages, the solution is to choose ADF components which generates the desired HTML for Slick.js to work on, Here we go with a working sample -

Page structure using ADF faces component which generates HTML Structure required for Slick plugin -
 
  <af:panelGroupLayout  layout="vertical">
       <af:iterator >
           <!-- content -->
        </af:iterator>
   </af:panelGroupLayout>


The complete page with carousel would look like -  







As i said there are lot of other cool carousel types available 
in Slick plugin to try out and it's very easy to use.
 
Hope this helps:-)

Saturday, April 12, 2014

PreferenceBean in Webcenter - Store Custom Constants

Tip - There are multiple ways to store constants outside the context of application such as properties file, Database ,LDAP or MDS etc. There is one more simple way in webcenter where we could have it stored which is  preferences in adf-config.xml.

 <portal:adf-portal-config>
    <portal:preferences>
      <portal:preference id="oracle.webcenter.portalapp.navigation.model"
                         desc="Default Navigation Model"
                         value="/oracle/webcenter/portalapp/navigations/default-navigation-model.xml"
                         resourceType="navigation" display="true"/>
      <portal:preference id="oracle.webcenter.portalapp.resourcecatalog"
                         desc="Default Resource Catalog"
                         value="/oracle/webcenter/portalapp/catalogs/default-catalog.xml"
                         resourceType="ResourceCatalog" display="true"/>
      <portal:preference id="oracle.webcenter.portalapp.pagetemplate.pageTemplate"
                         desc="Default Page Template"

                         value="/oracle/webcenter/portalapp/
                         ...........
                         ...........

These preferences are used by in webcenter to store the default navigations,resource catalog etc which can be accessed anywhere in the portal using preference bean 

Eg : Default Skin - #{preferenceBean.defaultPortalSkin}
         Default Template -  #{preferenceBean.defaultPageTemplate}

These preferences can also be used to store custom constants that can be used anywhere in the application and again as we store this in adf-config.xml which is editable through MDS, all these constants can be changed at runtime as needed:-)

Eg : Sample preferences in Adf-Config.xml








ELs to access this preference -
   
#{preferenceBean.portalAdfConfigMap.configMap['sampleConstant'].id}
#{preferenceBean.portalAdfConfigMap.configMap['sampleConstant'].desc}
#{preferenceBean.portalAdfConfigMap.configMap['sampleConstant'].value}
#{preferenceBean.portalAdfConfigMap.configMap['sampleConstant'].resourceType}
                        













Hope this helps :-)

Sunday, March 30, 2014

OPSS APIs to access Policy Store

Scenario - Though EM console of weblogic server provides a sophisticated UI to access policy store and perform actions, there was once a scenario where we had to find a way to provide a set of permissions to a specific role through code.

Solution - Weblogic provides OPSS APIs to access the policy store and i feel its not well documented, So here we go with a util to get your Application's Policy -

package com.webcentersamples.sampleapp.samples.utils;

import oracle.security.jps.JpsContext;
import oracle.security.jps.JpsContextFactory;
import oracle.security.jps.JpsException;
import oracle.security.jps.internal.api.runtime.ServerContextFactory;
import oracle.security.jps.service.policystore.ApplicationPolicy;
import oracle.security.jps.service.policystore.PolicyStore;

public class PolicyStoreUtils {
    private static PolicyStoreUtils policyStoreUtils;
    private static PolicyStore policyStore;
    private static ApplicationPolicy applicationPolicy;
    private PolicyStoreUtils() {
        super();
    }
    public static synchronized PolicyStoreUtils getInstance() {
        if (policyStoreUtils == null) {
            policyStoreUtils = new PolicyStoreUtils();
        }
        return policyStoreUtils;
    }
    /**@SBathala - This method uses internal classes.
     *It returns complete policy store where you could search for your own application's policy
     * @return
     * @throws JpsException
     */
    public static synchronized PolicyStore getPolicyStore() throws JpsException {
        if (policyStore == null) {
            ServerContextFactory serverCtxFactory =
                (ServerContextFactory)JpsContextFactory.getContextFactory();
            JpsContext jpsCtx =
                serverCtxFactory.getContext(ServerContextFactory.Scope.SYSTEM);
            policyStore = jpsCtx.getServiceInstance(PolicyStore.class);

        }
        return policyStore;
    }
    /** @SBathala - This method gets you the Application Policy of the application you want from the Policy Store .
     * @param applicationStripe -
     * It could be fetched from EM Console.
     * Step 1 - Choose your application
     * Step 2 - Choose the 'Application Policies' from the drop down in top bar.
     * Step 3 - Note down the Application stipe name mentioned there, Usually it will be of tis format
     * <Your_Application_Name>#<Deployed_Version_Number>
     * Eg : MyApp#V2.0
     * @throws JpsException
     */
    public static synchronized getApplicationPolicy(String applicationStripe) throws JpsException {
        if (applicationPolicy == null) {
            applicationPolicy =
                    getPolicyStore().getApplicationPolicy(applicationStripe);
        }
        return applicationPolicy;
    }
}

Once you get the Application policy, You could do whole lot of operations such as search/add/remove application roles,  grant/revoke permissions etc..

Note - The user should have the following permission in JAZN to access the policy store else the methods will throw exceptions..

 <permission>         <class>oracle.security.jps.service.policystore.PolicyStoreAccessPermission</class>
                <name>context=APPLICATION,name=[YOUR_APP_STRIPE_NAME]></name>
                <actions>*</actions>
              </permission>





Sunday, February 23, 2014

Performance Tip for Webcenter - IDs of Container components

Tip - ADF has a concept of container components by which its child components will have unique ids when rendered as HTML in front end.

Eg :  Lets say Region 1 and Region 2 form a part of a same page.
If Region 1 is with id r1 have an input text component with id i1
and Region 2 is with id r2 have an input text component with id i1
The ids of  input components in the rendered HTML would be r1:i1 and r2:i1

So though the input text component's ids are same, unique value is assigned to them automatically when the UI tree is formed during ADF lifecycle 
cool right??

Lets see a con about this, Since all of the child component's id will be appended by the parent component's id in the front and lets say you have have inputTextComponent in the below location

PageTemplate:Region:PanelCollection:Table:InputText

now the id of InputText in the front end would be (assuming ids given for each container as below)

pgtemplate:region1:pcollection1:table1:input1

This would add up to the HTML size loaded in front end.

Lets see the impact with a real example - I do have a simple page with a af:table and i have given the Table ID with a neat name "TableOne".





Now lets change the  Table ID from "TableOne" to "T"

So just by renaming one container component 0.1 KB is saved, In a large scale application where there are multiple containers and child components are in a single page this would be effective to a good extent.

Always try to name your ids to a much smaller value as possible.

For your reference PFB the list of container components  -

af:calendar

af:carousel

af:declarativeComponent

af:navigationPane

af:panelCollection

af:query

af:quickQuery

af:region

af:pageTemplate

af:subform

af:table

af:train

af:treeTable

af:tree
af:Iterator

Saturday, February 15, 2014

Cache in Iterator binding

This post is about the "CACHE" attribute in Iterator bindings. Though it looks very simple to turn on/off cache in iterator it has lot of implications with respect to performance, so just wan't to highlight it with an example :-)

Employee-Department view link of HR schema is used here.

Step 1 - I have generated java class for EmployeeVO and Departments VO with custom data source methods, placed sysouts in executeQueryForCollection.



Step 2 -  Drag and drop the view link as master detail table, run the application and observe the sysouts-



Here department VO's query is executed once on page load and employee VO query is executed as we select each department. This sounds fair right? Let turn of the Cache in iterator and try again.



Step 3- Re run the app again and now you could able to notice that DepartmentsVO gets executed on page load and as well on every PPR. Look at the number of EmployeeVO queries for each PPR !!



Proves to be an important factor :-)


How to run pubsub server in Integrated weblogic server

Scenario - For one of the usecase I had to do couple of POC on pubsub server, and as always its better to start of with Integrated WLS. I was following this wonderful blog from james bayer -
Real-time Updates on WebPages - Part 2 - Hello World Comet Application

Problem - Integrated server does not come packaged with pubsub.war :-(

Solution - 

Step 1 -  Locate pubsub.war in <MiddlewareHome>\wlserver_10.3\common\deployable-libraries\pubsub-1.0.war of weblogic server

Step 2 - Install it as a shared library in your integrated weblogic server.

Step 3 -  Now though we installed pubsub all it's dependent libraries are still not available in IntegratedWLS so we need to open the pubsub.war using winzip/anything available and see its dependent libraries in MANIFEST.MF,  then copy those libraries from Weblogic server location to Integrated WLS server location. Now that will take quite some time.

Let me give you another short cut- Copy all the folder contents from <MiddlewareHome>\modules\features and jars from  <MiddlewareHome>\modules\ to the same location in Integrated WLS.

This step copies all the required libraries to run pubsub.

So thats pretty much it :-) you can run pubsub locally :-)


Note - I used weblogic 10.3.6