Hi can you explain how and when to use multiple datasources defined against the the definition.

My issue as follows. I have a contact screen which uses datasource contact1. The panel with the fields I want to use in another "screen" as well. However the context is slightly different. In the primary case the contact screen is the standalone version. In the other case the contact screen is used to drive a master-detail. No I can define in the datasource the current row changed event. However when I use the screen in standalone mode I do not need to fetch details. Somehow I need to execute my populateDetail procedure only when I am in the master-detail and not in the standalone version. How can I best accomplish this. Defining datasource2 is not helping as all my pl/sql code references datasource1 as well as my single rowedit screen and grid of course. I guess I can use a session variable when in one or the other mode and execute the populate detail depending on the value of that session variable.

asked 16 Mar '14, 00:45

Raymond's gravatar image

accept rate: 0%

Hi Raymond,

Concerning your issue, if your master-details screen has the master contacts as a grid, i would use the selectionChanged event on the grid to execute your populateDetail procedure.

If your master-detail screen has the master contact as a single-record form as well, then you could do it by setting a session variable and check it in the populateDetail procedure, or you use the api_application.getclientevent() API. This API let's you check where the event was triggered by the user, and the return values will let you check the object type and panel.componentname.
api_application.getevent() is another event API, that let's you evaluate the application event itself and where it was triggered, like the current_row_changed event on the datasource. Just play around with these two API's and you will get the difference. These API's are a great tool to create generic code.

One remark on the use of multiple datasources defined against the same datasource definition:
there is no single definite answer to that question. It depends a lot on the structure and UI of your application, but also on your personal preferences.
I personally try to avoid to have different screens using the same (editable) datasource. I will give some examples of issues that will occur:

  • say you have an interface whee you can have multiple screens opened at the same time (or like a multi tab interface like i have). You open screen 1, and edit a record, but not save it yet. Then you open screen 2 (based on the same datasource), but you already have the first form opened with the same datasource with unsaved changes (dirty)... what do you do?
  • same issue having both forms open, change on screen 1 and change current record in screen 2.
  • also changing currect record on screen 1 will also change current record on screen 2. What if you specifically looked at a record on screen 1 and you would like to look at another record on screen 2..

Working with the same datasource in multiple screens at the same time is something to avoid in my opinion, so in these cases i create a second datasource or datasource definition.

There are lot's of more use cases for having multiple datasources on a single datasource definition, but this post will get way too big to list them all ;-)



answered 16 Mar '14, 07:18

Michiel%20A's gravatar image

Michiel A
accept rate: 13%

Yes that makes sense. My issue is I have these two panels, one grid the other is the single row edit screen. They are used in 2 or 3 places in the application. If I read you correct you suggest to copy the panels and adjust the datasource in the grid and fields in the single row screen so they all have their own datasource.


answered 16 Mar '14, 07:33

Raymond's gravatar image

accept rate: 0%

That would then mean that I need to copy the package as well.

(16 Mar '14, 07:35) Raymond

If the single record edit screen is always called from the master multi record panel (like doubleclick the master record to edit the record in a dialog), then it is easier to use the same datasource for these 2 panels.
If you have this set of panels on multiple places, then you could just use the same package and use the datasource name as variable.

(16 Mar '14, 08:56) Michiel A

Ok but I do have to duplicate the "panel set" for use in other places correct?

(16 Mar '14, 09:17) Raymond

or is there a way to use the same panels but change the datasource at runtime?

(16 Mar '14, 09:18) Raymond

if the 'panel set' could be active in your application at two places at the same time, i would copy them. Changing datasource at runtime is not possible.

(16 Mar '14, 09:36) Michiel A

thanks it is all clear now.

(16 Mar '14, 09:38) Raymond
showing 5 of 6 show 1 more comments

The only issue I found with the selectionChanged event on the grid to execute populateDetail procedure is that when you enter the screen the details for the first row are not fetched (assuming you use Query On Initilase). You need to handle that explicitly. Using the current row changed event is slightly more convenient. Does it boil down to personal preferences or are there specific reasons why your suggestion is preferable.


answered 16 Mar '14, 18:04

Raymond's gravatar image

accept rate: 0%

the reason i advised to use selectionChanged event on grid is to solve your issue that you had with two panels on the same datasource where one (the grid) had to query details and the other one not. Using the current row changed event wont solve it since it triggers on both screens, that's why my advice to use the grid selectionChanged for this particular case. Normally you would use the datasource current row changed event.

(17 Mar '14, 03:40) Michiel A

I followed your advise and duplicated my two panels and defined a second datasource for the second set. I modified the package to deal with both sets of panels with the use of api_application.getclientevent() and api_application.getevent(). Great pointers and everything is now coming together nicely.

(17 Mar '14, 07:16) Raymond
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 16 Mar '14, 00:45

Seen: 2,592 times

Last updated: 17 Mar '14, 07:16

© Copyright Gerger 2017