Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IsPostBack Error
#1
I just solved what I hope is the last issue in the conversion of my massive IW 14 app to IW 15.

I had one screen where I allow the user to set a wide array of filters, then I build the WHERE clause and open the query (FireDAC) in a regular Click event on a TIWButton.

It worked great in IW 14. But in IW 15 I would set the parameters, click Search -- and nothing would show up. I quickly learned that if I clicked the button twice, data would show up.

Very odd.

Just today I tracked it down to the code in OnRender that checks for (not IsPostBack) before initializing the adapter for my ORM. Somehow after a click IsPostBack is NOT True on the first PostBack. This led to my adapter being created again, overwriting the first one and closing my query.

I changed my code to use IsFirstRequest, and it works fine now.

But I think y'all oughtta take a look at IsPostBack in IW 15 in Delphi 10 Seattle -- something's wrong.
Reply
#2
Hi Loren,

I'll have a look and let you know. It is odd indeed.
Reply
#3
I couldn't recreate this error. I created a simple application, one button. Assigned an OnClick event. During OnClick execution, IsPostBack is True (it was false before receiving the request). Looks correct to me.
Reply
#4
(09-27-2018, 09:26 AM)Alexandre Machado Wrote: I couldn't recreate this error. I created a simple application, one button. Assigned an OnClick event. During OnClick execution, IsPostBack is True (it was false before receiving the request). Looks correct to me.

All I can tell you is that it is totally broken in my large IW app that was started in 14 and converted to 15 two weeks ago. It was causing big memory leaks.

Did you try with an inherited form on Delphi 10 Seattle?
Reply
#5
How do you create and show this form? Is it handled by some content handler or....?

IsPostBack logic is very simple and hasn't changed since first implemented. It will evaluate to True if form execution count is greater than 1 and request is a POST request (this differs from ASP.NET IsPostBack which might be true even if the request is a GET).
Reply
#6
(09-28-2018, 09:52 AM)Alexandre Machado Wrote: How do you create and show this form? Is it handled by some content handler or....?

IsPostBack logic is very simple and hasn't changed since first implemented. It will evaluate to True if form execution count is greater than 1 and request is a POST request (this differs from ASP.NET IsPostBack which might be true even if the request is a GET).

Here's how I create and show this form:

var
   Mgr: TpgSwovoMgr;
begin
   Mgr := TpgSwovoMgr.Create(WebApplication);
   if cbLang.ItemIndex <> -1 then
   begin
      Mgr.gInitialChronosID := Integer(cbLang.Items.Objects[cbLang.ItemIndex]);
   end;
   Mgr.Show;
end;

Then in the form itself for OnRender I have:

procedure TpgSwovoMgr.IWAppFormRender(Sender: TObject);
var
   i: Integer;
begin
   inherited;

   if not IsPostBack then
   begin
      DM := LockDataModule;
      ObjMgr := TObjectManager.Create(TFireDACConnectionAdapter.Create(DM.MainCx, False));

      // some other stuff
   end;
end;
Reply
#7
Hi Loren,

I finally found the issue. This has been fixed in our code base and it will be available soon.

IW 15 skips some unnecessary steps when form is rendered for the first time, which makes it faster, but also caused that issue.
Reply
#8
(10-01-2018, 11:32 PM)Alexandre Machado Wrote: Hi Loren,

I finally found the issue. This has been fixed in our code base and it will be available soon.

IW 15 skips some unnecessary steps when form is rendered for the first time, which makes it faster, but also caused that issue.

Very glad to help you find some issues and fix them Smile

I knew something was wrong when all of a sudden after the upgrade to 15 my Object Manager was getting created twice. I have already changed all my "not IsPostBack" to "IsFirstRequest". But 15 will still be important even after 17 is released, so it will be nice to have it fixed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)