Wednesday, February 19, 2014

ADF/WebCenter (Fusion Middleware) Errors and their solutions

  This page is to list down all issues that I face while working with ADF/Webcenter (Fusion Middleware products)

 

Issue 1:                                                                                           

ADF - Error in Jdev as shown below

Caused by: oracle.jbo.PersistenceException: JBO-34000: Definition class name missing in XML file of type taskFlow
     at oracle.adf.model.binding.DCDefBase.createAndLoadFromXML(DCDefBase.java:402)
     at oracle.adf.model.binding.DCBindingContainerDef.loadExecutables(DCBindingContainerDef.java:1405)
     at oracle.adf.model.binding.DCBindingContainerDef.loadChildrenFromXML(DCBindingContainerDef.java:1201)
     at oracle.adf.model.binding.DCDefBase.loadFromXML(DCDefBase.java:325)

Solution: Add following entries in DataBindings.cpx

  <definitionFactories>
      <dtfactory className="oracle.adf.controller.internal.dtrt.binding.BindingDTObjectFactory"/>
      <factory nameSpace="http://xmlns.oracle.com/adfm/dvt"
               className="oracle.adfinternal.view.faces.dvt.model.binding.FacesBindingFactory"/>
      <factory nameSpace="http://xmlns.oracle.com/adf/controller/binding"
               className="oracle.adf.controller.internal.binding.TaskFlowBindingDefFactoryImpl"/>
      <dtfactory className="oracle.adf.controller.internal.dtrt.binding.BindingDTObjectFactory"/>
   </definitionFactories>



=================================================================

Issue 2: http://server/webcenter/faces/oracle/webcenter/sitestructure/render.jspx?datasource=UCM%23dDocName%3mydoc shows blank page.

Solution: Check if you have navigation-renderer.jspx and its pagedef file in project. At times we delete them by mistake. These files are needed to render content which does not have a dedicated page.

===========================================================================


Issue 3: Weblogic throws 'Too many open files'
Solution: ulimit -n 4096

 

 

Thursday, February 13, 2014

Reading fillable PDF form using iText APIs


 To follow this example you need to download itext libraries. You can do it from http://sourceforge.net/projects/itext/files/latest/download


Code:

import com.itextpdf.text.pdf.AcroFields;
import com.itextpdf.text.pdf.PdfReader;

import java.io.IOException;

import java.util.Set;


public class PDFUtil {
    public PDFUtil() {
        super();
    }
   
    public static void main(String[] args) {
        String src = "D:\\Doc\\Filled_PDF_Form.pdf";
        PdfReader reader;
        try {
            reader = new PdfReader(src);
            AcroFields fields= reader.getAcroFields();
           
            Set<String> fieldKeys = fields.getFields().keySet();
            for(String itemKey : fieldKeys){
                System.out.println(itemKey + ": " + fields.getField(itemKey));
            }
            reader.close();
           
        } catch (IOException e) {
            System.out.println("IO Exception");
            e.printStackTrace();
        }

    }
}


This program will show key value pair of each field. For example

key1: value1
key2: value2





Reference: http://www.itextpdf.com/book/examples.php

NOTE: Before using iText libraries I would recommend to read  iText-licensing and pricing information.

Disclaimer: Any views or opinions presented in this blog are solely those of the author and do not necessarily represent those of the company.

Saturday, February 8, 2014

Special characters appearing in content presenter text. [Providing default style for content]

We use content presenter to show content from UCM. Content definition is defined by region-definition file and its template is create in webcenter. Let say we want to show news items in webcenter page.
First we define our news item. It may consist a title, a description and an image. All this definition goes in region definition file say NEWS_REG_DEF

In our webcenter content presenter template we refer region defintion and its element to show content. For example to show title of a news we use
 <af:outputText value="#{node.propertyMap['NEWS_REG_DEF:TXT_ELEMENT'].asTextHtml}"
                                                               id="ot11"/>


BUT there is a problem with this. If user has some special characters like quotes in text_element element, it will start showing &quote in UI. To avoid that we can use escape="false".
 <af:outputText value="#{node.propertyMap['NEWS_REG_DEF:TXT_ELEMENT'].asTextHtml}"
                                                               id="ot11" escape="false"/>


Now special characters will not appear in UI.

BUT at times we want to show text element with some specific styling. Using escape false, system will ignore any styleclass mentioned with outputtext.

As a solution we can create a panelgrouplayout around outputtext and specify styles on panelgrouplayout.

For example

Template code:
  <af:panelGroupLayout id="pgl21"  layout="vertical" styleClass="headline">
       <af:outputText value="#{node.propertyMap['NEWS_REG_DEF:TXT_ELEMENT'].asTextHtml}"
                  id="ot11" escape="false"/>
      </af:panelGroupLayout>


