Wednesday, June 06, 2007

Reuse Oracle APEX Components

Not sure if you already saw this feature in Oracle Application Express?
"Export Application Components" (in Application Builder - Shared Components)


When I first saw it, I thought: "cool", I can export my Shared Components (or Reusable Components) and import it again in another project. But that's not completely true...

On the left, you see you can export almost every APEX component. On the right side you see the import functionality (Application Builder - Import).


So what's the problem?

Same Workspace - Same Application
There's no problem when you stay in your current application. You can nicely export and import components.

Same Workspace - Different Application
If you try to import the component in another application, you get an error (see below).
But isn't that strange? You can create a new item based on a copy of an existing item of another application. (This is also a workaround, although you would need to create a new item for every component you want to copy)

Different Workspace - Different Application
If you try to import the component in another application of another workspace, you get the same error (see below). There's no workaround for this, except to export the whole application from one workspace, import it again in the other workspace and create components as copies of the components of the imported application.

Life would be a lot easier to have the export/import functionality as it would allow to copy (and subscribe) more components at once.

The error you get when you're not in the same application while importing:

I like the feature, don't get me wrong, and I understand the difficulties of doing it (changing id's). Nevertheless I hope in APEX 3.1 or 4.0 it will be extended so it also works cross workspace/application.

In the meanwhile, if you want to reuse components, make a "Shared Application" and when you start a new project import the entire application into your workspace (if it's cross workspace).

1 comment:

  1. Hi Dimitri!
    I ran through this export/import problem, and found out that if you change the application id or workspace id in the exported code, than you can import the exported components without error.
    Best,
    Bela

    ReplyDelete