Friday, May 6, 2016

AutoComplete feature with multiple element section in ADF

Auto suggest feature in ADF

We use the <af:autoSuggestBehavior/> tag to support the auto complete functionality in ADF - JSF screens.

Limitation with auto complete in ADF

It allows the selection of just one element. If we want multiple elements to be selected as shown below, it is not possible with ADF

Solution

We can use this JQuery add on - The link to download the JQuery is her

How to use that plugin?

JSF Code is as below

<af:inputText id="it1" rows="1" columns="50" label="To" simple="true"
styleClass="user-search-token-input" autoSubmit="true"
value="#{backingBeanScope.TestBean.sampleInput}"
binding="#{backingBeanScope.Test.sampleText}">
</af:inputText>


   <div style="display:none" data-bind="
                            tokenInput: 'REST API to get the code',
                            tokenInputSelector: '.user-search-token-input input',
                            tokenInputOptions: {
                                method: 'POST',
                                queryParam: 'query',
                                jsonContainer: 'users',
                                propertyToSearch: 'uid',
                                tokenValue: 'uid',
                                hintText: 'Please enter name or email address'
                            }"><jsp:text/></div>


Expected input to the Add on

$(document).ready(function() {
$("#user-search-token-input").tokenInput([{
"first_name": "Arthur",
"last_name": "Godfrey",
"email": "arthur_godfrey@nccu.edu",
"url": "https://default_profile_images/default_profile_2_normal.png"
},
{
"first_name": "Andre",
"last_name": "Jolly",
"email": "andre.jolly@uol.com.br",
"url": "https://default_profile_images/default_profile_2_normal.png"
},
{
"first_name": "Andre",
"last_name": "Henderson",
"email": "andre.henderson@globo.com",
"url": "https://default_profile_images/default_profile_2_normal.png"
}
 ]);
});

How to make the customization to the JQuery add on

Customize the required values in the plugin at the place shown in the below diagram.



Native transport for Oracle Service Bus with Apache Kafka

What is Apache Kafka?

Kafka is a distributed, partitioned, replicated commit log service. It provides the functionality of a messaging system, but with a unique design.
What does all that mean?
First let's review some basic messaging terminology:
  • Kafka maintains feeds of messages in categories called topics.
  • We'll call processes that publish messages to a Kafka topic producers.
  • We'll call processes that subscribe to topics and process the feed of published messages consumers..
  • Kafka is run as a cluster comprised of one or more servers each of which is called a broker.
So, at a high level, producers send messages over the network to the Kafka cluster which in turn serves them up to consumers like this:


 


Native transport for Oracle Service Bus 

Native transport for Oracle Service Bus allows the connection and data exchange with Kafka – supporting message consumption and production to Kafka topics. This is done in a way that allows Service Bus to scale jointly with Kafka, both vertically and horizontally.

How to install and exchange the data between Oracle Service Bus and Apache Kafka Can be found here

Friday, April 29, 2016

How to create a remote portlet and consume in Webcenter portal application


In this post, we are going to discuss the way to create, deploy and consume a remote portlet

Step 1. How to create a remote portlet

Remote portlet can be anything, as simple as an ADF application.

Create an ADF application with the taskflow containing the required logic and create a portlet entry as shown as below.




Now, create a deployment profile and deploy the application as EAR (or just view controller as war) to the application server. And note down the deployment URL from the JDEV logging console as shown below



Open that link to get the WSDL to consume the created application as portlet. Choose the second URL as shown below (That give the WSDL URL of the application we just deployed and ready to be registered and consumed as portlet).



Step2 - Register the custom application as the remote portlet


Go to Tools and Services -> Portlet Producers section as shown below in the portal administration 

Click register and give the portlet name and the WSDL file of the portlet => You are all set at the producer side. The portlet is registered and is ready to be consumed.


Step 2. How to Consume a remote portlet

Go to the page on which we would like to consume the portlet and 

go to UI Components -> Portlets -> Choose your portlet as shown below.






ADFC-02013: The ADF Controller cannot find metadata for activity ...

Sometime we run into the following issue

 <Error> <oracle.webcenter.webcenterapp.internal.view.webapp> <BEA-000000> <
oracle.adf.controller.activity.ActivityLogicException: ADFC-02013: The ADF Controller cannot find metadata for activity '/extend/webcenter/doclib/view/jsf/taskf
lows/folderViewer/folderView.xml#doclib-folder-viewer@initFolderViewer'.
        at oracle.adfinternal.controller.util.Utils.createAndLogActivityLogicException(Utils.java:230)
        at oracle.adfinternal.controller.engine.ControlFlowEngine.doRouting(ControlFlowEngine.java:1003)
        at oracle.adfinternal.controller.engine.ControlFlowEngine.doRouting(ControlFlowEngine.java:853)
        at oracle.adfinternal.controller.engine.ControlFlowEngine.invokeTaskFlow(ControlFlowEngine.java:245)
        at oracle.adfinternal.controller.state.ChildViewPortContextImpl.invokeTaskFlow(ChildViewPortContextImpl.java:104)
        at oracle.adfinternal.controller.state.ControllerState.createChildViewPort(ControllerState.java:1519)
        at oracle.adfinternal.controller.ControllerContextImpl.createChildViewPort(ControllerContextImpl.java:88)
        at oracle.adf.controller.internal.binding.TaskFlowRegionModelViewPort.createRegionViewPortContext(TaskFlowRegionModelViewPort.java:762)
        at oracle.adf.controller.internal.binding.TaskFlowRegionModelViewPort.getViewPort(TaskFlowRegionModelViewPort.java:607)

Solution

1. Make sure that the method where the metadata is failing has the fixed outcome property set in the taskflow as shown below




2. Also there should be no errors and warnings (Yes warning should also be not there) should not be there for that method in the taskflow


Wednesday, April 13, 2016

Email Validation for af:inputText in adf

jsff code


<af:inputText styleClass="email"  label=" " id="it1" rows="1" {pageFlowScope.TestBean.userEmail}"
validator="#{pageFlowScope.TestBean.customEmailValidator}"> </af:inputText>

Java Code

    public void customEmailValidator(FacesContext facesContext,
                               UIComponent uIComponent, Object object) {
        if (object != null) {
            CharSequence inputStr = object.toString();
            Pattern pattern = Pattern.compile(PortalConstants.EMAIL_PATTERN);
            Matcher matcher = pattern.matcher(inputStr);
            if (! matcher.matches()) {
                throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,
                                                              PortalConstants.EMAIL_FORMAT_ERROR, null));
            }
        }

    }


Constants Code

public class PortalConstants {
    public static final String  EMAIL_FORMAT_ERROR = "Please enter a valid email address";
    public static final String  EMAIL_PATTERN = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";

}

Friday, April 1, 2016

How to escape the af:inputText component value in ADF managed bean

Sometimes its a requirement that the text entered by the end user has to be escaped and should be stored to not loose the values entered by the end user.

How to do it?

This can be done using the StringEscapeUtils Module

JSFF Code


af:inputText id="it3" label="message" binding="#{requestScope.MB.message}" autoSubmit="true" />

Managedbean Code


import org.apache.commons.lang.StringEscapeUtils;

//Use the StringEscapeUtils Module

String userMessage = StringEscapeUtils.escapeHtml((String)message.getValue());

Tuesday, March 29, 2016

Programmatic PPR af:outputText refresh issues - no PPR-capable ID found for elements of: RichOutputText [UIXFacesBeanImpl, id=ot05]

We sometimes see the below issue on doing a programmatic refresh of af:outputText Component

The error message

PprResponseWriter$PPRTag> <finish> no PPR-capable ID found for elements of: RichOutputText[UIXFacesBeanImpl, id=ot05]

Why do we see this issue?

By default, the framework does not generate the ids for the components unless and absolutely required to optimize the page performance but we need id to be present at the client side to do PPR and thus we see the issue in doing a programmatic PPR of af:outputText. This issue can be solved in 2 methods described below.

Solution 1

Set the clientComponent="true" for the output text, sample is as below

              <af:outputText value="Test" id="ot5" styleClass="share-error"
                             binding="#{backingBeanScope.MB.message}"
                             clientComponent="true"/>

Refer to <af:outputText> documentation for more details on the clientComponent attribute

Solution 2

Add the following in web.xml

<context-param>
    <param-name>
      oracle.adf.view.rich.SUPPRESS_IDS
    </param-name>
    <param-value>auto</param-value>
</context-param>

Tuesday, March 22, 2016

oracle.jsp.parse.JavaCodeException - Root cause and solution

Sometimes we see the following exception after doing a webcenter portal deployment

Error details

OracleJSP error: oracle.jsp.parse.JavaCodeException: Line # 13, oracle.jsp.parse.JspParseTagScriptlet@5cefd96
Error: Java code in jsp source files is not allowed in ojsp.next mode.

Solution

Make sure that the web.xml in the Deployer project is empty, it should not have any adf library references.

