Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: VMainForm var has disappeared in IV


This question is answered.


Permlink Replies: 9 - Last Post: Jul 8, 2016 1:43 AM Last Post By: Alexandre Machado
Gerald Clancy

Posts: 7
Registered: 1/4/02
VMainForm var has disappeared in IV  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 11, 2016 12:55 PM
Have migrated from D5 to XE2 and IW !V and find that the last variable, VMainForm, in this procedure has disappeared:

procedure TIWServerController.IWServerControllerBaseNewSession(ASession:
TIWApplication; var VMainForm: TIWAppForm);

Now shows as
procedure TIWServerController.IWServerControllerBaseNewSession(
ASession: TIWApplication);

How does one assign a form to the variable now? Or, do we now directly create the form?

Please advise.
Daniel Fields

Posts: 622
Registered: 11/29/04
Re: VMainForm var has disappeared in IV
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 11, 2016 3:18 PM   in response to: Gerald Clancy in response to: Gerald Clancy
You now have to use the ServerController.OnGetMainFormEvent. By default it goes to the MainForm of your application. You can use any logic that you were using in the OnBewSession event.

procedure TIWServerController.IWServerControllerBaseGetMainForm(var vMainForm: TIWBaseForm);
begin
  if (WebApplication.RunParams.Count >= 1) and (Lowercase(WebApplication.RunParams[0])='dbutils') then
    VMainForm := TFormDButils.Create(WebApplication);
end;
Gerald Clancy

Posts: 7
Registered: 1/4/02
Re: VMainForm var has disappeared in IV  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 11, 2016 4:00 PM   in response to: Daniel Fields in response to: Daniel Fields
Daniel Fields wrote:
You now have to use the ServerController.OnGetMainFormEvent. By default it goes to the MainForm of your application. You can use any logic that you were using in the OnBewSession event.

procedure TIWServerController.IWServerControllerBaseGetMainForm(var vMainForm: TIWBaseForm);
begin
  if (WebApplication.RunParams.Count >= 1) and (Lowercase(WebApplication.RunParams[0])='dbutils') then
    VMainForm := TFormDButils.Create(WebApplication);
end;

Thank you, Dan. Looks like I have to move some of my logic from "NewSession" to there as well. Appreciate the response, particularly with atozed.com down today.
Dan Barclay

Posts: 889
Registered: 11/9/03
Re: VMainForm var has disappeared in IV  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 11, 2016 5:29 PM   in response to: Daniel Fields in response to: Daniel Fields
Daniel Fields wrote:
You now have to use the ServerController.OnGetMainFormEvent. By default it goes to the MainForm of your application. You can use any logic that you were using in the OnBewSession event.

procedure TIWServerController.IWServerControllerBaseGetMainForm(var vMainForm: TIWBaseForm);
begin
  if (WebApplication.RunParams.Count >= 1) and (Lowercase(WebApplication.RunParams[0])='dbutils') then
    VMainForm := TFormDButils.Create(WebApplication);
end;

I can learn something here I think.

I've only been familiar with the IV version. What situations would I want to assign a main form? Currently I have the main form defined in the project. Is this to allow switching mainforms based on parameters or something?

Thanks,
Dan
Daniel Fields

Posts: 622
Registered: 11/29/04
Re: VMainForm var has disappeared in IV  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 11, 2016 6:25 PM   in response to: Dan Barclay in response to: Dan Barclay
That is exactly how I have been using it. I have also used it to support multiple interfaces from the same server, such as back offices for clients and staff. I was also using it to return status information, but have since switched those over to Custom Content Handlers.

In the example I posted the application takes me to a page that requires a login, and then allows access to some database maintenance utilities that I use for the system.
Gerald Clancy

Posts: 7
Registered: 1/4/02
Re: VMainForm var has disappeared in IV  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 11, 2016 9:56 PM   in response to: Dan Barclay in response to: Dan Barclay
Dan Barclay wrote:
Daniel Fields wrote:
You now have to use the ServerController.OnGetMainFormEvent. By default it goes to the MainForm of your application. You can use any logic that you were using in the OnBewSession event.

procedure TIWServerController.IWServerControllerBaseGetMainForm(var vMainForm: TIWBaseForm);
begin
  if (WebApplication.RunParams.Count >= 1) and (Lowercase(WebApplication.RunParams[0])='dbutils') then
    VMainForm := TFormDButils.Create(WebApplication);
end;

I can learn something here I think.

I've only been familiar with the IV version. What situations would I want to assign a main form? Currently I have the main form defined in the project. Is this to allow switching mainforms based on parameters or something?

Thanks,
Dan

For more than a decade (mostly D5) I used VMainForm to target either my main form or a login form if there aren't matching and correct cookies.Login would call the main form if the login is successful.

I've been struggling a bit rewriting this in XE2 tonight, though I finally have things restructured and working. The problem I found is that the GetMainForm event fires before the NewSession event which creates the UserSession, so there is no UserSession yet in the GetMainForm event. As a result I found that I had to move some logic from ServerController to the main form so that I had a UserSession established.

It would sure be nice to have updated Atozed documentation on the transition to version IV. I found references to a doc but their site is still down, first time I can ever remember it being down this long. Glad I'm not in their shoes tonight.
Dan Barclay

Posts: 889
Registered: 11/9/03
Re: VMainForm var has disappeared in IV  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 11, 2016 10:05 PM   in response to: Gerald Clancy in response to: Gerald Clancy
Gerald Clancy wrote:
Dan Barclay wrote:
Daniel Fields wrote:
You now have to use the ServerController.OnGetMainFormEvent. By default it goes to the MainForm of your application. You can use any logic that you were using in the OnBewSession event.

