Main

Stories Archives

March 29, 2006

ADF Sample Applications

In my daily work, I often create small example applications for customers. I'll document them here - for those who read Steve's blog regularly, I copied the idea from his "Not Yet Documented ADF Sample Applications" page.

When I find useful to document the example in detail, you'll find a project "_StartHere" in the application. Right-click _StartHere and select Run to see the associated Help page:

_StartHereRun:


  1. Rendered
    [10.1.3.3.0] 30-APR-08
    Shows an ADF Faces page with 2 radio buttons to show / hide a command button.
    This doesn't work when both properties rendered and partialTriggers are defined on the button.
    It works fine when wrapping the button in a parent component where you move the partialTriggers property.
    For more information, see "Only Rendered ADF Faces Components Can React To PPR"

  2. Lookup
    [10.1.3.3.0] 31-JAN-08
    Shows an ADF Faces page displaying an Employee (SCOTT.EMP); it includes a field Deptno that automatically refreshes a field Dname (called a "Lookup" field by the Oracle Forms and Oracle Designer community).
    Lookup:
    The underlying model is a View Object EmpView based on 2 Entity Objects Emp (Primary and Updatable Entity Object) and Dept (Reference Entity Usage).
    The Deptno is bound to an <af:selectInputText> component with property autoSubmit="true", causing a PPR (Partial Page Rendering) postback to occur when the end-user changes the value of the Deptno.
    The Dname field has its partialTriggers property set to the value of the id of the <af:selectInputText> component (partialTriggers="Deptno"). As result, its value is refreshed as soon as the value of Deptno is changed.

  3. <af:tableSelectMany>
    [10.1.3.2.0]
    Shows
    an ADF Faces page where you can select many Employees to increase their
    salary.
    This sample doesn't include any code, except in the
    Application Module to increase the salary. The rest is
    declarative!
    The method in the AM has the following signature:
    public void massSalaryIncrease
    (Set<Key> EmpKeys, Number raise)

    In
    the method binding, I pass the following EL as parameter: ${requestScope.BackingSalaryIncrease.selectedEmployees.selectionState.keySet}
    This
    will pass the Keys of the selected employees to the AM method. There
    it's possible to loop through the keys to process the records, by
    selecting them with the findByKey()
    method.

  4. TableRange [10.1.3.1.0]
    Shows
    an ADF Faces page where you can query the Employees (Read-Only Table)
    of a specific Department (by entering the Department Number). The case
    is trivial, but end-users may report a strange behavior:
    the Range in the Table stays at the same position as previously selected.
    F.ex.
    you query the Employees from Department 10, navigate to the second
    Range of Employees, and then query the Employees from another
    Department, say 20. While you would expect the page to show the first
    Range, with the first Employees from the Department 20, it doesn't:
    the page stays at the same Range (second) as it was when displaying Employees from Department 10.
    The
    sample includes a page showing the default behavior and another one
    with a workaround, where I reset the Range to the first row of the
    table [table.setFirst(0)].

  5. <af:selectBooleanCheckbox> [10.1.3]
    Shows how to use an <af:selectBooleanCheckbox> bound to VARCHAR2 or NUMBER Oracle Database columns.
    This
    is performed by creating a transient attribute of type Boolean and
    redefining its getter and setter methods to 'translate' the ADF
    Business Components type Boolean to 'standard' String or Number types that Oracle "understands".
    (Boolean
    is not a valid type in the Oracle Database).

  6. ENTER key and Reset button
    Shows how to set an ADF Faces page to Submit the form with the ENTER key
    It also shows how to reset the fields to null with a Reset button, via JavaScript.

  7. <af:selectOneRadio>
    Shows how to disable/enable inputTexts depending on the value selected in a Radio Group (selectOneRadio); this example illustrates the following properties: AutoSubmit, PartialTriggers & EL in the "Disabled" property.



May 19, 2006

ADF Faces Core and ADF Faces Html missing from the Component Palette

The problem

