Recent

Author Topic: Standard Dataset Actions  (Read 21769 times)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Standard Dataset Actions
« Reply #15 on: July 18, 2014, 04:20:03 pm »
Hi,

The modifications in DBActns had no effect.

So, I will use normal actions, with an OnExecute firing the respective buttons of a DBNavigator placed in the main form. This is the only way to offer the user a GUI, a menu that can be read by a screen reader and a set of shortcuts to work with the databse.

I find almost impossible that it had no effect. It is more likely that the modified dbActns did not linked in and the old one was used. I haven't found the time to test them my self so far because to test them properly I need to create a 3rd party package with new actions different names build it and install it on the IDE etc etc, to avoid linking problems.

In any case I'll do something along those lines and get back to you.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: Standard Dataset Actions
« Reply #16 on: July 18, 2014, 04:36:36 pm »
The modifications in DBActns had no effect.
Did you recompile the LCL ?
( I think it's in Tools / Configure "Rebuild Lazarus". I'm not sure if there is an easier way. Also newby here ;))

It did the trick for me and it works now.
(Not sure yet what negative effects this might have, if there are any)

I haven't looked at the patch supplied on the bug tracker so I can't be sure what it changes and if it will do the job yet and I must find the bug reports to add a comment there too.
I think the patch Luigi did is not the preferred one, as far as i can see.
(He doesn't even mention anything in the bug-report about what the patch actually does)
Maybe it works but it uses the Data Aware controls in dbctrls.pp to update the actions (which is wrong, i think, because there might not even be any data aware controls on your form and then the actions should still work).

(Luigi's original bugreport #25441)
(What i believe is his suggested solution #25988, but can't be sure because of missing information)
« Last Edit: July 18, 2014, 04:48:13 pm by rvk »

Walmir

  • New Member
  • *
  • Posts: 39
Re: Standard Dataset Actions
« Reply #17 on: July 18, 2014, 09:36:23 pm »
I finally discovered why it was not working here after DBActns modification.
The cuprit is TDINoteBook. When I open a form inside it, the standard DB actions stop working and I can't even set  the DataSource of a DBNavigator in the main form at run time.
When I open the form outside the TDINoteBook, all is correct.


Walmir

  • New Member
  • *
  • Posts: 39
Re: Standard Dataset Actions
« Reply #18 on: July 21, 2014, 06:52:07 pm »
Another discovery...
The TDINoteBook behavior is not unique.
I tried opening a form inside a TabSheet of a PageControl and the problem is the same.
Only when I open the form wit a simple Show the database standard actions work corrrectly.
I also noted that I cannot change in code the DataSource of a DBNavigator placed in the main form from a secondary formwhen this form is inside a TabSheet.
So, the Tabbed Document Interfaceof my application will not work with the standar DB actionhs and the alternative - using common actions with onExecute events that fire the DBNavigator respective BtnClick - also don't work because I can't change the DBNavigator data source at run time.
What can I do?

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Standard Dataset Actions
« Reply #19 on: July 21, 2014, 06:58:17 pm »
I think that you are hitting the following bug. http://bugs.freepascal.org/view.php?id=24793
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Standard Dataset Actions
« Reply #20 on: July 24, 2014, 08:01:12 pm »
If you download the code from the bug report I have posted you will find out that by re linking through code at runtime the actions work properly it probably is only a problem of streaming.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: Standard Dataset Actions
« Reply #21 on: July 25, 2014, 04:21:32 pm »
If I open the form inside a TabSheet, the actions don't work. As I also mentioned, this behavior is shared by a DBNavigator placed in the main form - and I can't modify its DataSource through code.
For me the Datasetactions work even when i have absolutely no data-aware components in my whole project.
(So they don't seem to be depended on any data-aware components, as it should be)

Could you provide a simple sample-project where you show exactly what going wrong?

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Standard Dataset Actions
« Reply #22 on: July 25, 2014, 04:36:48 pm »
If you download the code from the bug report I have posted you will find out that by re linking through code at runtime the actions work properly it probably is only a problem of streaming.

If you are referring to the modifications in DBActns

the bug report at http://bugs.freepascal.org/view.php?id=24793 has some code attached it shows that if you re link the actions at runtime they work as expected.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Walmir

  • New Member
  • *
  • Posts: 39
Re: Standard Dataset Actions
« Reply #23 on: August 07, 2014, 02:27:56 pm »
,.. I got the time to test with SQLdb and found that the standard DB actions don't work too with it.
But with MemDataSet all is ok.
Again, I have to say that  in this manner, standard DB actions are useless in a real world application, with the actions in the main form, the data controls in a data module and the data aware controls in secondary forms opened in tabsheets.

Can anyone confirm his behavior?

rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: Standard Dataset Actions
« Reply #24 on: August 07, 2014, 04:50:08 pm »
... with the actions in the main form, the data controls in a data module and the data aware controls in secondary forms opened in tabsheets.
With the changes from this post they work perfectly here with the situation you described (even with a form opened in a TTabSheet of a TPageControl).

If it's not working for you the only thing i could suggest is making a small sample-app (where your problem presents itself) and posting that project here.

rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: Standard Dataset Actions
« Reply #25 on: August 09, 2014, 01:32:12 am »
For the problem with the dbnavigator i answered here:
http://forum.lazarus.freepascal.org/index.php/topic,25370.msg154465.html#msg154465

For the problem with you datasetaction....
Where do you assign the datasource to the datasetactions??

Shouldn't you also do this in all the FormActivate's?
Code: [Select]
  frmMain.DataSetNext1.DataSource:=dmData.dsCli;
  frmMain.DataSetCancel1.DataSource:=dmData.dsCli;
  frmMain.DataSetDelete1.DataSource:=dmData.dsCli;
  frmMain.DataSetEdit1.DataSource:=dmData.dsCli;
  frmMain.DataSetFirst1.DataSource:=dmData.dsCli;
  frmMain.DataSetInsert1.DataSource:=dmData.dsCli;
  frmMain.DataSetLast1.DataSource:=dmData.dsCli;
  frmMain.DataSetNext1.DataSource:=dmData.dsCli;
  frmMain.DataSetPost1.DataSource:=dmData.dsCli;
  frmMain.DataSetPrior1.DataSource:=dmData.dsCli;

B.T.W. it would be better to loop through all the action from the TActionList and check if it is inherited from TDataSetAction. If it is then assign the datasource.

Like this (in all your forms):
Code: [Select]
procedure TfrmCadCli.FormActivate(Sender: TObject);
var
  i: Integer;
begin
  frmMain.dbnNav.DataSource:=dmData.dsCli;
  for i := 0 to frmMain.aclActions.ActionCount - 1 do
  begin
    if frmMain.aclActions.Actions[i].InheritsFrom(TDataSetAction) then
      TDataSetAction(frmMain.aclActions.Actions[i]).DataSource:=dmData.dsCli;
  end;
end;

Yet another way would be to do it in the mainform in the onpagechange-event (i showed in the other topic for the OnActivate). You can loop there through all the actions and set the datasource to the same as the dbnavigator:
Code: [Select]
procedure TfrmMain.tdiAbasChange(Sender: TObject);
var
  i: Integer;
begin
  if tdiAbas.ActivePage is TTDIPage then
    if Assigned(TTDIPage(tdiAbas.ActivePage).FormInPage) then
      if Assigned(TTDIPage(tdiAbas.ActivePage).FormInPage.OnActivate) then
      begin
        TTDIPage(tdiAbas.ActivePage).FormInPage.OnActivate(nil);
        for i := 0 to frmMain.aclActions.ActionCount - 1 do
        begin
          if frmMain.aclActions.Actions[i].InheritsFrom(TDataSetAction) then
            TDataSetAction(frmMain.aclActions.Actions[i]).DataSource:=dbnNav.DataSource;
        end;
      end;
end;

Choose one of these last two methods.

Walmir

  • New Member
  • *
  • Posts: 39
Re: Standard Dataset Actions
« Reply #26 on: August 09, 2014, 06:20:56 pm »
Rvk,
In Delphi I did never set the DataSource property of the DB standard actions and all worked fine... In some way it autommatically detected the DataSource property of the controls in tthe MDI child forms.
So, by what you are showing me, this is not considered to be a bug in Lazarus.
Thank you for the help.

rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: Standard Dataset Actions
« Reply #27 on: August 09, 2014, 06:30:24 pm »
In Delphi I did never set the DataSource property of the DB standard actions and all worked fine... In some way it autommatically detected the DataSource property of the controls in tthe MDI child forms.
I'm not sure if the DatasetAction automatically takes the datasource in Delphi. But you have many Datasources so i can't imagine that in this case you wouldn't have to do anything in Delphi. What datasource would Delphi connect the Datasetaction to? Did it automatically switch when choosing another active form? Maybe this is the behavior if there is only one datasource... but with multiple datasources i almost can't believe Delphi would do this automatically.

But at least the way i showed you, you're sure the correct datasource is set for the actions.



taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Standard Dataset Actions
« Reply #28 on: August 09, 2014, 06:41:31 pm »
I'm not sure if the DatasetAction automatically takes the datasource in Delphi. But you have many Datasources so i can't imagine that in this case you wouldn't have to do anything in Delphi. What datasource would Delphi connect the Datasetaction to? Did it automatically switch when choosing another active form? Maybe this is the behavior if there is only one datasource... but with multiple datasources i almost can't believe Delphi would do this automatically.

But at least the way i showed you, you're sure the correct datasource is set for the actions.

I'm assuming that in delphi the focused data aware control is used to determine which datasource is used. Thinking it this way it seems possible to accomplish and a pain in the behind to implement since there is no interface that all the data aware controls support that can answer the datasource question and there is no single component in the hierarchy that implements datasource support that can be used to abstract the access.

I say "I assume" because I can't remember by heard and I don't have access to delphi at this time to check.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Walmir

  • New Member
  • *
  • Posts: 39
Re: Standard Dataset Actions
« Reply #29 on: August 11, 2014, 07:35:46 pm »
I'm having these "problems" with DB standard actions exacttly because I assumed Lazarus will have the same behavior as Delphi.
The application I am porting use this feature extensively and nowhere I needed to set the DataSource of the DB actions.
I don't know how Delphi did this "magic", but I can assure you it worked and it is one that I'll really miss in Lazarus.

 

TinyPortal © 2005-2018