procedure TIWServerController.IWServerControllerBaseGetMainForm(var vMainForm: TIWBaseForm);
begin
  if (WebApplication.RunParams.Count >= 1) and (Lowercase(WebApplication.RunParams[0])='dbutils') then
    VMainForm := TFormDButils.Create(WebApplication);
end;

I can learn something here I think.

I've only been familiar with the IV version. What situations would I want to assign a main form? Currently I have the main form defined in the project. Is this to allow switching mainforms based on parameters or something?

Thanks,
Dan

For more than a decade (mostly D5) I used VMainForm to target either my main form or a login form if there aren't matching and correct cookies.Login would call the main form if the login is successful.

I've been struggling a bit rewriting this in XE2 tonight, though I finally have things restructured and working. The problem I found is that the GetMainForm event fires before the NewSession event which creates the UserSession, so there is no UserSession yet in the GetMainForm event. As a result I found that I had to move some logic from ServerController to the main form so that I had a UserSession established.

It would sure be nice to have updated Atozed documentation on the transition to version IV. I found references to a doc but their site is still down, first time I can ever remember it being down this long. Glad I'm not in their shoes tonight.

Intraweb is really great but. Documentation. Yea <g>

I'm sure you've already seen this. If not, when the atozed site comes back up have a look:
http://docs.atozed.com/docs.dll/development/Migrating%20to%20IntraWeb%20XIV.html

You can also check out the demos on codeplex.

Some of the newer features may offer better options for starting up. Dunno.

As to their site, they've had minor trouble before but not with their site per se. They had trouble in which some of us could not reach it, others could. ISP and routing issues. They'll figure it out, but they do provide good support here.

Dan
Daniel Fields

Posts: 622
Registered: 11/29/04
Re: VMainForm var has disappeared in IV  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 11, 2016 11:55 PM   in response to: Gerald Clancy in response to: Gerald Clancy
When I debug I get the IWServerControllerBaseNewSession(aSession: TIWApplication) first, and then IWServerControllerBaseGetMainForm(var vMainForm: TIWBaseForm).

Also, inside the GetMainForm event you can get to the UserSession through the WebApplication.Data.

procedure TIWServerController.IWServerControllerBaseGetMainForm(var vMainForm: TIWBaseForm);
begin
  if (WebApplication.RunParams.Count >= 1) and (Lowercase(WebApplication.RunParams[0])='dbutils') then
    VMainForm := TFormDButils.Create(WebApplication);
 
  with TIWUserSession(WebApplication.Data) do
  begin
    DoSomething;  //You can access anything in the UserSession because it has already been created.
  end;
end;
Gerald Clancy

Posts: 7
Registered: 1/4/02
Re: VMainForm var has disappeared in IV  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 7, 2016 11:43 AM   in response to: Daniel Fields in response to: Daniel Fields
Daniel Fields wrote:
When I debug I get the IWServerControllerBaseNewSession(aSession: TIWApplication) first, and then IWServerControllerBaseGetMainForm(var vMainForm: TIWBaseForm).

Also, inside the GetMainForm event you can get to the UserSession through the WebApplication.Data.

procedure TIWServerController.IWServerControllerBaseGetMainForm(var vMainForm: TIWBaseForm);
begin
  if (WebApplication.RunParams.Count >= 1) and (Lowercase(WebApplication.RunParams[0])='dbutils') then
    VMainForm := TFormDButils.Create(WebApplication);
 
  with TIWUserSession(WebApplication.Data) do
  begin
    DoSomething;  //You can access anything in the UserSession because it has already been created.
  end;
end;

In XE2 the GetMainForm event fires BEFORE the UserSession is created, so this won't work.

I've tried to examine the RunParams in this event but I've not found a way to do this. I really need to determine the calling device before presenting the first form (VMainForm), but there appears no way to do this anymore. Most frustrating.
Alexandre Machado

Posts: 1,754
Registered: 8/10/13
Re: VMainForm var has disappeared in IV  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 8, 2016 1:43 AM   in response to: Gerald Clancy in response to: Gerald Clancy
Gerald Clancy wrote:
Daniel Fields wrote:
When I debug I get the IWServerControllerBaseNewSession(aSession: TIWApplication) first, and then IWServerControllerBaseGetMainForm(var vMainForm: TIWBaseForm).

Also, inside the GetMainForm event you can get to the UserSession through the WebApplication.Data.

procedure TIWServerController.IWServerControllerBaseGetMainForm(var vMainForm: TIWBaseForm);
begin
  if (WebApplication.RunParams.Count >= 1) and (Lowercase(WebApplication.RunParams[0])='dbutils') then
    VMainForm := TFormDButils.Create(WebApplication);
 
  with TIWUserSession(WebApplication.Data) do
  begin
    DoSomething;  //You can access anything in the UserSession because it has already been created.
  end;
end;

In XE2 the GetMainForm event fires BEFORE the UserSession is created, so this won't work.

I've tried to examine the RunParams in this event but I've not found a way to do this. I really need to determine the calling device before presenting the first form (VMainForm), but there appears no way to do this anymore. Most frustrating.

Which version are you using?

I'm sure that this is not how it should work. I've just tested and this is the sequence of events in ServerController, using IW 14.0.60 (latest) and Delphi XE2:

1) OnNewSession is triggered
2) TIWApplication instance is created, UserAgent string is parsed and the browser is defined
3) OnGetMainForm event is triggered

Just test this:

procedure TIWServerController.IWServerControllerBaseGetMainForm(
  var vMainForm: TIWBaseForm);
var
  s: string;
begin
  s := WebApplication.Browser.BrowserName;
end;


This should work and "s" will contain the name of the browser.

Can you please test it and let me know?
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02