From time to time, I have the following problem in JDeveloper after I create a new Application with a template including JSF:
I cannot see the palettes ADF Faces Core and ADF Faces Html from the drop-down list in the Component Palette:

ComponentPaletteNoADF:

and when I drag and drop an element from the Data Control palette in a new JSF JSP page, the tags are not executed in the Visual Editor:

VisualEditorTagsNotExecuted:

If you look at the Structure window, you can see a warning No grammar available for namespace http://xmlns.oracle.com/adf/faces/html, contents of element html cannot be validated:

WarningInStructure:

The cause

I suspect this happens after JDeveloper was inactive for a while.
I logged Bug 5232205 (requires an access to MetaLink) to report this issue.

The solution

Just close and restart JDeveloper.
You will see ADF Faces Core and ADF Faces Html in the Component Palette:

ComponentPaletteWithADF:

and the tags will be executed in the Visual Editor:

VisualEditor_OK:

May 23, 2006

IllegalStateException when Running a JSF Page in the Embedded OC4J

The Problem

Running or debugging a JSF page from JDeveloper in the embedded OC4J may display an IllegalStateException in the Log window:


06/05/23 17:30:53 java.lang.IllegalStateException: ClassLoader "adf.oracle.domain:10.1.3" (from <shared-library> in <JDev_Home>/jdev/system/oracle.j2ee.10.1.3.36.73/embedded-oc4j/config/server.xml): This loader has been closed and should not be in use.
06/05/23 17:30:53     at oracle.classloader.util.ClassLoadAsserts.fail(ClassLoadAsserts.java:154)
06/05/23 17:30:53     at oracle.classloader.PolicyClassLoader.checkState(PolicyClassLoader.java:1977)
06/05/23 17:30:53     at oracle.classloader.PolicyClassLoader.internalLoadClass(PolicyClassLoader.java:1645)
06/05/23 17:30:53     at oracle.classloader.PolicyClassLoader.loadClass(PolicyClassLoader.java:1621)
06/05/23 17:30:53     at oracle.classloader.PolicyClassLoader.loadClass(PolicyClassLoader.java:1606)
06/05/23 17:30:53     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
06/05/23 17:30:53     at oracle.jbo.pool.ResourcePoolMonitor.run(ResourcePoolMonitor.java:70)
06/05/23 17:30:53     at java.util.TimerThread.mainLoop(Timer.java:512)
06/05/23 17:30:53     at java.util.TimerThread.run(Timer.java:462)

However, the page works and is displayed in your browser without any the problem.


The Cause

The problem is related to the "warm-restart" of the Embedded OC4J server when redeploying applications.
For more information, see the Oracle JDeveloper 10g Release Notes, topic "Intermittent IllegalStateException Rerunning ADF Web Applications on Embedded OC4J (4758240)"


The Solution


This error can be ignored.
As a rule of thumb, we advise you to close the browser and stop the Embedded OC4J Server after you tested or debugged your application.

In JDeveloper 10.1.3, you can stop the Embedded OC4J easily by clicking the "Terminate" button in the Log window:

TerminateInLogWindow:

May 25, 2006

JSTL 1.0 in JSP 2.0 Pages

The problem

We had several customers who reported the same issue last week through MetaLink. I see that others also created a Forum thread:

JSP pages with JSTL including EL gives the following error at compilation in JDeveloper 10.1.3:

Error(<line number="">): Expression Language not supported in compile time attribute value
</line>

or the following when running the page in OC4J:
500 Internal Server Error
OracleJSP: oracle.jsp.parse.JspParseException: /Name.jsp: Line # 13, <c:out value="Hello, my name is ${LastName}, ${FirstName} ${LastName}">
Error: Expression Language not supported in compile time attribute value</c:out>
The same pages could compile and run without any problem with JDeveloper 10.1.2.

The cause

This happens when using JSTL 1.0 in JSP 2.0
When the Deployment Descriptor (web.xml) is from version 2.4 - you see it in your web.xml file:
<web-app (...) version="2.4" (...) >
then the default mode for JSP pages is to evaluate EL expressions, what raises the above errors when JSTL 1.0 libraries are used.

