Question
· Jan 15, 2017

CSP Page show content dinamically

I want do to a "simple thing". Show a dynamic log of actions in the browser as we can see on Terminal. For that, I guess to make a simple CSP Page that show a new line every WRITE command is the thing I need.  

But how I refresh after each WRITE?

How I can refresh the content automatically?

I made a simple CSP Page and in method OnPage I do this test:

    write "Start..",!
    for i=1:1:10{
        hang 1
        write "Doing "_i,!
    }

 

Don't work... because the browser show me only after the process finish.

I guess I should use another way... any help?

Discussion (4)1
Log in or sign up to continue

Looks like, you don't know how this technology works.

The server will send content after all content is ready to send. Browser shows page, just after loading all the page, or partially, if this page is too big.

To do what you want, you should have some code on client side, which will ask the server for the new lines by Ajax. Or with WebSocket, just get new lines from the server. But it means that process which generates such logs, should be different to the session process.

As Dmitry already pointed out, it seems you should cover your basics first. 

A CSP page is first and foremost a static page which is being rendered on the server. The data model of webpages has traditionally been dominated by a request-response approach. This comes down to the basic stateless design of http: a client sends requests to GET some information from the server (very simplified). 

This means it is quite difficult to "push" updates from the server to the client. One solution, or rather, workaround to this problem, is to implement a timer on the client side which periodically asks the server if there is new data. This can easily be solved with a javascript timeout. 

Nowadays we have moved on a little bit from this rather clumsy approach. Dmitry already mentioned a possibility for this: websockets. Websockets give you a two way communication channel between your client and your server (see RFC6455). 

This introduced the exciting possibility to actually push events from the server to the client without the need for periodic pulling of information.  

Have a look at this basic example how to do that in Caché technology: asynchronous-websockets-quick-tutorial (shameless plug;) )

There have been quite a few advances and developments in this area, building on the basic websocket connection and building frameworks for the efficient handling and caching of even bigger datasets. React/Flux are just some frameworks you could look at as you make your way through the jungle of web technology. Good Luck!

 

-Fab

I understand and am clear about the so "wide" of my question :-)

I wonder if there is something not so complex or something "done" to send directly to a web page the results of a WRITE command. This is something common in Ensemble when creating a namespace  or DeepSee Portal when compile or Build a Cube.

Maybe there is a Zen component or sample CSP/Javascript that do that, etc.

Regards