NetTalk Central

Author Topic: What is this message after a script Alert?  (Read 4022 times)

springguy

  • Full Member
  • ***
  • Posts: 195
    • View Profile
    • Email
What is this message after a script Alert?
« on: September 15, 2012, 06:48:00 AM »
NT 6.42
I'm in a Form, and am trying to display a message using p_web.script('alert("my message");') and this does generate the message just like I want.  However, after closing the message, the form returns to the browse, and I have some text being displayed at the top of the browse page (see attached screenshot).  The text is:

HTTP/1.1 200 OK Date: Sat, 15 Sep 2012 14:35:46 GMT Server: NetTalk-WebServer/6.42 Expires: Fri, 16 Sep 2011 14:35:46 GMT Content-Type: text/html Cache-Control: no-store, no-cache, must-revalidate, private,post-check=0, pre-check=0, max-age=0 Pragma: no-cache Connection: close

Any idea what the problem is?

Mike Springer

[attachment deleted by admin]

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: What is this message after a script Alert?
« Reply #1 on: September 16, 2012, 10:36:09 PM »
Hi Mike,

it means you're doing it wrong. Perhaps a small example that we can look at and comment on would be useful?

cheers
Bruce

springguy

  • Full Member
  • ***
  • Posts: 195
    • View Profile
    • Email
Re: What is this message after a script Alert?
« Reply #2 on: September 17, 2012, 02:44:04 AM »
I'll work up an example later today.  But I can tell you this now - this is a static site with dynamic content, and it is a form and when the delete button on the form is clicked, I am using the ValidateDelete embed to change the ans to ChangeRecord so that I don't actually delete the record but it allows me to set a flag in the record that indicates that the record has a "delete status".  Since I do not get a delete confirmation message, I want to display a message that the record has been deleted before the browse screen appears.

Here's the code in the ValidateDelete embed:

!*** Call the Delete Processor ***
ans = net:ChangeRecord
p_web.SSV('DeleteSysID',ATT:SysID)    !remember the sysid of this record
p_web.SSV('DeleteFile','Attendance')  !identify the file involved
!*
!* call the clarion source procedure that will
!* update this record's delete flag field and
!* any related child records
!*
deleteprocessor(p_web)

!*
!* give a message that the record has been deleted
!* since there is no "delete confirmation" message
!*

p_web.script('alert("The record has been deleted\nIf you didn''t mean to do that, contact the Church Administrator who can recover the information");')

Bruce, is this enough to identify the problem, or would you still want an example app?

Mike Springer

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: What is this message after a script Alert?
« Reply #3 on: September 18, 2012, 05:24:38 AM »
>>  I want to display a message that the record has been deleted before the browse screen appears.

that's not as easy as you might think. You need to "embed" that message in that page.

you can't just do;

p_web.script('alert("The record has been deleted\nIf you didn''t mean to do that, contact the Church Administrator who can recover the information");')

at this point, because that would put the script before the returned page, not on the returned page.

Yes, an example will probably be useful because  there are a couple approaches one could take, and I'd like to try them before giving you a definitive answer.

cheers
Bruce

springguy

  • Full Member
  • ***
  • Posts: 195
    • View Profile
    • Email
Re: What is this message after a script Alert?
« Reply #4 on: September 18, 2012, 07:03:33 PM »
Bruce,
Attached is a simple example - browse with a form in a static page environment.  The browse does not have a delete, but the form does.  The validatedelete embed is used to flag the record (rather than deleting it) and that is were I am trying to display a message to the user.

Thanks for your advice.
Mike Springer


[attachment deleted by admin]

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: What is this message after a script Alert?
« Reply #5 on: September 19, 2012, 12:27:54 AM »
Hi Mike,

thanks for the example. As occasionally happens working with the example, and writing some docs, leads to a more elegant solution than one which is currently on offer. So the following applies to build 6.45 and later (which should be out later this week.)

In your code instead of;
p_web.script('alert("The record has been deleted");')
you should rather put
p_web.SetAlert('The record has been deleted')

The key thing here is that the SetAlert approach should work _anywhere_ in the code. I encourage others reading this thread to use this syntax rather than any other. If there is a context where it does not work then the goal would be to extend it to support that context.

The second change in 6.45 is the "split" between the "Message" (typically shown in Red on the top of the page) and the "Alert" (which appears in a popup box, and requires the user to click Ok). If you want to set both you can do;
p_web.SetAlert('whatever',net:alert + net:message)

p_web.SetMessage('whatever') can also be used to set just the message and not the alert. This is the equivalent of
p_web.SetAlert('whatever',net:Message)

Cheers
Bruce




springguy

  • Full Member
  • ***
  • Posts: 195
    • View Profile
    • Email
Re: What is this message after a script Alert?
« Reply #6 on: September 19, 2012, 03:12:29 AM »
Hi Bruce,
Thanks for your fantastic support.  Your more elegant solution sounds like a great addition.  I appreciate your looking beyond just a specific application suggestion to a more general and flexible solution.

Thanks,
Mike