The solution(s)

Depending on the fact you want to continue working with the JSTL 1.0 libraries or not, here are different solutions you can implement:
  1. use the JSTL 1.1 libraries;
    you should add the 1.1 libraries to your Project and replace the URIs in your pages, as they are different between the 2 versions.
    The new URIs are similar to the old JSTL 1.0 EL URIs, except that jsp/ has been added in front of jstl, stressing JSTL's dependency on the JSP specification (which now "owns" the EL).
    For example:
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  2. use the "Request-Time" (..._rt) JSTL 1.0 libraries:
    for example, if you use the core library, replace "core" by "core_rt"
    <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
  3. Create your JSP Pages in a Project with a 2.3 Deployment Descriptor
     
    Each JSP page has a default mode for EL expression evaluation. The default value varies depending on the version of the web application deployment descriptor.
    The default mode for JSP pages delivered with a Servlet 2.4 descriptor is to evaluate EL expressions.
    The default mode for JSP pages delivered using a Servlet 2.3 or earlier descriptor is to ignore EL expressions.
    So, if you create your JSP pages with JSTL 1.0 in a "Servlet 2.3/JSP 1.2 (J2EE 1.3)" Web Project (when you create a "Web Project" in JDeveloper 10.1.3, you are prompted for its version), the EL will be ignored and your page will compile.

  4. Deactivate the EL evaluation with a Page directive or in the Deployment Descriptor:
    You can deactivate the EL evaluation either at the JSP page level, in the page directive, by setting the isELIgnored attribute to "true":
    <%@ page (...)  isELIgnored="true" %>
    or in your Deployment Descriptor (web.xml), by setting the <el-ignored></el-ignored> element to true (subelement of <jsp-property-group></jsp-property-group>):
    (...)
        <jsp-config>
            <jsp-property-group>
                <display-name>Ignore EL</display-name>
                <url-pattern>*.jsp</url-pattern>
                <el-ignored>true</el-ignored>
            </jsp-property-group>
        </jsp-config>
    (...)

In case you have access to MetaLink (*), I also created Note 361806.1 - JSTL Including EL Raises Error "Expression Language not supported in compile time attribute value"

(*) MetaLink requires a login that you get with your Oracle Support licence.

References

The debugger only displays the first 100 characters in String variables

Steve writes in a comment:

"(...) if you look at a string in the debugger trace window, it is truncated..
so if you happen to have a very long sql statment in hte string , or cannot view it, or even edit it"

Indeed,
that's correct: as for any array, the debugger will only show 100
elements at a time, for performance reasons, as it may be very
expensive to send an unlimited value from the debuggee process to the
debugger.

So we only display the first 100 characters of a String.
For example, suppose the following code:

(...)
StringBuilder sb = new StringBuilder();

sb.append("This String has exactly 100 characters and you can check that all characters are displayed  in debug");
sb.append("* * *  However this text won't be visible in the Debug Data window * * *");
sb.append("* * *as it's after the limit of the 100 characters * * *");
(...)

In the debugger, you will only see the first 100 characters:

DebugString01:

However, it's possible to see the whole value:
To modify the value, select right-mouse button menu "Modify Value..."

And for what concerns the arrays, you can select menu "Adjust Range..." if you want to display more elements:

DebugString04:


How to add JDK 1.5 API Reference to JDeveloper 10.1.3

In prior releases of JDeveloper, the Help menu included the J2SE API Reference:

MenuJ2SEAPIReference:

Several customers asked us why it is missing from JDeveloper 10.1.3
The reason is that we don't include the J2SE API documentation in JDeveloper anymore.
Instead, we refer to http://java.sun.com/j2se/1.5.0/docs/api

