Monday, December 28, 2009

ADF 11g RC: Manipulating a components toolbar.

Last week I had a question regarding the Rich Text Editor in ADF 11g RC.

Is it possible to disable/enable or add/remove components form the rich text editor's toolbar? At first I didn't know the answer, but after some investigation it appears to be very simple.

The most important piece of the puzzle is to understand how the toolbar is constructed. According to the components documentation, the toolboxLayout property allows control over the layout of the toolbar. This is actually just an Array of Strings.

The built in strings the component recognizes are:
1) "all"
2) "font"
3) "history"
4) "color"
5) "formatAll"
6) "justify"
7) "list"
8) "indent"
9) "link"
10) "newline"
11) "stretch"

For more information on what these built in Strings do, refer to the online help of the component.

One of the options you have to change the toolbar is to bind the editor component to a backing bean. In this bean you can manipulate the list with the built in Strings.

Each of the entries in this select many checkbox correspondents with one of the properties in the toolbar.

Every time a checkbox is selected or deselected, the corresponding item in the toolbar will (dis-)appear. This happens because the autosubmit property of the checkbox is set to true, and in the toolbarItems() method, not only the list with selected checkboxes is updated, but also the bound richTextEditor is changed by calling its setToolboxLayout() method with the list of checked boxes as argument.

public void setToolbarItems(String[] toolbarItems) {
this.toolbarItems = toolbarItems;
for (int i = 0; i < toolbarItems.length; i++) {
toolbarItemMap.put(toolbarItems[i], Boolean.TRUE);

This results in a runtime changeable toolbar.

Note that with this knowledge we are also able to change the toolbar of a calendar component, because this toolbar consists of a set of built in Strings as well.
You can download a workspace with the toolbar functionality here.

Monday, November 30, 2009

JHeadstart 11g TP - Magic with Wizards

One of the main features in ADF 11g is the use of taskflows. There are different kinds of taskflows. One of these is a process train. A process train (the ADF name for wizard) can be used to guide the end user step by step through a rather difficult process. In this post I describe how you can use JHeadstart to generate the wizard for you.

The very difficult (duh) process in his case is the entry of a new employee. For that I need a three step wizard.

The first steps are the same as always. Create a new fusion wep application, create new Business Components from tables, and only pick the Departments and Employees, enable JHeadstart on the view controller project, and finally create a new service definition for the datacontrol (accept al the defaults).

According to JHeadstart help, to spread items of one group over multiple wizard pages, you should place the items in an item region and set the layout style of the regions container to "separatePages". Let's do that.

Create three item Regions under the Employees group. The first one will contain "Personal" items, the second one the "Financial" data, and the last one contains all the other data. Set the layout style for the regions container to "separate pages". Take a look at the image below for the details.
Drag all the items from the Employees group to the appropriate item groups.

Now prepare the employees group to be generated as a wizard. First of all set the layout style to form, and check the "Wizard Style Layout" checkbox. Searching in a wizard is a little bit strange so set both Advanced- and Quick search properties to "none". In the operations part uncheck the "Single Row Update- and Delete" boxes and set "Display New Row on Entry" to true. The application Definition of the wizard should look something like this:

Finally generate the application and run it.
Notice how you can step through the wizard using the buttons and the train stations.

Fill out the fields in all three steps of the wizard and click finish.

If the entered data is correct JHeadstart will show the transaction completed message.

This was a very simple wizard. More complex magic can be done with wizards, but for now this will do.

Saturday, October 31, 2009

JHeadstart 11g TP - Master Detail and Overflow

I have been working with JHeadstart 11g technical preview a lot lately. I want to share some of the features with you in a series of articles. Luckily Oracle allowed me to blog about the JHeadstart 11g technical preview. It is a technical preview, but is already pretty mature. Let's start with some basic generation. In this blog I describe how easy it is to create a layout in which a master-detail relation is generated into a form - table layout. I use the DEPT-EMP relation we probably all know.

In the model project just create new Business Components from tables, and only pick the Departments and Employees. In the JHeadstart Application Definition Editor, you can now create a new Group, based on the Departments collection. Also create a detail Group based on the Employees group. It should look somewhat like this.

Before you generate, make sure that the layout style for the departments group is form. Also set layout style for employees to table, put this group on the same page, and below its parent. That sounds like a lot of laying out, but you can set all of this in the Group Layout properties of the Employees group.

Now run the generator, start the application and be amazed.........

And to make it all better, the simple and advanced search for the departments is generated for you as well.

Let's take this one step further. The Employees table contains a little bit too much columns. We will put these in a synchronized overflow area. Create two new item regions within the employees group. Call one "contact" and call the other one "financial".

For all items (except First name, Last name and Hiredate) in the Employees group set display in form and table to false. Now you can pick some items from the Employees group and drag them into these new regions. Now there is just one change to make before we can generate our new layout. On the Employees group you'll have to set the "Table overflow style". For now just pick "below with splitter".

Generate the application and run it.

Play around with the splitter to get all data in view, or even click on the splitter to hide the whole table. Pretty cool isn't it ! And how much code was involved ?

Actually this is not my prefered layout. It would be better to display these very few items to the right of the table. To achieve this put both item regions in a region container. By doing that we can use an accordion layout. This will enable the user to show/hide the details. Just create a new region container, set its layout style to accordion. Call the region "Details" or any other name you like, and drag the two groups we created earlier, into this new group. Change the layout style of the Employees group, by setting its "table overflow style" to "Right".

This should do the trick. Regenerate and run. Notice how the details are now displayed to the right of the table.

So in just very little time we created a master-detail page with an overflow area rendered in an accordion. All of the data is kept in sync with each other, and we have a cool layout.

For today that's all. Next time more on generating ADF applications with JHeadstart 11g.

Tuesday, September 29, 2009

Back again

Almost two years ago I published my last post here. What happened in these two years? Did I quit developing ADF applications? Nope! I've been very busy on my new job. I started at AMIS Technology as an ADF expert and I've also been working with JHeadstart. It still is a great job, so that's not the reason that I am back here. It's just that it would be a shame if my own weblog should die........... That's why I'm back again.

Here's what I published and presented the last two years:

Presentation and workshop on ADF:

Publications on ADF:
  • January 2009: OGH-visie: ADF 11g (in Dutch). OGH-visie is the magazine of the Dutch Oracle user group.

My next post should arrive within the next two years ;-)