CSS:
.headline {
    font-size: 16px;
    color: #000000;
    font-weight:bold;
    }


NOTE: PanelGroupLayout can only provide default styles. If element is of type wysiwyg, contributor can put styling while creating content and in that case those styling will take preference. Functionally and Technically it makes sense also. That is why I referred it as a default syling by panelgrouplayout. It will only work if contributor has not overridden it by providing his own setting.

Disclaimer: Any views or opinions presented in this blog are solely those of the author and do not necessarily represent those of the company.

Friday, January 10, 2014

Refreshing consumer page based on action performed on webcenter provided task-flow

Webecenter provides many task-flows and we can drag and drop these task-flows on our page. There might be a usecase when we want to refresh a section of our consumer page while clicking a button (or link) on webcenter provided task-flow page (jsff).

Let say our page is shows as below




Ideal solution would be to raise contextual event from 'Click Me' button and handle it in consumer page. But this would require good amount of customization of webcenter task-flow. We can achieve it without contextual event, which requires minimal customization of webcenter task-flow.

Let say we want to consume poll service on our page (HomePage). This service (task-flow) provides a 'Vote' button. On click on Vote button we want to refresh certain section of consumer page (HomePage).

Here are the steps

Step 1: We just need to set a variable in request scope on click of 'Click Me'. For which we need to customize webcenter jsff. Customized file would look something like




Step 2: Now I need to bind my UI component which I want to refresh with a bean


Step 3: Write a refresh method in bean as
 public void refreshHomePagePollSection() {
             if(this.getPollSection() != null ) {
                      AdfFacesContext adfctx = AdfFacesContext.getCurrentInstance();
                      adfctx.addPartialTarget(this.getPollSection());

            }
             
}


Step 4: Create a java class (say HomePageDC.java) and have this method in that class
    public void refreshHomePagePollSection() {
               HomePageBean bean =
            (HomePageBean)ADFUtil.evaluateEL("#{backingBeanScope.HomePageBean}");
        bean.refreshHomePagePollSection();
            }

    Expose this class as a datacontrol. This will create a HomePageDC.xml file and it would look like


Step 5: Add refreshHomePagePollSection method of datacontrol in your binding: For this open consumer pageDef (say HomePagePageDef.xml) and click on + icon in binding section. Select methodAction. In next popup select datacontrol (HomePageDC) and then operation (refreshHomePagePollSection).



Step 5: Add executable for binding method: Open consumer pageDef (HomePagePageDef.xml) and add executable by clicking on + icon in executable section. Select 'invoke Action'. In next popup select select


 Step 6. Set refresh condition for executable as #{requestScope.pRefreshPollSection == 'Y'}

Page should look like this


Now whenever user clicks on a button which is inside webcenter task-flow a requestscope variable pRefreshPollSection = Y will be set. Consumer Page (HomePage) binding will be called. It will execute datacontrol method refreshHomePagePollSection. This method calls bean method which refreshes the consumer page's UI component.


Disclaimer: Any views or opinions presented in this blog are solely those of the author and do not necessarily represent those of the company.






Thursday, December 19, 2013

Favicon using ADF

Favicon is an icon in browser tab and address bar. Below diagram shows it.











There are two ways to show favicon in browser
1. Set context-root as "/" and then put favicon.ico file in web-root directory: Actually browser tries to fetch http://<server>:<port>/favicon.ico from server and if its available then it will try to show that as a favicon. While deploying application on server we need to specify its context-root. Application pages can be accessed as http://<server>:<port>/<context-root>/<page-url>. To access any file from application we need to have context-root in url otherwise server will not know which application to use as there might by many application deployed on a server. Using this context-root only server knows about application and get files from that application only. If you have only one application on a server you can decide to have "/" as a context root and then you can access your pages as http://<server>:<port>/<page-url>.  Now if we put favicon.ico file directly under web-root directory (public_html) then we can access it using http://<server>:<port>/favicon.ico.
To set context-root "/" for an ADF application we can do following:

a. Setting context root while running application (or page directly) with integrated weblogic server:  If you are running your page directly in JDEV it will use integrated weblogic server and context root will be picked from 'Java EE application' setting. To set it follow Web-Project-Properties > Java EE application

















BUT BUT this does not work. The moment I try to save this setting I get error as



























OK. Now lets try to play with jdeveloper and try to change this using a text editor directly. We can open UI project's jpr file and then search for property j2eeContextRoot. Now change its value to "/" as shown in below diagram.
















If we open UI project's property we will see context-root is changed to "/". Use cancel to close project properties and run the page.






















Put favicon.ico file directly under public_html directory of your UI project.


Run your page.  You should see favicon icon appearing on browser tab.

 NOTE: You may see error as "Context path '' is already in use by the module: / application: FMW Welcome Page Application"



