Can I use doPost to send data through the WebDev module pocess it and see the page in an iframe in Perspective

I have set up a Perspective view that has a button that runs a script to perform a query and then send it to a Python WebDev resource that consists of a script that pulls the data out of the body, processes, builds the html for a JavaScript SVG chart.

I would to like view this on the same view as the button. I have successfully sent the data to the endpoint and returned the dataset to the console. Also the html comes back.

However, nothing is drawing in the iframe.

I tested just a static version of the same html in a doGet to the same endpoint and the chart is drawing.

I have not tried to pass the dataset in the url to a doGet because I am worried about the size limits of data passed in a url

Does anyone know if the iframe will render the html code in this way?

Any script you run will be issued from the gateway, not your running session, so the updated HTML returned by your Webdev endpoint is just going to end up lost.
Could you have your Webdev endpoint return an image file or SVG, and use that directly in an image in your view, instead of using the iframe?

This is going to be a tricky thing to accomplish within your constraints.

That will prob work and I want to turn this in to an image for a report at some point.

Is there a lib or something I can use in the WebDev resource script to turn this html in to an image?

I am doing beacuse of the limitations of not running javascript directly in ignition.

This is what is drawn by the html code. The colored lines are currently sample generated data which will eventualy be the data passed in the query.

Would Apache Batik work for this?

Would I put the jar files in the lib/core/common folder?

Do they need to all be in a folder under this folder or just individual jars?

Would I need to use the pack200 tool?

Only in Vision.

I have a module that packages the libraries for Vision Clients (with a component wrapper). The designer already has all the libraries.

I would prefer that I was able to send the data to WebDev and have it send the html back and have it rendered directly in an iframe in Perspective but it seems that’s not possible.

So the next option seems to be a solution that will return the chart as an image to a perspective page.

I saw your module and that it was designed for Vision.

What prevents me from having batik or some other java taking the svg content in the doPost endpoint and returning it to an image container in Perspective?

If you don't need to manipulate it, I don't see why WebDev cannot do this. You will need two endpoints:

  • One to receive the post with the SVG. This would cache the content somewhere. I'd recommend a sessionVarMap, targeting the Perspective session that wants this image. Or in a database. Then message or otherwise trigger a event in the session to display an IFrame or Image component with the URL for:

  • The endpoint that retrieves the SVG and serves it.

@pturmel Thanks for the reply.

In this senerio do I need to install Batik?

If yes, can you answer any of the initial questions I had.

I have the endpoint set up to recieve the post and I have it echoing the JSON data and the static html back currently.

Can you give me a bit of direction on the sessionVarMap?

Also, Would this be another WebDev endpoint?
If yes, Would I set up a doGet in an iframe to get this?

No.

If it doesn't make sense, just use a database.

Yes.

If you mean give the IFrame a URL that points at the 2nd WebDev GET endpoint, yes.

I think the database might be the way to go. This way I can store a single image of the chart that I can use for a report, as well. What do you think?

Would I just put the entire html code in the database?

If yes, would I run an insert or update query in the doPost endpoint to do this?

Then, In the doGet do I run a query to retrive and return the html?

Sorry for all the questions. the WebDev module is a bit to wrap my head around.

I would.

I would insert, and use getKey=True to retrieve the new ID in the DB, and message that to the Perspective session for it to build the IFrame URL.

Yes.