Mittwoch, Dezember 22, 2004

 

Write your own JSP EL-Functions to secure your web app

Frank has a very good description to use the J2EE security model to secure your web pages fine granular (ADF UIX: Enabling and disabling page compression in UIX). However I have an extention to this: Within the ADF UIX Framework you can easily extend EL and write your own EL methode like ${isUserInRole('GuestRole')}. As you know UIX was the initial idea to specify JavaServer Faces. So with UIX you can write for each component your own renderer. This means you can write your own Java methodes and call it within the EL renderer like this:

<submitButton disabled="${ctrl:isUserInRole(uix, 'GuestUserRole')}" text="Save" >

To accomplish this you must write the following code:

public final class ELFunctions{
public static Boolean isUserInRole(Object uix, String role) throws Exception{
ControllerImplicitObject uixObj = (ControllerImplicitObject)uix;
boolean isInRole = uixObj.getBajaContext().getServletRequest().isUserInRole(role);
return new Boolean(isInRole);
}
}

After writing your static Java EL Function you must write a framework factory class. This is accomplished by usage of the UIExtention Framework:

public class ELFunctionExtension implements UIExtension {
static Class funcClass = com.bm.ui.common.ELFunctions.class;

static Class getFuncClass(String className){
try {
Class clazz = Class.forName(className);
return clazz;
}
catch(ClassNotFoundException classnotfoundexception) {
throw new NoClassDefFoundError(classnotfoundexception.getMessage());
}
}

public void registerSelf(ParserManager parserManager) {
XMLUtils.registerFunctions(parserManager, "http://xmlns.oracle.com/uix/controller",
funcClass != null ? funcClass : (funcClass = getFuncClass ("com.bm.ui.common.ELFunctions")));
}

public void registerSelf(LookAndFeel lookandfeel) { }

}


Additional you must register the UIExtention in the WEB-INF/uix-config.xml file:

<ui-extensions>
<extension-class> com.bm.ui.common.ELFunctionExtension </extension-class>
</ui-extensions>


Now you can access the isUserInRole() method directly from the uiXML code:

<submitButton disabled="${!ctrl:isUserInRole(uix,'PowerUserRole')}" text="Save" >
or
<submitButton disabled="${not ctrl:isUserInRole(uix,'PowerUserRole')}" text="Save" >
or
<submitButton disabled="${ctrl:isUserInRole(uix,'GuestUserRole')}" text="Save" >





Sonntag, Dezember 19, 2004

 

ADF: How to edit the current selected row

There are may possibilities to edit the current selecte row in usage of ADF-Bindings, ADF- BC4J and uiXML .


Samstag, Dezember 18, 2004

 

How to evaluate any parameter in ADF-Actions

You can easiely evaluate any parameter including servlet, request or ADF binding parameters with the Expression Language Syntax (EL).


/** Evaluate an EL (expression language) Expression and return the result
* @param expression EL Expression to evaluate
* @param ctx The DataAction context.
* @return The object identified by the EL expression
*/
public Object evalEL(String expression, DataActionContext ctx) {
Evaluator eval = Evaluator.getEvaluator(ctx);
return eval.getValue(expression); }


An example to retrive a request parameter into an adf action:
...

String myImputParam = (String)evalEL(ctx, "${param.myInputParam}");




Donnerstag, Dezember 09, 2004

 

Spring Toplink Integration

I am very happy to annonce Oracle's Springframwork support. The integration includes the Toplink Persistence Framework like Hibernate. http://www.oracle.com/technology/products/ias/toplink/preview/spring/index.html
... numerous thanks Jim Clark!








This page is powered by Blogger. Isn't yours?