HandleURL, ExecuteEvent and WebControlWrapper is possible work together?

I’m trying to work reading html files from disk while trying to manage one WebControlWrapper control for these html files. Is there any way to do this? Will not let me create a WebControlWrapper control without having associated a Webpage. Even within a Webpage, the page is not loaded when the HandleURL event runs.

I try to make it that way because I want to interact with JavaScript and HTML page loaded from a file.

Now I try to have a web design completely done with an external tool, and I want to work with such a design and interact with it.

And for that, I would like to use the ExecuteEvent event, to exchange data without being seen in the URL address bar.

No no no. You are mixing everything up.

HandleURL cannot display any webpage directly. You cannot use Show or ShowURL there.

Think of HandleURL the same way as Php : you tap into it with parameters, and it does something with it, then returns an HTML page.

That is what you see in the LR example.

If you want to use HandleURL, you will have to display your HTMLPage from there, by picking it up and printing it.

For instance :

[code]Dim f as folderItem = specialFolder.ApplicationDate.Child(“com.mylab.myapp”).Child(“index.html”)

If f <> Nil Then
If f.Exists Then
// Be aware that TextInputStream.Open coud raise an exception
Dim t As TextInputStream
Try
t = TextInputStream.Open(f)
t.Encoding = Encodings.MacRoman
Print(t.ReadAll)
t.Close
Catch e As IOException
MsgBox(“Error accessing file.”)
End Try
End If
End If[/code]

The catch is, you won’t be able to use TriggerServerEvent from that page, since no session exists in HandleURL. A point rightly made by Greg in the other thread about using BootStrap.

A better way would be to use a full page WebHTMLViewer to display your HTML.

Let me verify how to call a WebSDK Control TriggerServerEvent from within an iFrame (which WebHTMLViewer is).

OK. It is not the most simple, but it is feasible.

Basically, the most difficult to do is to get the WebSDKControl ControlID, in order to call TriggerServerEvent.

Here is how I was able to do it :

  • Drag a TextField to the WebPage
  • In its Open event :

Sub Shown() Handles Shown me.Text = CustomHTMLArea.ControlID self.ExecuteJavaScript("document.getElementById('"+me.ControlID+"_inner').id = 'boo';") End Sub

  • In the HTML page, I was able to display the control event with the following code :

<script> alert(window.parent.document.getElementById('boo').value); </script>

Basically then you have the ID of the WebSDK control to send back whatever you want to the page.

Put the TextField that will serve to communicate with the page off-view (Top = -100).

Put a WebHTMLViewer on the WebPage, make it full width and full height, lock all sides.

Then you will have to load your HTML Page in the WebHTMLViewer. The most convenient is to upload it to the Web space where your app resides and use the URL property to point to it.

If you cannot upload to the same web space with pictures and stuff, you can still use the technique in my previous post. But it is a tad more complex to do. Note that you cannot use another web space than that where your app resides because iFrame HTTP security would prevent you from accessing the webPage data, or sending back to the WebSDK.

I did that to demonstrate that things that appear impossible at first glance are indeed feasible. In fact I enjoyed the exercise to see if I was able to do it. But I am absolutely not convinced I would use the same technique for myself.

Quite frankly, I feel you may want to get a lot more familiar with Xojo Web in the first place, instead of trying to frankeinsteinize it with external HTML pages.

Sometimes what seems a quick way to avoid learning how Xojo Web works can in fact become a long and tedious walk through convoluted workarounds. No pain no gain…

[quote=291850:@Michel Bujardet]No no no. You are mixing everything up.
HandleURL cannot display any webpage directly. You cannot use Show or ShowURL there.
[/quote]

Thanks Michel for your help. This point I already had solved with a similar example, even with reading the CSS, JS and images of HTML and inserts in all one document, which by the way, it is more laborious.

My intention for wanting to use the Show method is because he saw no other way to use a WebControlWrapper control, for AJAX calls, in these cases.

In this case (at the moment) just trying to be as productive as possible, bringing complete files of other visual web design tools without modifications. We could say that I will trying use in this case Xojo as backend, with AJAX but without APIs or Restfull calls.

I said in previous threads my difficulties in web development, and that was one of the reasons why I bought Xojo, for to help me abstract from all over the web complexity in the best way possible.

Despite having an intelligence slightly above average without being very prominent, my cognitive reasoning is below average. That makes me a lousy user, but also an excellent analyst, because I need to have very detalled every detail to understand.

I have spent many years trying to make Fullstack web developments without success, and with my training and experience, sometimes I am ashamed of it :frowning: . Are those things that cost in life to understand…

The way Xojo addresses the problem of the web development is the same approach as any web scripting language, with its advantages and disadvantages, and that’s a problem for those who need the simplest things. Moreover, For me, I think I can cost the same job learning to use PHP that Xojo for web development… With the unique (and great) difference to have a better code debugger, and one language more easy of read. I truly, I understand a PHP code made by a craftsman (not by someone who uses MVC pattern).

I continue reviewing your other comment…

