Thursday, August 7, 2008

Glasspane in ADF Faces RC

You can build very cool systems, based on excellent architecture design, with ADF BC or EJB in Model layer and with ADF Task Flows in View Controller layer. However, when it comes time for functional test, tester can break all things only with one question - why when I pressed Apply button and at the same time have pressed couple of other buttons, I got some unexpected result? Well, you probably will answer - you need to wait after Apply button is pressed some minute until operation will be finished and only after it will be done you can press other buttons. I'm sure, tester will not be satisfied with such answer, and application will not be accepted. However, things are not so bad as you can imagine, Frank Nimphius have described how to block page screen during long operation - How-to build a reusable Glasspane in ADF Faces RC. Please read Frank's article, before reading my post, since current post is completely based on it. Here I will describe with sample application how to refresh the screen to show the visual results of the long running operation.

Developed sample application - GlassPaneTest.zip is based on HR schema from Oracle XE database and implements one JSPX page with search form and results table. When you will open this application in JDeveloper 11g, be sure GlassPane reusable component (JAR file) is in correct path. You can check this in JSP Tag Libraries section by opening Project Properties for ViewController:


In this application I'm running two 'long' operations:
  1. filterEmployees(String firstName, String lastName) custom method from Application Module implementation class
  2. Simple Commit action
In both methods I'm using Thread.sleep(5000) in order to make those operations artificially longer. filterEmloyees custom method code:


Here is the code from Backing bean, where Glasspane is launched and closed:


There are 3 additions comparing to original Frank Nimphius article:
  1. In onAction(ActionEvent actionEvent) method, I'm storing Id of button component that currently activates Glasspane. I'm doing this, in order to know what logic should I invoke in queryToLaunch(ClientEvent evt) method.
  2. When Glasspane component is activated, it calls back queryToLaunch(ClientEvent evt) method. In this method I'm accessing stored variable with currently pressed button Id and invoking appropriate functionality.
  3. In order to present visual changes when operation is finished, I'm calling refreshCurrentPage() method that is doing refresh of the current page:


When I'm running this application and doing Search operation, Glasspane appears and not allows to do any changes until operation is not finished:


After operation is finished and result is returned, Glasspane disappears and user can continue his/her work:


Same applies for Save button, during Commit operation screen is blocked and user can relax until operation will be done and Glasspane will disappear :)


Additionally, in ADF Faces RC its possible to use Blocking=True property for buttons. However in most cases its not useful, since user still can do changes on the screen.

Useful Update:

While integrating Glass Pane solution into our project, JDeveloper/ADF developer have found nice improvement. Instead of using refreshCurrentPage() method you can set PartialTriggers property for af:form tag and indicate dependency with Glass Pane popup (for example, in my sample application it will be - af:form partialtriggers="gp:busyPopup"). With this setting, page content is refreshed after popup is closed, without rerendering full page.

12 comments:

Muhammed Soyer said...

Hi Andrejus,
I can't compile your project , I am getting the below error, should I do something else to make it work.

Error: java.lang.NoClassDefFoundError: oracle/adfinternal/view/faces/taglib/region/RichDeclarativeComponentTag

Thanks

Andrej Baranovskij said...

Hi,

I have tested, it compiles well in my JDeveloper TP4. However, little later I will try to compile the same application in completely fresh JDeveloper, on my Virtual machine. Will post update.

Thanks,
Andrejus

Andrej Baranovskij said...

Hi,

I have tested on my VM with fresh JDeveloper 11g TP4 - application compiles and is running. I only was needed to add GlassPane.jar library to the project (as described in blog post).

Have you compiled it also?

Thanks,
Andrejus

gareth said...

I am getting the same compilation errors. I tested Frank Nimphius example but Im getting the same.

Andrej Baranovskij said...

Well, it happens ;)

Try to reproduce described steps yourself and to build own application.

Andrejus

Anonymous said...

I was looking for same functionality in ADF Faces non RC (Jdev 10g). Is it possible? If yes could you post something on that.

Andrej Baranovskij said...

Hi,

I dont think its easy to develop same functionality in 10g, since there is no Modal Popup component.

Regards,
Andrej

Nattu said...

Hello Andrejus,

I have a requirement, where, I can enter an email id into a text box, and when I click on add, it temporarily adds into an adf table on the same page. Also, I have a search icon next to textbox, on click of which, opens a search window as a popup. I enter search criteria and hit search button, I lists the users. I can select multiple users and click on 'Done' button. This should add the selected list of users to the parent page's table.

Can you please point to some examples that address these ? Even those examples that would address parts of these requirements would be interesting to me.

Thanks in advance.
Best Regards,
Nataraja.

Nattu said...

Hello Andrejus,

I am able to implement a solution for my requirement stated above. I managed the lifecycle of the list across the pages, and thank you, that I referred to your other blog on af:tableSelectMany, which gave invaluable inputs.

Best Regards,
nattu

Unknown said...

Hello Andrejus,

I'm trying to run your example inside a region with page fragments. But the glasspane is not launched. If i call my region from a jspx and i include the glasspane in that page, the panel is launched but is generating a null pointer error, because can't call to the region action.

Is possible do it???

I mean, call a glasspane inside a region with page fragments?

Thanx!

Unknown said...

Hi, Andrejus

Please, post a link to download the glasspane.jar. The link of frank nimphius, doesn't work anymore.

thk, y great blog...is such a useful

Srikanth said...

Hi Andrejus,

This sample is good.
I have one requirement, may be you can suggest me.

Open a popup (modal window) on a drag and drop operation between a table row and tree node.
Drag and drop is working fine, but need to show a popup window once dropEvent is started and close on completion.

Thanks,
Srikanth