Andrej Koelewijn

7/21/2004

Creating a custom tag for use with ADF data bindings

Filed under: — andrejk @ 9:16 am

Here’s how you can create custom tags that support JSTL’s expression language. This example applies to JSP 1.2. In JSP 2.0 is has become a lot easier, as JSP 2.0 already supports EL, so you don’t need JSTL for that.

I wanted to create a tag that can be used with ADF’s data bindings, for example:


<taglib1:Tag1 attr1="${bindings.TabDonorView1}" ></taglib1:Tag1>

In you tag implementation code you’ll need to import apache jstl’s ExpressionEvaluatorManager. Here’s how you can use it:


import oracle.adf.model.binding.DCControlBinding;
import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
...
binding = (DCControlBinding) ExpressionEvaluatorManager.evaluate("attr1",attr1,Object.class,this,pageContext);

Using VPD with BC4J

Filed under: — andrejk @ 9:14 am

On OTN you’ll find a document outlining how to use VPD with BC4J: How To Create Secure BC4J Applications with Oracle9i VPD and Oracle 9iAS JAAS Provider.

I’ve tried the method described, but couldn’t get it to work properly. The afterConnect method is called only once, if you do not use connection pooling. I tested this by setting the max application module pool size to 1, and starting 2 browser sessions. Logging in with the first browser, afterConnect is called, setting the application context for VPD. After logging in with the second browser, afterConnect is not called as the application module already has a database connection.

You need to use afterActivation instead of afterConnect to make this work. AfterActivation is called every time an application module is activated from the pool. Now you can set your VPD context in the database before doing any work in the application module.

Update: Steve Muench has commented that it’s better to implement this using prepareSession(), instead of afterActivation().

Powered by WordPress