June 6, 2013

Webcenter Portal Display issues in lower versions of IE

I have a portal application developed in JDev 1.6. While running the application, it supposed to be 
displayed full of the browser and it is in Firefox, Chrome and even in IE (version greater than 8). But 
I have a requirement to use this in IE7. When I run this app in IE7, the app is displaying in one third 
of the browser. To make my app displays properly in IE7, I need to write some browser specific 
javascript. Below is my javascript code added to my home page. This script will be executed when 
the browser is IE and its version is 7.

<af:resource type="javascript"> 
browser_version= parseInt(navigator.appVersion);
browser_type = navigator.appName;
if (browser_type == "Microsoft Internet Explorer" ) {
if((browser_version == 4)){
var lineURL = "&lt;style&gt;.af_decorativeBox { width: 100% !important;height: 640px
 !important;}div.af_decorativeBox_center{overflow: hidden !important;}div.af_panelTabbed_body {overflow: auto;}.profileSubHeader{ margin-left: -10px !important}.wid50 input {width: 35px !important;}&lt;/style&gt;";


In the above code, lineURL is a variable which holds css styles which will impact my display in IE7.

May 6, 2013

Using multiple skins in an ADF application

To use multiple skin files in an ADF application, follow the below procedure.
  • Create different css files for the application. (In this example, I have created css files under the folder css)
  • Configure all these skins in trinidad-skins.xml file. The file would be like below
<?xml version="1.0" encoding="windows-1252"?>
<skins xmlns="http://myfaces.apache.org/trinidad/skin">

  • Make an entry in the trinidad-config.xml file as below with a variable to replace skin family name. Here “currentSkin” is a String variable configured in adfc-config.xml under session scope. In this example, skin-family is provided a default value “test”. If no value is passed to the variable “currentSkin” then the page will be loaded by the skin “test”.
<?xml version="1.0" encoding="windows-1252"?>
<trinidad-config xmlns="http://myfaces.apache.org/trinidad/config">
  <skin-family>#{sessionScope.currentSkin!=null?sessionScope.currentSkin : "test"}</skin-family>

  • And write a method in a manage bean and define with below java code. In this example, the new skin value is taken from a value change listener.
public void valueChangeListener(ValueChangeEvent valueChangeEvent) {
/*Code to change the skin value in session variable*/
       String currentSkin=valueChangeEvent.getNewValue().toString();
        FacesContext context = FacesContext.getCurrentInstance();
        Map sessionMap = context.getExternalContext().getSessionMap();
        sessionMap.put("currentSkin", currentSkin);
/*Code to refresh the page with new affects*/      
                String currentView = context.getViewRoot().getViewId();
                ViewHandler vh = context.getApplication().getViewHandler();
                UIViewRoot viewRoot = vh.createView(context,currentView);

Refreshing JSF page from Java Code

The below code can be useful to refresh JSF page from java code method. 

String currentView = context.getViewRoot().getViewId();
ViewHandler vh = context.getApplication().getViewHandler();
UIViewRoot x = vh.createView(context,currentView);