If you want to add the JDK API locally:

  1. Download the Java Docs on your machine;
    in my case, I keep it in C:\java\jdk1.5.0\doc\jdk-1_5_0-doc.zip


  2. In JDeveloper, select menu Tools > Manage Libraries... and click tab J2SE Definitions


  3. Select 1.5.0_05 library under User


  4. Click the 'Doc Path:' in the right panel and click button Add Entry...
    JDK15API_1:


  5. Expand C:\java\jdk1.5.0\doc\jdk-1_5_0-doc.zip!\docs, select api and click Select

    Remark:
    you don't need to extact the javadoc from the .zip file: you can
    use this dialog to navigate within the .zip file and select the
    directory holding the javadoc;

    the path will be specified as the following: C:\java\jdk1.5.0\doc\jdk-1_5_0-doc.zip!\docs\api where the "!" separates the path to the zip file itself from the path to the javadoc within the .zip file.


  6. Ensure that C:\java\jdk1.5.0\doc\jdk-1_5_0-doc.zip!\docs\api
    appears above the URL http://java.sun.com/j2se/1.5.0/docs/api by using
    the arrow Move up
    JDK15API_2:


  7. Click OK


  8. Exit and restart JDeveloper

This won't add the menu J2SE API Reference in Help, but when you will select Go to Javadoc in java code, it will look at the local documentation instead of connectiing to http://java.sun.com
However, you can right-click the page and select Add to Favorites; by selecting menu Help -> Favorites, you'll then be able to access it directly.



June 8, 2006

UIX LOV Doesn't Return the Selected Value the First Time


The Problem


We have had several customers complaining about the fact that the UIX List of Values (LOV) wasn't working correctly in JDeveloper 10.1.2:

The problem reproduces as the following:
  • no value is returned from the LOV:
    • you create a new Row in a UIX page
    • you click a LOV icon to run a  LOV window
    • you select a value from the LOV window
    • you close the LOV window by clicking on the "Select" button
    • the selected value isn't displayed in your UIX page

  • the LOV returns a value the second time it's invoked
    • after the first trial as described above
    • you repeat the same operation (launch the LOV window, select a value and click "Select"),
    • this time, a value is returned in the field associated with the LOV
The same steps did work in JDeveloper 9.0.x releases, and it still work for pages that were migrated to JDeveloper 10.1.2
It doesn't work for new pages created in JDeveloper 10.1.2


The Cause


The functionality of the "Create" Action Binding has changed between JDeveloper 9.0.5.2 and 10.1.2
.
In JDeveloper 9.0.5.2 (and prior releases), the "Create" action binding was calling the 2 View Object methods: createRow() and insertRow().
Method createRow() does create a new row;
method insertRow() does insert the row in the RowSet. This method sets the current row to the row just inserted

In JDeveloper 10.1.2, the "Create" action binding calls the createRow() method only.
We implemented this change to avoid the "blank row" problem as described in document "Avoiding the Blank Row Issue in ADF Business Components Web Applications" from Steve Muench.

The problem is that the selected value actually ends up in the current row (the current row isn't changed by the call of createRow() method only). The page is then submitted and the new row inserted in the Row Set.
If you invoke the LOV a second time, then it returns the value as expected.

If you have acess to to MetaLink, you can read the following documents about the problem:

Note 299860.1: UIX LOV Returns the Selected Value in Another Row
Bug 4201020: UIX LOV VALUE SET IN EXISTING ROW INSTEAD OF NEW ROW W/ "CREATE" ACTION BINDING


The Solution


Change the binding for the Create action from "Create" to "CreateInsert" as explained below:
  • With your UIX page selected, click on "UI Model" (3d toolbar button) in Structure pane as shown in the next figure:

    UIXLOV_Structure:

    Figure 1 - UI Model toolbar button

  • Double-Click on "Create" under UI Model as shown in the next figure:

    UIXLOV_Create:

    Figure 2 - Create Action Binding

  • This opens the 'Action Binding Editor';
    Change "Select an Action" from "Create" to "CreateInsert" as show in the next figure:

    UIXLOV_CreateInsert:

    Figure 3 - Action Binding Editor

  • Click OK.
  • Run your application; this time, the LOV will behave as expected directly.
NB: you can check the Action Binding in your <name>UIModel.xml file
      <DCControl
         id="Create"
         SubType="DCAction"
         IterBinding="DeptView1Iterator"
         Action="40"
         RequiresUpdateModel="true" >
      </DCControl>
Action="40" is used for the "CreateInsert"
Action="41" is used for the "Create" 

This tip can be convenient for you to assess how many "Create" action bindings (Action="41") you have in your application by using the "Find in Files" utility (menu "Search" -> "Find in Files..." or accelerator Ctrl+Shit+F).
However, you should only modify UIX pages that also include a LOV (UIX component messageLovInput), and always via the aforementioned dialog.

July 24, 2006

ADF Faces: Submit a form with the Enter key

Question


In ADF Faces, how to submit an input form with the ENTER key ?

Suppose f.ex. the following Login page with 2 input fields: Username and Password, and a button: Login:

LoginPage:


Your end users have to enter their username and password and then click the button Login.
However, some would prefer to press the ENTER key as equivalent to clicking Login.


Answer

A lot of developers search for a property in the <af:commandButton> to specify that pressing ENTER should activate the button.
As they don't find any they conclude this is not possible to define it in ADF Faces.
This is true you cannot specify it at the <af:commandButton> level (you can only define an access key there), but you can in the <af:form>.tag.
More details below.

af:commandButton

There is no property in the <af:commandButton> tag to specify that pressing the ENTER key is the equivalent of clicking the commandButton.

There is a property accessKey (sometimes referred to as the "mnemonic") to specify the character that, when pressed in combination with the ALT key, will activate this commandButton.
<af:commandButton text="Login"
id="loginButton"
(...)
accessKey="L" />
In this example, pressing ALT + L will activate the Login button.
The button is rendered with the accessKey underlined as shown the next figure:
LoginButton:

NB: you can also use the textAndAccessKey to simultaneously set both the "text" and "accessKey" attributes from a single value, using conventional ampersand (' & ') notation.

af:form

You can specify it in the <af:form> tag. It contains a property defaultCommand where you can specify the id attribute of the command button whose action would be invoked by default for form submit on hitting ENTER on any of the input fields of the form:
<af:form (...) defaultCommand="loginButton" >
(...)
</af:form>

By default, JDeveloper creates a JSF standard h:form tag in your JSF pages, but you can easily convert it to an af:form tag by performing the following steps:

  1. in the Structure window, select h:form

  2. select the right-click menu Convert

    Structure_Convert:


  3. in the Convert Form dialog, select the category "ADF Faces Core";
    select the item to be created: Form and click OK

    ConvertForm:


  4. select af:form in the Structure window (that's the component we have created);
    in the Property Inspector, type the id of the commandButton in the property DefaultCommand, in this example loginButton

    PropertyInspector_defaultCommand:



References

JDeveloper online help, topics
Oracle Application Development Framework Developer's Guide For Forms/4GL Developers

January 18, 2007

Firefox Extensions

ChatZilla

Colorful Tabs

FAYT ("Find As You Type")

In Firefox, the useful "Find As You Type" bar (with "Next", "Previous", "Highlight all" and "Match case" buttons) has disappeared being replaced by a poor search box with no buttons (Reference: https://bugzilla.mozilla.org/show_bug.cgi?id=347259). This extension resets the FAYT bar as it existed in Firefox 1.

To get your loved "Find As You Type" bar back in Firefox 2, it's enough to install FAYT extension.
https://addons.mozilla.org/firefox/3650/

FireBug

Forecastfox

FoxyTunes

LinkedIn Companion for Firefox

Live HTTP Headers

Smoothwheel

StumbleUpon

Tab Mix Plus

Venkman JavaScript Debugger

Web Developer

About Stories

This page contains an archive of all entries posted to Didier's Blog in the Stories category. They are listed from oldest to newest.

None is the previous category.

Support is the next category.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle