Friday 16 January 2009

Multiple Descriptor items in JHeadstart

In the past I used develop using Designer. Although it's already years ago I have warm memories to the tool. In Designer you could mark table-columns as descriptor-items, if I recollect correctly. I can't remember how it's done exactly and since I have noa running Designer install anymore I can't check. But I know that it was a check box on the item. So you can have multiple.

Descriptor Items are used to generate a reference on a details page to denote for which parent you are editing details.

In JHeadstart I found that you can give up only one item as a descriptor item on the group. In my latest project I had to create a maintenance application on a datamodel that had a table where the columns on their own were not descriptive enough. You could argue that I had to introduce such an attribute. For example a name or code attribute that is unique. But functionally the table did not need to have one. But the entity related to another entity for which I generated a detailgroup. And on that page a reference to the 'non-descriptive' table-row was generated. on one of it's columns. Most of the rows had the same value on the column though. So I wanted to connect all the attributes, together with a lookup attribute from another table and have that as a descriptor.

Luckily the solution I used was easy. And maybe as a JavaADF-JHeadstart expert you'd not be surprised. But for those who struggle, here's how I did it.

First I adapted the ViewObject of the parent-entity.

If needed add extra entity objects for attributes you want to relate to in your descriptor items. In an entity Object in ADF-Business Components by default the complete entity name is used for used as a table-alias. I normally I don't care, but if I want to adapt the ViewObject I find that inconvenient. So I replaced them with table three-letter-shortages.

Then under the Attribute nodes, click on the New Attribute button (bottom right):

Then you get the following screen. Give the new attribute a name, check the box "Mapped to Column or SQL". Then you can give it an alias (the name the expression gets in the resulting SQL Statement". And give in an expression. I found it handy to first build up the sql statement with the particular expression in Pl/Sql developer and copy and paste it. Then I'm pretty shure it will work.

If you've done it correcly, following your needs, then the new attribute is found in the resulting SQL Statement:

You can adapt it by giving an order by and an extra where-clause-condition. But I found it also handy to copy and paste the complete sql statement and try it in Pl/Sql Developer. That prevents me from surprises later on.

Having done that, things are straight forward. Go to the JHeadstart Application Definition Editor. And on the parent group add the descriptor-attribute as an item. Set the Java-Datatype etc. correctly but make it hidden (make sure all the 'show-on'-checkboxes are unchecked). Although it's hidden I gave it a prompt. Just to recognise it directly when I stumble on it.

Then on the group-page you can set the descriptor-item selector on the particular item.

The solution is simple. But it would be handy to have checkboxes on the items so that you could just check every item you want to have in the descriptor... (going the Designer way).

No comments :