Mitkees & Webcenter

Into the charm of Oracle Webcenter and ADF

Monthly Archives: March 2016

Call a bean method after ajax call

Many requirements asks to call external service using ajax or do some javascript like using js calendars and on user click send the response to the bean to save it in database or to do some business validation.

The way to do that is using serverListener & clientListener .

The serverListener tag is a declarative way to register a server-side listener that should be executed when a custom client event is fired.

while The clientListener tag is a declarative way to register a client-side listener script to be executed when a specific event type is fired.

I have created a small demo application that calls ajax call & jquery to get location & ip and then we will send it to back bean which will be printed in the console.

Lets see the steps

1.create a jspx page and add a button like this

 <af:panelGroupLayout id="pgl1" layout="vertical">
<af:commandButton text="Get My Location" id="cb1">
<af:clientListener type="action" method="callAjaxAndNotifyServer"/>
<af:serverListener type="servListener"

2. add af:resource with the code below

 var actionbtn;
 var response_Json
 function callAjaxAndNotifyServer(actionEvent) {
 actionbtn = actionEvent.getSource();//
 $.ajax( {
 url : "", data : '', type : "GET", error : function (XMLHttpRequest, textStatus, errorThrown) {

 ajaxError(XMLHttpRequest, textStatus, errorThrown);
 success : function (data) {

 response_Json = JSON.stringify(data);

 AdfCustomEvent.queue(actionEvent.getSource(), "servListener",
 fvalue : response_Json
 return false;
 error : function (xhr, status, err) {

 var err = eval("(" + xhr.responseText + ")");
 alert('' + err.Message);
 console.log('Error in Ajax
 call:' + err.Message);

actionEvent.cancel(); is needed if you are using commandbutton without partialsubmit=”true”
AdfCustomEvent.queue(actionEvent.getSource(), “servListener”,
fvalue : response_Json
return false;
registers the custom event and set parameter “fvalue” with the json string value

3.create a bean for example backbean demoBB with method name getAjaxCallbackValue 

that you already referenced in your serverListner in step 1 & add the code to this method as follows to print the value

public void getAjaxCallbackValue(ClientEvent clientEvent) {




Update web.xml in webcenter portal

Sometimes you need to update the web.xml for webcenter portal if you want to disable compression or add servelets or change the session timeout.

As you know the webcenter potal (AKA Spaces before) is already deployed application .

In order to update the web.xml you need to create extension shared library and add web.xml to it with your updates. here are simple steps to do it:

  1. download webcenter extensions for jdevloper from here
  2. add these extensions to your jdevloper follow this blog
  3. create new application “webcenter portal server extension”
  4. you will find 2 projects “PortalExtension” & “PortalSharedLibrary”
  5. expand PortalSharedLibrary and find the web.xml under WEB-INF
  6. update web.xml as you want
  7. right click on project > project properties > deployment> edit
  8. under web files mark the web.xml to be included in the deployment.
  9. ok then ok
  10. locate the MANIFEST.MF under the project
  11. change the version Implementation-Version & Specification-Version
  12. save
  13. deploy to the server
  14. restart the managed server

Change the webcenter portal language selector task flow to be links instead of popup

The current portal language selector is a popup that shows the available languages to select from .

what if you need to create links or drop down with 2 languages only?!

you can use this code and pass the locale to the parameters

 <af:commandLink styleClass="topNavLinks frlink" rendered="#{facesContext.externalContext.requestLocale eq 'en'}" partialSubmit="false" id="frlink" actionListener="#{o_w_wa_chooseLanguage.changeLanguage}" text="French">
<f:attribute name="wcLangId" value="fr"/>
<af:commandLink styleClass="topNavLinks enlink" rendered="#{facesContext.externalContext.requestLocale eq 'fr'}" partialSubmit="false" id="enlink" actionListener="#{o_w_wa_chooseLanguage.changeLanguage}" text="English">
<f:attribute name="wcLangId" value="en"/>

Content Presenter Taskflow does not render in webcenter Portal Template

My customer asked for new business requirement which to add a js carousel as a banner in the template.

this carousel aim to get images from webcenter content + render some html on it.

while implementing this requirement   it worked great in the edit mode of the template.but it didn’t render at all in view mode on the portal.

I have opened SR with oracle mentioning that the content presenter doesn’t work in templates view mode but it works in edit mode. the reply was content presenter is not designed to work in templates.

but i found a work around that we should not add  content and template in  the taskflow edit wizard itself . Instead we add the content & template  in the content presenter paramters.


DataSource: select * from cmis:document

Data Source Type: Query Expression

Template View ID :my_customCS_viewer

Also you may find more info that may help to meet your requriments in the below links


%d bloggers like this: