Dive into Oracle ADF

Send me a mail
 Dive into Oracle ADF   Click to see the XML version of this web page.   (Updated: 2/3/2008; 9:21:09 PM.)
Tips and tricks from Steve Muench on Oracle ADF Framework and JDeveloper IDE

Search blog with Google:
 

Search BC4J JavaDoc:
 

November 2006
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Oct   Dec

Get Firefox!

Friday, November 10, 2006

It's not often that I receive emails where a (potential) customer vents frustration, but today I got one from a certain "bill". His note read:

I downloaded the toy store demo for JDeveloper and found (as I suspected and is always the same from Oracle). It doesnt work. I have to read loads of geeky tripe (about nothing) and then there is no button to simply 'run' the demo. In fact it just errror error error errors.
 
I knew it - I just want to run it. Isn't that the first thing we all do? You geeks cannot manage the simplest thing. Are you just waiting for your pay packets?

Why does oracle waste all my time on geeky meanderings. Why can't you make something that is user friendly?
 
Here's how.  We download the demo. Click a start button it loads into JDeveloper, then there's a 'run demo' button and up pops the demo web page - working.

Can you manage that? NO CHANCE.

I understand his frustration. We're always trying to make our samples easier to use, and with the latest SRDemo sample I think we've achieved that.

I provided him this hopefully helpful reply, and thought it was worthwhile to capture it here in the blog for posterity...

Bill,

Sorry you're frustrated. I hope I can help. Here are pointers to demos that will "just run" out of the box. Perhaps you ended up trying to use an older version of the Toy Store Demo. The latest resources for the latest production version of JDeveloper 10.1.3 are on the ADF Learning Center.


The Service Request Demo (SRDemo ADFBC Version) is installed using the JDeveloper 10.1.3 "Check for Updates..." feature under the help menu. It automatically will install the necessary tables in the schema you point it at when its installation dialog appears. This demo is the most up to date and simplest to install. To run, you just select the "ViewController" project in the demo, and click the ">" (play) run icon in the toolbar.

As far as the ADF Toy Store Demo goes, there are several versions of it depending on which version of JDeveloper you are using. If you are using:

Sorry for so many different versions of the demo, but it's a venerable demo that's been around a long time and has evolved along with the product to show off the latest technologies.


3:04:31 PM    



Since I work often with the EL expression language in ADF/JSF applications, I have a favorite helper class that I like to use called EL (I've included the source at the end of this post). This EL class is designed to let me write terse, one-line EL-manipulation code in JSF backing beans like:

MyAppModule m = (MyAppModule)EL.get("#{data.MyAppModuleDataControl.dataProvider}");
m.someInterestingCustomMethod(x,y,z);

or

String postCode = EL.getAsString("#{bindings.PostCode.inputValue}");

or

EL.set("#{bindings.PostCode.inputValue}","#{param.SomeParamName}");

The mystery that has been haunting me for months has been that whenever I try to use my class named "EL" in a JSF backing bean, JDeveloper 10.1.3 refuses to offer me its handy, automatic Java import "insight" to save me from having to remember or type the full package name of the EL class in my Java imports section. I tried to narrow down the problem and I noticed that if I named my helper class another name like MyELHelper, the import insight worked as expected.  So, I filed a bug reporting that for some strange reason our import insight was broken for a class named EL. Today a developer on our core IDE team updated my bug with the explanation of the behavior. The mystery had nothing to do with exactly the name EL, but instead with the fact that its name is only two characters long. By default, the JDeveloper import insight mechanism waits until the developer has typed at least three characters of the class name before suggesting import assistance. This is to avoid a large number of irrelevant suggestions. For example, if you typed a letter "a" and JDeveloper were to immediately propose a list of possible classes that begin with the letter "a" which you might be intending to import, you would have a long list of classes are are not what you want. By waiting for at least three letters to be typed, it makes JDeveloper's search through all possible classes more selective and performant.

However, if you want to enable the import insight for classes of any length (including classes with 1-letter or 2-letter names), you can:

  1. Shutdown JDeveloper 10.1.3 for a moment if it's currently running
  2. Edit the file jdev/system/oracle.jdeveloper.<version>/preferences.xml
  3. Set the ignoreShortClasses preference property value to false as shown in the XML snippet below.
   :
<Item>
      <Key>JavaImportOptions</Key>
      <Value class="oracle.jdevimpl.java.imports.JavaImportOptions">
:
         <ignoreShortClasses>false</ignoreShortClasses>
:

      </Value>
   </Item>

When you next restart JDeveloper, the import insight will work for your two-letter classnames like EL.

The source of the EL helper class, in case you might be interested, looks like this:

package example.view.util;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
public class EL {
  public static boolean test(String booleanExpr) {
    return Boolean.TRUE.equals(get(booleanExpr));
  }
  public static String getAsStringWithDefault(String expr,
                                              String defaultExpr) {
    return (String)getWithDefault(expr, defaultExpr);
  }
  public static String getAsString(String expr) {
    return (String)get(expr);
  }
  public static Object get(String expr) {
    FacesContext fc = FacesContext.getCurrentInstance();
    ValueBinding vb = fc.getApplication().createValueBinding(expr);
    return vb.getValue(fc);
  }
  public static Object getWithDefault(String expr, String defaultExpr) {
    Object exprVal = get(expr);
    return exprVal != null ? exprVal : get(defaultExpr);
  }
  public static void set(String expr, String value) {
    Object valToSet = value;
    if (isELExpr(value)) {
      valToSet = get(value);
    }
    set(expr, valToSet);
  }
  public static void set(String expr, Object value) {
    FacesContext fc = FacesContext.getCurrentInstance();
    ValueBinding vb = fc.getApplication().createValueBinding(expr);
    vb.setValue(fc, value);
  }
  private static boolean isELExpr(Object o) {
    if (o instanceof String) {
      String str = (String)o;
      str.trim();
      return str.startsWith("#{") && str.endsWith("}");
    }
    return false;
  }
}

2:51:18 PM    


© Copyright 2008 Steve Muench.