Manuel, as I said, what I posted was a proof of concept.

It would be a lot better if, since you are a good analyst, you came up with a precise description of what you want to do and obtain step by step.

For some tasks, I am convinced HandleURL is the way to go. For others, a tighter integration may be necessary.

At any rate, if you can divide your project in simpler modules, and precisely describe what you want to obtain from Xojo in regards to HTML pages, it is way easier to solve one problem at a time rather than a whole bowl of salad.

[quote=291925:@Michel Bujardet]Manuel, as I said, what I posted was a proof of concept.
[/quote]

Yes Michel, I can always it be divided into two Xojo applications, and communicate between them … there are always options, the issue is to see what effort required … Thanks :slight_smile:

Indeed anything is possible, and I don’t mind showing you the way, but that requires clearly stating what you need. Describing the process you want to create.

BTW using HandleURL you don’t need TriggerServerEvent. All you need to do is to pass the parameters to the HandleURL as in for instance in JavaScript

window.location = 'http://127.0.0.1:8080/SendBack/?param1=orange&param2=apple&param3=banana';

In HandleURL you know that when the virtual directory Sendback is used you should expect values sent back from your HTML Pages.

That is just an example.

To have the app display a particular page :

Function HandleURL(Request As WebRequest) Handles HandleURL as Boolean if instr(Request.Path, "ManageHTML") > 0 then Request.print "<html><body><script>window.location='"+Request.GetParameter("page")+"';</script></body></html>" return true end if End Function

Then you hit the app with this for instance :

http://127.0.0.1:8080/ManageHTML/?page=http://fontmenu.com/?param1=grape&param2=pommegrenate&param3=avocado

With these two, you have what is needed to interface your HTML pages and Xojo. Note that you pass lots of parameters to your HTML/JavaScript page for display.

You can go further for instance with HTML forms and Post, which is then obtained with Request.GetRequestHeader.

As I said, anything is possible, as long as you have clearly defined what you want.

[quote=292098:@Michel Bujardet]BTW using HandleURL you don’t need TriggerServerEvent. All you need to do is to pass the parameters to the HandleURL as in for instance in JavaScript

window.location = 'http://127.0.0.1:8080/SendBack/?param1=orange&param2=apple&param3=banana';

[/quote]

Thanks Michel. I did not know I could use the form post method also handleurl.

Could you make a call from an event using javascript with handleurl and modify only part of the DOM without reloading the whole window, similar to AJAX?

The problem in this case would be: How to use Executejavascript method? I would need to use a webcontrol or webpage…

I have done it so far for rows in tables, but essentially it is a matter of removing an element and inserting a new one. You could very well replace the entire body that way.

Seems futile, though. Showing a new page is way easier.

Nope. Not necessarily.

You can pass instructions and data Base64 encoded via the hashTag.

That requires a setInterval() to monitor the hashtag, and parsing the instructions.

There are probably other methods available.

Understand that I am not saying all that is easy. It is possible. But you will have to do the footwork.

The nice thing about Xojo Web used with the IDE is that it takes care of everything for you.

I believe the best of both worlds would be to use the Xojo Web sessions (designed in the IDE) in iFrames as portions of elaborate pages created in Bootstrap or other high level web design tool.

It is not extremely difficult to create sober and clean webpages in Xojo, which can take place transparently inside iFrames. That way you don’t have to worry about language abstraction so much, and although JavaScript is nice, it does not have natively the collection of objects Xojo has.

For instance, things like login, database maintenance, processing, are way easier and secure in Xojo Web.

I know there are web developers here who do exactly that with stunning results.

In that case you need indeed to modify the Bootstrap page content dynamically, as any new display of a Xojo Web page creates a new session.

Michel, the iframe is always something I have in mind to use, but I would not like to use it within Xojo development, but yes to embed on other sites. However, if it is commonly used by developers Xojo, I’ll keep that in mind, thank you.

Manuel, at this stage, I tried to tell you what is possible. You can embed a Xojo Web app in an HTML/CSS page. You can embed an HTML/CSS page within a Xojo Web app, and you can communicate between the two.

Now you need to sit down and try to define more clearly where you want to go. And probably experiment.

BTW, Xojo Web uses an iFrame : WebHTMLViewer. There is nothing wrong about iFrames per se. Used correctly on the same server, they can do pretty spectacular things.

[quote=292581:@Michel Bujardet]Manuel, at this stage, I tried to tell you what is possible. You can embed a Xojo Web app in an HTML/CSS page. You can embed an HTML/CSS page within a Xojo Web app, and you can communicate between the two.

Now you need to sit down and try to define more clearly where you want to go. And probably experiment.

BTW, Xojo Web uses an iFrame : WebHTMLViewer. There is nothing wrong about iFrames per se. Used correctly on the same server, they can do pretty spectacular things.[/quote]

Michel, you’re right in what you say. But for me the most important thing was knowing communication between both worlds: Javascript and Xojo, and the different options that can be used.

I insert another associated thread: https://forum.xojo.com/32112-webpage-show-from-handleurl/p1