Showing posts with label JHeadstart. Show all posts
Showing posts with label JHeadstart. Show all posts

Friday, 16 January 2009

Change a JHeadstart Workspace for another Jdeveloper Setup on Windows

Aonther problem I ran into in my latest JHeadstart project was that I'm using Linux on my laptop. So all the paths to libraries in my JDeveloper environment are following my setup under Linux. All of my co-workers on the project use Windows. I know, I said it earlier, I'm somewhat stubborn in this.

In the JHeadstart developers guide is stated that in a multi-developer-JHeadstart-project you should ensure that all the developers have the same Developer setup. In my case I turned out to be the only developer on this sub-project. But leaving the project others should be able to go further with it.

So I started my Windows Virtual Machine and took the time to setup a JDeveloper, Tortoise SVN client, download the Working copy of the workspace from SVN. That took me most of the time. Changing the workspace then was done in about a quarter.

JDeveloper Startup Path

JHeadstart and JDeveloper have absolute paths to libraries in the projects. It turns out to be quite handy to have all team members the same path to the libraries (as stated in the JHeartart Developers Guide). To enable that without the need to have each member physically install JDeveloper and the workingcopy of SVN in to the same directory, I crated a batch-file that creates two drives that map to the physical location.

I named the file drives.bat. It sets the s: drive to the folder that contains the trunk folder of your working copy and the w: drive to the home directory of jdeveloper (the root folder that contains the jdeveloper.exe):
subst s: e:\svn
subst w: e:\oracle\product\jdeveloper

Create a shortcut to the jdeveloper.exe on w:\ and start jDeveloper from that shortcut.
Install JHeadstart if not done allready:
In Jdeveloper goto Help=>Check for upates
Click next and choose install from local file.
Choose JHS10.1.3.3.85-INSTALL.ZIP and finisch the wizard.

Edit custom library
I used BPEL libraries because I needed to kickstart a BPEL process from a button in one of the screens. This library turned invalid since it could not find the jar-files following the original paths.
In Model Project properties goto libraries. Edit your custom OraBPEL Library. In my case I added the entries:
  • W:\integration\lib\orabpel-boot.jar
  • W:\integration\lib\orabpel-common.jar
  • W:\integration\lib\orabpel-thirdparty.jar
  • W:\integration\lib\orabpel.jar
  • W:\j2ee\home\lib\ejb.jar
  • W:\j2ee\home\oc4jclient.jar
Rebuild the Application
Right click on the ViewController project and run Jheadstart Application Generator (JAG). The JAG will change the paths to the JHeadstart libraries according to the startup path of Jdeveloper.

Recompile the Model and the ViewController project.

This ensures you that the changes are applied correctly and the code compiles correctly. Now you can deploy it to your App-server and you should be able to run it using the Embedded OC4J server.

Run the ViewController project
If you add an appropriate ConnectionPool and DataSource in the Embedded OC4J Server (You can do that via Tools => Embedded OC4J Preferences) then you’ll be able to run the SchedulerUI in the Embedded OC4J. If you do so then you're sure the workspace is correct again.

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).

Friday, 28 November 2008

Home page in a JHeadstart application

This week I finished a JHeadstart generated application. Indeed I found that using JHeadstart, espessially because of the Velocity Templating framework, you get about the same productivity of Oracle Designer.

When you generate an application using JHeadstart, it generates also a Home.jspx for you. If you use this Home.jspx as your landing page (because after logging in by default you "land" on this page) you find that it lacks a menu. And maybe you want some other elements on this page. Of course you can edit the generated Home.jspx, adding the menu-facet and the other elements. But I found that sometimes JHeadstart regenerates the Home page.
If you use Subversion (or another version control system) and had committed your Homepage then you can reset your Home page back from your repository. But certainly I forget this 3 out of 4 times.

So I thought: lets generate the home page together with the other screens.

To do that you have to create another group in the application service with the JHeadstart Application Definition Editor. Call it the Home group.
Uncheck the 'Bound to Model Data collection'. Of course you do not have to choose a Data Collection.

As a layout style choose: Form.
Set the search settings both on false.
As tab-name I would choose "Home".
For a display title you can choose: "Welcome #{jhsUser!=null ? jhsUser.displayName : facesContext.externalContext.userPrincipal.name} to the Service Oriented Scheduler Maintenance Application!". In fact I copied this from the original generated home page. Of course I gave onather application name (it used to be "JHeadstart demo application").

Under Operations uncheck every DML operation.

Since there is already a "Home" button in the Global Menu, I do not want to have the Home page in the application menu. So I unchecked "Add Menu entry for this Group" under Customization Settings.

For a Group it is mandatory to have a Descriptor Item. But I did not want any items on my page. So what I did was to create one item, called "Home" (or what ever you like).


Uncheck "Bound to Model attribute?".
As a Java Type, I choose "String" (but that does not do anything) and as a display type "Hidden". Furthermore I set the Display properties all on False, and unchecked the Search options. But since I had a hidden field, these options might do nothing. I did not check.

Now if I did not forget to mention anything, the home page is generated for you, as you like, with the proper menu. You can adapt it to your wishes by adding other elements as Items (like an image for instance).

And here is my Do It Yourself-Home-page: