Wednesday, March 10, 2010

A Reader Asks - How To Pass Table Export Id Into ADF 11g Declarative Component

"I'm trying to use ExportCollectionActionListener inside Declarative Component, but I can't pass table export Id correctly - it gives error, Id is not found. Is it possible to make it work?"

Yes, it is. Download sample application - DCLibExport.zip. This archive contains two JDeveloper 11g applications - Declarative Component (ExportToolbarLib) and consuming application (EmployeesExport). I will not talk about Declarative Components in this post, you can read more about them from previous post.

Declarative Component example is really simple, it contains one attribute - exportId. Such type of components are really useful for proper application design and architecture, it allows to achieve proper reusability - instead of declaring Export buttons for each table, we are doing it only once:


And one button with ExportCollectionActionListener assigned, this will allow to export table data to Excel format automatically:


Important thing to mention - ExportCollectionActionListener gets ExportedId property value from Declarative Component attribute:


This means, we will be able to provide table Id value directly from consuming page and reuse Declarative Component in many pages.

Consuming application declares Tag library for Declarative Component - ExportToolbar:


Library is available in Component Palette:


Consuming page structure defines three main elements: data table, panel collection and export toolbar (our Declarative Component):


Here is main question now - how to wire together Export listener from Declarative Component and table in consuming page. The main trick - we should declare complete path and pass it through ExportId attribute. We should specify ExportToolbar Id (et1), enter into this component, and reference Panel Collection (pc1) from there. Finally, we need to access table component (t1) itself. Expression language for this case: #{et1::pc1:t1}:


On runtime we can see Export button from Declarative Component and ADF table with data:


Export works successfully:

6 comments:

Martin said...

Hi,

good example, but it is possible to get the "RichTable" in the declarative component (dc) by passing only the table-id into the dc?

I try to create a "Clear-Table-Filter-Button" based on the steve muench code "146. Programmatically Manipulating a Table's QBE Filter Fields". I set the RichTable as a dc-attribute, but so I must bind the table in a manged bean for every use.

I try to find the RichTable in der dc by passing only the table-id (like in the exportCollectionListener) but without success.

Perhaps you have an idea? ;)

Kind regards,
Martin

Andrej Baranovskij said...

Hi Martin,

I was trying same things you are describing. But, to say truth, I didn't found effective working solution. From my perspective, its good enough to pass complete table path through ID.

Its similar when you are defining Partial Trigger dependency - also path to ID is included.

Thanks,
Andrejus

i-Felix Andrew said...

Hi Its nice example,
But I want to select only few rows from the table which is in display.
I should not use the view->Cloums using the PanelCollection,

One more qusetion can we export to excel programatically.

Thanks in Advance
Felix

i-Felix Andrew said...

Hi,
Its good and simple example.
But my problem is can we export selected rows from table not using panelcollections' view-->Collumns.
One more question can we programatically export a table into excel format.

Regards,
Felix

Anonymous said...

Hi.
What would be the expression if the component declarative was on the toolbar facet of panelcollection?

YKR said...

Hi,

Nice one, I follow this one i am using jdev 11.1.2.3 version and i create user defined component,But i got problem in ExportID expression builder how to get this ID in expression builder..