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());