CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Ajax render, subcontainers, IWTemplates

General discussion

by George » 20 May 2014 09:25

Hi!

Guess what i found again..
Extra strange behavior, that seems, related with IW Templates technology and Ajax.
I just want force project to work after migrating to damn templates, but it's not simple as i see.

All what i do in demo is:
delphi code
procedure TMainForm.AjaxBrowserHistoryProcessing(Param: string);
begin
CreateNewFrameWithoutRender(TFrameRequestFeedNew);
RenderRegionAsync(wRegionContainer);
TFrameRequestFeedNew(FrameComp).ProcessCommand(0);
end;

procedure TMainForm.CreateNewFrameWithoutRender(AFrameClass: TIWCGFrameClass);
begin
if Assigned(FrameComp) then
FreeAndNil(FrameComp);
CGCallBackDisableAjaxResponse;
try
FrameComp := AFrameClass.Create(Self);
FrameComp.Parent := wRegionContainer;
FrameComp.Align := alClient;
finally
CGCallBackEnableAjaxResponse;
end;
end;


delphi code
procedure TFrameRequestFeedNew.ProcessCommand(ACommand: integer; AParams: TStrings = nil);
begin
case ACommand of
0:
begin
// When one or both lines uncommented, JS error occurs "undefined is not a function in IW Ajax responce!"
// wHTMLEditor.Content := 'test';
wRegionBottomButtons.AjaxReRender();
end;
end;
end;


I make mistake somewhere?

Executable demo and source.
Best regards!
George
 
Posts: 486
Joined: 23 May 2013 15:50
Location: Russia, Moscow

by Alexander Bulei » 20 May 2014 10:55

Hi George,

Created ticket #388 in our system.
We will check this asap.

Best Regards.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3637
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by George » 22 May 2014 15:40

Hi!

I encountered with another situation with same problem.
New demo available (based on CGDevTools 2.1.0.3619).
Without JS, without templates, without dialog, simple demo.
Best regards!
George
 
Posts: 486
Joined: 23 May 2013 15:50
Location: Russia, Moscow

by Alexander Bulei » 26 May 2014 15:03

Hi George,

Fixed in V2.1.3636

Thanks.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3637
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by George » 27 May 2014 13:58

Hi!

cgdevtools wrote:Hi George,
Fixed in V2.1.3636
Thanks.

I tested new update on both demos, second one now works as expected. Thanks!

Unfortunately, first demo still not work.
I found, that old render method works.
delphi code
procedure TMainForm.IWAppFormCreate(Sender: TObject);
begin
CGRenderAsyncMethod := TRenderRegionAsyncMethod.rramOldMethod;
end;


Should i use old render method instead in release build of my App?
Or will be better to wait for update?
Best regards!
George
 
Posts: 486
Joined: 23 May 2013 15:50
Location: Russia, Moscow

by Alexander Bulei » 27 May 2014 14:09

Hi George,

I will check your 1st demo asap.

Best Regards.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3637
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by George » 27 May 2014 14:33

As suggestion, would be great if render parameter AAfterLazyLoadJS will also work with old renderer.
You can check render type and if it is "rramOldMethod", render procedure can call CGAddJavaScriptToAjaxResponse(AAfterLazyLoadJS).
If you agree, probably, parameter should be renamed to AAfterRenderJS.
Now i have to write this:
delphi code
if (CGRenderAsyncMethod = TRenderRegionAsyncMethod.rramOldMethod) and (not FrameJSInitCode.IsEmpty) then
begin
RenderRegionAsync(Container, TRenderRegionAsyncMethod.rramDefaultMethod, false);
CGAddJavaScriptToAjaxResponse(FrameJSInitCode);
end
else
RenderRegionAsync(Container, TRenderRegionAsyncMethod.rramDefaultMethod, false, FrameJSInitCode);
It's not a problem at all. But you can enhance behavior.
Best regards!
George
 
Posts: 486
Joined: 23 May 2013 15:50
Location: Russia, Moscow

by Alexander Bulei » 27 May 2014 14:56

Hi George,

I will check your 1st demo asap.


Well i checked your 1st demo, and you have bad usage of RenderAsync.

By code, I can take the conclusion that you copied some code from our demo,
but not noticed the essential thing:

Code: Select all
TFrameRequestFeedNew(FrameComp).ProcessCommand(0);


Is called between the CGCallBackDisableAjaxResponse...CGCallBackEnableAjaxResponse,
all js code will generated and sent to client only in one response.

Other thing, you execute this:

delphi code
wRegionBottomButtons.AjaxReRender();


In ProcessCommand, for what? You don't need do this on create of frame (check the code).

Best Regards.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3637
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by Jorge Sousa » 27 May 2014 15:03

hi

As suggestion, would be great if render parameter AAfterLazyLoadJS will also work with old renderer.


This is not needed , since the old method wasn't async in browser, you just have to add to correspondant to AAfterLazyLoadJS , after calling RenderRegionAsync / AjaxReRender
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by George » 27 May 2014 16:09

TFrameRequestFeedNew(FrameComp).ProcessCommand(0);
Is called between the CGCallBackDisableAjaxResponse...CGCallBackEnableAjaxResponse

No, in my first demo, TFrameRequestFeedNew(FrameComp).ProcessCommand(0) is called outside of CGCallBackDisableAjaxResponse...CGCallBackEnableAjaxResponse.
I checked with breakpoints.

I use ProcessCommand(0) as event "frame after first show":
delphi code
CreateNewFrameWithoutRender(TFrameRequestFeedNew);
// some work with frame
RenderRegionAsync(wRegionContainer); // Show frame
TFrameRequestFeedNew(FrameComp).ProcessCommand(0); // Frame after show


Other thing, you execute this:
wRegionBottomButtons.AjaxReRender();
In ProcessCommand, for what? You don't need do this on create of frame (check the code).

It's just for example. there is also line: wHTMLEditor.Content := 'test' that leads to same issue, even if wRegionBottomButtons.AjaxReRender() commented.

I suppose that some bug present in Lazy render, but also my code is not perfect.
I'll check, how i can change my code in real project, probably i can avoid issue by improving my code.
Thanks for advice!

cgdevtools_support wrote:hi
As suggestion, would be great if render parameter AAfterLazyLoadJS will also work with old renderer.

This is not needed , since the old method wasn't async in browser, you just have to add to correspondant to AAfterLazyLoadJS , after calling RenderRegionAsync / AjaxReRender

I'm not sure that i understand you :(
I implemented wrapper for me, to use single call for both render methods:
delphi code
cm_RenderRegionAsync(wRegionContainer, TRenderRegionAsyncMethod.rramDefaultMethod, true, TFrameRequestFeedNew(FrameComp).GetJSInitCode());

delphi code
procedure cm_RenderRegionAsync(ARegion: TIWHTMLContainer; ACGRenderAsyncMethod: TRenderRegionAsyncMethod; ABrowserResize: boolean = false;
const AAfterRenderJS: string = ''; const AAppendToHTMLID: string = '');
var
RenderAsyncMethod: TRenderRegionAsyncMethod;
begin
case ACGRenderAsyncMethod of
TRenderRegionAsyncMethod.rramDefaultMethod:
RenderAsyncMethod := CGRenderAsyncMethod;
TRenderRegionAsyncMethod.rramOldMethod:
RenderAsyncMethod := TRenderRegionAsyncMethod.rramOldMethod;
TRenderRegionAsyncMethod.rramLazyLoadMethod:
RenderAsyncMethod := TRenderRegionAsyncMethod.rramLazyLoadMethod;
else
RenderAsyncMethod := TRenderRegionAsyncMethod.rramOldMethod;
end;

if RenderAsyncMethod = TRenderRegionAsyncMethod.rramOldMethod then
begin
RenderRegionAsync(ARegion, ACGRenderAsyncMethod, ABrowserResize, '', AAppendToHTMLID);
if not AAfterRenderJS.IsEmpty then
CGAddJavaScriptToAjaxResponse(AAfterRenderJS);
end
else
RenderRegionAsync(ARegion, ACGRenderAsyncMethod, ABrowserResize, AAfterRenderJS, AAppendToHTMLID);
end;
Last edited by George on 27 May 2014 16:15, edited 1 time in total.
Best regards!
George
 
Posts: 486
Joined: 23 May 2013 15:50
Location: Russia, Moscow

Next

Return to General - Archive

cron

Who is online

Users browsing this forum: No registered users and 0 guests

Contact Us.