It means there is already an application "FMW Welcome Page Application" running which has context path as "/". We need to stop this application. Go to console and stop this application and then re-run the page.

IE started showing favicon icon. Firefox and Chrom are still not showing. Looks like Firefox and Chrom needs explicit <link ...> tag in its head section.

b. Settting context root while deploying application (war/ear) on a stand-alone server:
When we are deploying application on a stand-alone server we can set context-root using war deployment profile of UI project. Navigate to UI project's properties > Deployment and select appropriate war deployment profile. Edit it and change context root as shown below.

Now deploy application using this war profile on a stand alone server.

IE started showing favicon icon. Firefox and Chrom are still not showing. Looks like Firefox and Chrom needs explicit <link ...> tag in its head section.


2. Add explicit <link ....> entry in your page head:  To show a favicon icon we can also add following entry on head section of html as
 <html>
     <head>
         <link rel="shortcut icon" href="location-of-favicon.ico file">
     </head>

     <body>
     </body>
</html>

The key-word "shortcut icon" allows browser to show icon file as a favicon. If favicon.ico is under web-root directory we can directly write href="favicon.ico". If its under some other directory like images etc we can refer it as <link rel="shortcut icon" href="/context-name/images/favicon.ico">

In terms of ADF question is how to write <link ...> line in head section of html. 
We can use metaContainer facet of <af:document> tag
Add following line under <af:document> and change favicon.ico location accordingly.

<f:facet name="metaContainer">      
    <af:outputText escape="false"              
            value="&lt;link href=&quot;#{facesContext.externalContext.requestContextPath}/images/favicon.ico&quot; rel=&quot;shortcut icon&quot;>" id="o1"/>   
</f:facet>

To add this line we can also try to write a javascript which runs on page load but I found that javascript solution is not working in IE.

========================
11.1.2 solution: From 11.1.2 we have smallIconSource and largeIconSource attributes to show favicon icon.


Bottom line is
1. If you are on 11.1.1.x use metaContainer facet approach to make favicon working in all browser.
2. If you are on 11.1.2.x use smallIconSource and largIconSource attributes of <af:document> tag.

In both approaches you need to do it in individual jspx page. I believe we don't have any common solution (like adding it in template) which will allow us to avoid code duplication in all pages.


Disclaimer: Any views or opinions presented in this blog are solely those of the author and do not necessarily represent those of the company.


Thursday, November 21, 2013

'Service not available' error with webcenter services (Polling etc)

We have recently hit 'Service not available' error with polling service of webcenter. Solution we found is that we need to have correct jndi settings in weblogic.xml file

weblogic.xml file by default resides in /WEB-INF folder. Its has two jndi entries, which are used to connect with WebCenter and ActivityStream schema. 

Generally settings are 

 <resource-description>
    <res-ref-name>jdbc/ActivitiesDS</res-ref-name>
    <jndi-name>jdbc/ActivitiesDS</jndi-name>
  </resource-description>
  <resource-description>
    <res-ref-name>jdbc/WebCenterDS</res-ref-name>
    <jndi-name>jdbc/WebCenterDS</jndi-name>
  </resource-description>


We need to have two db connection settings in weblogic with jndi entries as jdbc/ActivitiesDS and
jdbc/WebCenterDS. 


jdbc/ActivitiesDS should point to activity shema and jdbc/WebCenterDS should point to webcenter schema. 

If we are creating different jndi connection in weblogic, we should change entry in weblogic.xml accordingly. 


Disclaimer: Any views or opinions presented in this blog are solely those of the author and do not necessarily represent those of the company.

Tuesday, October 29, 2013

ADF: Mandatory SelectOneChoice component is not firing client side validation.

Let say we have a form which is used to create/edit data and in this form we have one input-text component and one SelectOneChoice component. If both of these fields are mandatory there are times when we see client side validation is happening for input-text but not for select-one-choice.

Take example of this picture

 


 If we wee LastName and Email validation are happening client side and we get proper error message as 'You must enter a value' but DepartmentId validation is happening in model side, which is causing error message as 'Attribute DepartmentId in HRAppModule.EmployeeVO is required'.

Generally this issue occurs when we include a 'No Selection' item for a mandatory attribute while creating LOV.








If we 'Include 'No Selection' Item: client pushes "" value from UI which is not null so client side validation does not happen.
If we don't include 'No Selection' Item: client shows blank initially which is null and once user hit submit, it performs client side validation on it. The moment user selects a value, he would not be able to select blank again as attribute is mandatory. Yes, he can change value but no more blank value selection. Which is good way of forcing him to select something.



Disclaimer: Any views or opinions presented in this blog are solely those of the author and do not necessarily represent those of the company.