Saturday, April 30, 2011

PopUpFetch Option for Property Listener

With previous JDeveloper/ADF 11g releases it was quite complicated to catch popup fetch event, we were overriding popup fetch listener inside managed bean and processing it. Its a good hint, things are simpler now - there is popupFetch property with Set Property Listener component:


This means, you can associate Set Property Listener directly with popup, and listener will be invoked automatically on popup fetching.

To demonstrate this functionality I have implemented simple filter solution, filter box is opened inside popup and is initialized with currently selected department data, by default:


Default value for filtering is set through Set Property Listener associated with popup, it assigns currently selected department name:


When user selects another department, filter value is reset by Set Property Listener during popup fetch event:


Filter operation is performed:


Filtering is performed, because VO contains WHERE clause with Bind Variable:


Filter field is mapped with variable defined inside Page Definition:


Page Definition variable is accessed through Attribute Value:


Download sample application - PopUpFetchListener.zip.

Wednesday, April 27, 2011

Strange Day - ADF Library Profile Dependency Deployment Problem

Time to time it happens, when we are keep saying - 'strange...', while developing something. It happened to me today, let me share what I was facing and how this 'strange' problem was resolved. My use case was - reusable ADF application packaged into ADF library JAR file and reused from main portal application. However, when accessing from main portal application, constantly it was throwing NullPointer exceptions from ADF Data Control. I managed to reproduce this problem with smaller simple application, NullPointer exception is generated when trying to load table component from ADF library:


Reusable ADF application is just standard ADF 11g application, it contains ADF BC and ADF Task Flows:


There is dependency set between ViewController and Model project:


Portal application is also standard ADF 11g application, it imports ADF library and includes reusable ADF region:


But it would take more closer look and browse through imported libraries, we would notice that reusable ADF library doesn't contain actual model project for our reusable ADF task flow:


Okej, so we are very close to solve the problem now, it means for some reason whole model package just was not included into ADF library. Of course, then we would look into deployment profile for ADF library and would see that Library Dependency section is empty. You must ensure deployment profile dependency is not empty, when deploying to ADF library. Its enough to have set only project dependency, when running application without deploying into ADF library JAR:


If you want to avoid one of those 'strange...' situations, make sure you will set deployment profile dependency from Model project:


Rebuild library, it will include model part now as well:


Data is loaded successfully now, through main portal application:


Download working sample application with reusable ADF library imported into main portal application - reusableapps.zip.

Monday, April 25, 2011

Invoking Stored Procedures and Functions with Named Variable Parameters

This example will explain briefly, how to use named variable parameters for PL/SQL calls. As for example, this simple PL/SQL procedure with IN and OUT parameter will be used:


Its better to pass parameters to PL/SQL procedure through named variable parameters, instead of using indexes, your code becomes much readable then. Its not described in ADF developer guide - 37.5 Invoking Stored Procedures and Functions and developers may get confused, how to pass values through named variable parameters. If developer would try to use variable=? syntax:


Runtime error will be generated for such SQL callable statement:


Correct way is to use :variable syntax for SQL callable statement:


PL/SQL procedure is completed successfully:


Wednesday, April 20, 2011

How to Get Application Server Name and Port in ADF

Quick post about how to get information for application server name and port in ADF. This particularly can be useful for instrumentation solutions. In order to get server name and port, you should acquire HttpServletRequest from ExternalContext, see example:


This example is accessing URL information from login method, but you can do it from any other place as well. Data is stored in session scope and later retrieved:


Server name and port are reported as expected:


Download sample application - SecurityFormLoginServerParams.zip

Saturday, April 16, 2011

Practical Guide for Oracle WebCenter PS3 Security Implementation

This article is about best practices for WebCenter PS3 security implementation. Provided information is not necessarily complete, I will post updates in my future posts. Main goal is to give sample start-up application, it should help to jump start your WebCenter PS3 project and avoid certain level of beginner confusion. Sample application - EnterprisePortalApp_v1.zip, is focused around secured landing page implementation and Login/Logout functionality. By default, auto-generated sample application based on WebCenter PS3 template from JDeveloper 11g doesn't have secured landing page. Every customer is wondering, where is a point to have landing page with anonymous access, this article will explain in detail how to fix this.

First, let's look more closely into problem I'm talking about. Typical WebCenter PS3 application contains navigation model, it renders menu structure on runtime:


When accessing landing page, user is redirected directly into home page with menu structure - anonymous access is enabled:


User can login directly inside home page, authentication will be performed and same home page will render authorized items:


What we want to achieve, is to redirect all anonymous users to Login page first and only then after successful authentication process to home page. If we check web.xml, Form-Based authentication is configured by default for WebCenter PS3 application:


The question is, how to enable it? As you can see, Login page is registered as login.html. We can open and check login.html after it will be removed from excluded items:


All looks good, there is redirect to actual login.jspx:


Real thing we are looking for is inside pages.xml file, it is where page hierarchy is defined:


Home page is defined to be accessible for anonymous users, its why redirect to login page is not happening when accessing landing Home page:


Click Delegate Security option and remove anonymous grant for Home page access:


Run portal application, you will get resource not found error:


From URL we can see it points to pages_home resource, this is basically home page from pages.xml hierarchy. Now since we disabled anonymous access, this resource is not accessible anymore. Open index.html file, where landing URL is defined:


Change it to point to home.jspx directly:


ADF Security will redirect anonymous users to login.jspx:


Login and enter inside portal:


From first look, all seems to work now. But believe, we need to apply few more fixes. For example, if user will try to logout now, again will get resource not found error:


First attempt to resolve this issue is to set logout_success URL in faces-config.xml:


Login/Logout works now for landing home page:


But it still doesn't work when current selected menu item points to ADF Task Flow.

Let's do some heavy refactoring for auto-generated WebCenter PS3 application and ensure Login/Logout works in all cases. First things I would recommend is to disable page hierarchy, especially when you are using combination of ADF Task Flows in the same menu structure. Open pages.xml file and remove Home page:


Once page is removed from pages hierarchy, it appears in jazn-data.xml and can be defined with ADF Security permissions as any other ADF resource:


Define required permissions:


Remove page Page Hierarchy from navigation model:


Add page link pointing to Home page inside navigation model:


In order Home page menu item to be selected by default, add externalId attribute to Home page link:


Open faces-config.xml and reference externalId of Home page as login_success URL, this allow to select Home menu item by default after successful authentication - /wcnav_externalId/defaultMenu:


One more thing, you need to extend WebCenter PS3 View Handler class. Otherwise it gets confused with navigation model items during Login/Logout actions. I have received extended WebCenter PS3 View Handler class from Oracle support, same class is available inside provided sample application. You can check in faces-config.xml, it is specified to point to extended View Handler:


Method from extended class filters and validates every navigation request, see comments inside:


Now we are done, all should work smooth. Just one more small but important best practice, make sure you protect external menu items. Its all good if menu item points to ADF page or ADF Task Flow, it will inherit security permissions from ADF Security. But if menu item points to external resources, this menu item by default is directly accessible by app-context-root/faces/menuItemId:


Open navigation model and change external resource Visible property from default #{true}:


To authenticated: