NetTalk Central

Author Topic: Netwebbrowse Server side code doesn't fire when on click procedure with _blank  (Read 4683 times)

MikeR

  • Sr. Member
  • ****
  • Posts: 265
    • View Profile
    • Email
Netwebbrowse Server side code doesn't fire when on click procedure with _blank template filed in.

The reason I want to do this is:
A button in the browse calls a report procedure which opens the pdf on a new tab.
It must also do something else , that needs to be refreshed on the browse.
The server side code and the refresh browse row data doesnt fire ?
any thoughts 

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Hi Mike,

>> A button in the browse calls a report procedure which opens the pdf on a new tab.
>> It must also do something else , that needs to be refreshed on the browse.

it can't do that. Well not without a fair bit of cunning. The browser/server model is one of request/response.
So when you ask for a report, you get a report. Updating the screen underneath is something different.
I'll look into this specific case, but generally you can't make 2 requests at once, so if I got it to work here it
would be a very "specific case" solution.

Also the update would happen in parallel to the report, not after the report is made.

Cheers
Bruce


MikeR

  • Sr. Member
  • ****
  • Posts: 265
    • View Profile
    • Email
Ja , thanks Bruce, I got a work around where the server side code just generates the report and does the updates.
another button must be pressed to view the report  :(

By the way is it possible to show a pdf document inside my nettalk page ?
ie I want to show the user the pdf and ask him what action he wants to take based on what he sees ?

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
This JS should do it (for IE or others)  - maybe :)


<script language="javascript">
  if ((navigator.appName).match(/Explorer/i) != null)   {
    document.write('<OBJECT CLASSID="clsid:CA8A9780-280D-11CF-A24D-444553540000" WIDTH="100%" HEIGHT="500">');
    document.write('<PARAM NAME="SRC" VALUE="***path to your pdf***"/>');
    document.write('</OBJECT>');
  } else {
    document.write('<EMBED src="***path to your pdf***" width="100%" height="500" type="application/pdf">');
    document.write('</EMBED>');
  }
</script>


You'll need that on your page somewhere and you'll need to know the PDF filename beforehand. But it could also be done via ajax.

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
I was thinking about your original question and it sounds like something i do and Bruce is right much cunning was required, it went something like this:

1. Click on button asking for report (from browse or anywhere really)
2. This calls a NetWebPage, that is mostly just HTML saying "we are preparing your report... blah blah blah".
3. This NetWebPage contains a Javascript Interval (every few seconds) that calls an AJAX function on the server that checks for the existence of the "expected PDF filename, that is only available once the report is completed. If its not ready AJAX function say no, if it is ready AJAX function returns yes. The original NetWebPage in step 2 above knows that once the AJAX function returns yes, it can redirect you (window.location=""; or similar) to the PDF.
4. Meanwhile if you get bored and go off and do something else, the report is still produced and it sitting in your "Report In-Tray".

Works very nicely on one of my apps, and is my preferred solution to handling reports on web based systems. As some of my reports are ready within seconds and others may take minutes.

Regards
Bill

MikeR

  • Sr. Member
  • ****
  • Posts: 265
    • View Profile
    • Email
Thanks pshields for the responses.
I included the java script , it works on my ie browser , but not firefox.
What do you mean ajax ? how do I pass the pdf as a parm ?

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Double check your firefox browser can open PDFs on other websites as an embedded object. It will require the PDF extension to be installed.

By AJAX - http://en.wikipedia.org/wiki/Ajax_(programming) - i mean NT does lots of stuff where it calls back to the server to update fields, hide fields, etc etc. But you can also call back to the server using AJAX techniques from your client browser yourself, much like a normal function call in Clarion. It just requires a little more work.

So in the example of the printing PDF, at the time you send the page to the customer saying please wait for your report, you don't know if it is finished or not. But you can check back with the server from time to time and ask if it has finished yet. Once it says it is finished within your client browser you have the ability to do something about it, like to and open the PDF.