It should looks as below.

<?xml version = '1.0' encoding = 'windows-1252'?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
</web-app>

Do we need to restart the managed server after webcenter deployments?

Yes, we need to restart the managed server after Webcenter deployments

Many developers are wondered why the changes made to the Webcenter are not dynamically obtain the changes?

An excerpt from the Webcenter portal documentation is as below

Most WebCenter application configuration changes that you make, through Fusion Middleware Control or using WLST, are not dynamic; you must restart the managed server on which the application is deployed for your changes to take effect. For example, when you add or modify connection details for WebCenter services such as Announcements, Discussions, Documents, Mail, and so on, you must restart the application's managed server.
There are several exceptions; portlet producer and external application registration is dynamic. Any new portlet producers and external applications that you register are immediately available in your WebCenter application and any changes that you make to existing connections take effect immediately too.

Wednesday, March 16, 2016

Sample code to get the user profile information in the WebCenter Portal

The sample code to get the currently logged in user profile information is as below


import oracle.webcenter.peopleconnections.profile.WCUserProfile;

String currentUserId = ADFContext.getCurrent().getSecurityContext().getUserName();
WCUserProfile currentProfile = ProfileFactory.getProfileManager().getProfile(currentUserId);
currentProfile.getDisplayName();


The complete documentation for WCUserProfile is here

Some other supported methods are as below

  1. currentProfile.getBusinessCity()
  2. currentProfile.getBusinessCountry()
  3. currentProfile.getBusinessEmail()
  4. currentProfile.getBusinessFax()
  5. currentProfile.getBusinessLocationMapURL()
  6. currentProfile.getBusinessMobile()
  7. currentProfile.getBusinessPOBox()
  8. currentProfile.getBusinessPager()
  9. currentProfile.getBusinessPhone()
  10. currentProfile.getBusinessPostalCode()
  11. currentProfile.getBusinessState()
  12. currentProfile.getBusinessStreet()
  13. currentProfile.getDateofBirth()
  14. currentProfile.getDateofHire()
  15. currentProfile.getDefaultGroup()
  16. currentProfile.getDepartment()
  17. currentProfile.getDescription()
  18. currentProfile.getDisplayName()
  19. currentProfile.getEmployeeNumber()
  20. currentProfile.getEmployeeType()
  21. currentProfile.getExpertise()
  22. currentProfile.getFirstName()
  23. currentProfile.getGuid()
  24. currentProfile.getHomeAddress()
  25. currentProfile.getHomePhone()
  26. currentProfile.getID()
  27. currentProfile.getInitials()
  28. currentProfile.getLastName()
  29. currentProfile.getLocalizedDisplayNames()
  30. currentProfile.getMaidenName()
  31. currentProfile.getManager()
  32. currentProfile.getManagerDisplayName()
  33. currentProfile.getMiddleName()
  34. currentProfile.getName()
  35. currentProfile.getNameSuffix()
  36. currentProfile.getOrganization()
  37. currentProfile.getOrganizationalUnit()
  38. currentProfile.getOriginalPhoto()
  39. currentProfile.getPersonalStatusNote()
  40. currentProfile.getPhoto(WCUserProfile.PhotoSize size)
  41. currentProfile.getPhotoUID()
  42. currentProfile.getPreferredLanguage()
  43. currentProfile.getReporteeDisplayNames()
  44. currentProfile.getReporteeList()
  45. currentProfile.getReporteeProfiles()
  46. currentProfile.getReportees()
  47. currentProfile.getTimeZone()
  48. currentProfile.getTimeZoneAsObject()
  49. currentProfile.getTitle()
  50. currentProfile.getUpdateDate()
  51. currentProfile.getUserName()
  52. currentProfile.getWirelessAcctNumber()

Tuesday, March 15, 2016

Tuesday, February 9, 2016

Fix for Oracle 12c database installation error: File not found C:\app\oracle12c\product\12.1.0\dbhome_2\ctx\admin\dr0ulib.sql.sbs


Sometimes we see the below error on installation of the Oracle 12c Database

File not found C:\app\oracle12c\product\12.1.0\dbhome_2\ctx\admin\dr0ulib.sql.sbs

Solution for the issue

1. Unzip the database zip files into one single directory (C:\DBSetup) say as below

  • winx64_12102_database_1of2
  • winx64_12102_database_2of2

2. Now copy the setup folder in 2nd folder to first older (If the windows asks for merging, do it)

3. Then abort the current installation and start fresh again. It should be done.