Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » xtext-services and iframe(xtext-services don't work when using iframe)
xtext-services and iframe [message #1840947] Thu, 29 April 2021 11:39 Go to next message
z232 I is currently offline z232 IFriend
Messages: 48
Registered: February 2016
Member
Hi,

I have created a web application with a simple "hello world" DSL.
I run the project with gradle in localhost 8080.
When accessing the web app from any browser (firefox, chrome etc ) everything seems to work fine. The validation of the DSL, in case of syntactic errors, shows respectively the errors in each line of the text editor.
The thing is that, in case i embed inside another web page ( through an iframe) the "localhost:8080" , the validation errors and generally the xtext services, don't work.

In the console.log of each browser i use, i am getting the following error
GET http://localhost:8080/xtext-service/occurrences?resource=21769cf1.ddl&caretOffset=203&requiredStateId=-80000000 404 (Not Found) jquery.min.js:2

a snapshot of my index.html is presented below
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="Content-Language" content="en-us">
	<title>Example Web Editor</title>
	<link rel="stylesheet" type="text/css" href="xtext/2.20.0/xtext-ace.css"/>
	<link rel="stylesheet" type="text/css" href="style.css"/>
	<script src="webjars/requirejs/2.3.6/require.min.js"></script>
	<script type="text/javascript">
		var baseUrl = window.location.pathname;
		var fileIndex = baseUrl.indexOf("index.html");
		if (fileIndex > 0)
			baseUrl = baseUrl.slice(0, fileIndex);
		require.config({
			baseUrl: baseUrl,
			paths: {
				"jquery": "webjars/jquery/3.4.1/jquery.min",
				"ace/ext/language_tools": "webjars/ace/1.3.3/src/ext-language_tools",
				"xtext/xtext-ace": "xtext/2.20.0/xtext-ace"
			}
		});
		require(["webjars/ace/1.3.3/src/ace"], function() {
			require(["xtext/xtext-ace"], function(xtext) {
				xtext.createEditor({
					baseUrl: baseUrl,
					syntaxDefinition: "xtext-resources/generated/mode-mydsl"
				});
			});
		});
	</script>
</head>
<body>

<div class="container">
	<div class="header">
		<h1>Example MyDsl Web Editor</h1>
	</div>
	<div class="content">
		<div id="xtext-editor" data-editor-xtext-lang="mydsl"></div>
	</div>
</div>

</body>
</html>



thanks in advance

[Updated on: Thu, 20 May 2021 14:54]

Report message to a moderator

Re: xtext-services and iframe [message #1840948 is a reply to message #1840947] Thu, 29 April 2021 11:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
can you provide something reproducible. i cannot do with this handcrafted index2.html

<html>
<body>
<iframe src="index.html"/>
</body>
</html>


same when i switch the names and adapt the var fileIndex = baseUrl.indexOf("index.html");


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 29 April 2021 11:50]

Report message to a moderator

Re: xtext-services and iframe [message #1840950 is a reply to message #1840948] Thu, 29 April 2021 12:12 Go to previous messageGo to next message
z232 I is currently offline z232 IFriend
Messages: 48
Registered: February 2016
Member
Hi Christian

This is the second page, that loads inside an iframe the "hello world" dsl web application.

<!DOCTYPE html>
<html lang="en">
  
   <body>

<h1>The iframe element</h1>
<iframe src="http://localhost:8080" frameborder="4" allowfullscreen="true" style="width: 100%; height: 1924px;">
</iframe>

</body>
</html>


a screenshot of the web page using an iframe to embed the hello world dsl language

https://i.postimg.cc/RZ30316s/Capture.jpg


[Updated on: Thu, 20 May 2021 14:54]

Report message to a moderator

Re: xtext-services and iframe [message #1840951 is a reply to message #1840950] Thu, 29 April 2021 12:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
do you have multiple webservers with different ports?
i still cannot reproduce.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 29 April 2021 12:18]

Report message to a moderator

Re: xtext-services and iframe [message #1840953 is a reply to message #1840951] Thu, 29 April 2021 12:24 Go to previous messageGo to next message
z232 I is currently offline z232 IFriend
Messages: 48
Registered: February 2016
Member
No.
a) The only server that is running right now, is the DSL web app in localhost:8080.
b)The parent page is only a index.html file, which i open with a browser. This page has an iframe with source being the address "http://localhost:8080"

[Updated on: Thu, 20 May 2021 14:55]

Report message to a moderator

Re: xtext-services and iframe [message #1840956 is a reply to message #1840953] Thu, 29 April 2021 12:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
can you please provide a complete example

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext-services and iframe [message #1840961 is a reply to message #1840956] Thu, 29 April 2021 13:44 Go to previous messageGo to next message
z232 I is currently offline z232 IFriend
Messages: 48
Registered: February 2016
Member
Christian,

Unfortunately i run this server locally, so i cannot provide you a link to see the behavior of the system as a hole. I will try to explain the steps i followed, to create the DSL web application and the index.html with the iframe pointing on the server.

First step was to create a xtext project,
generated the artifacts of that dsl language
and run it with gradle on port 8080.

I opened a browser to see if the web app dsl is working as expected.
Everything seems to work as expected regarding the xtext-services.

The second step was to create a index.html file (like the one that i mentioned in my previous post). This file has an iframe inside with src="http://localhost:8080".
In this case when i open the file with a browser, the localhost :8080 shows up inside the iframe, but the xtext-services are crashing.

Sorry, i try to be more detailed about the problem.
I hope its more understundable.

thanks


[Updated on: Thu, 20 May 2021 14:55]

Report message to a moderator

Re: xtext-services and iframe [message #1840962 is a reply to message #1840961] Thu, 29 April 2021 14:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
but there is already an index html in the project created by the wizard, so how can you create a second one and add the iframe there?
shouldnt you open

localhost:8080/yournewindex.html in browser then?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext-services and iframe [message #1840964 is a reply to message #1840962] Thu, 29 April 2021 14:15 Go to previous messageGo to next message
z232 I is currently offline z232 IFriend
Messages: 48
Registered: February 2016
Member
The second index.html is not in the same project . It is a simple file outside the scope of that project, which has an iframe in it and the src refers to the "http://localhost:8080"

Only the project, which has the implementation of the dsl language (hello world), is running in localhost:8080 .
Sorry for the confusion

[Updated on: Thu, 20 May 2021 14:55]

Report message to a moderator

Re: xtext-services and iframe [message #1840965 is a reply to message #1840964] Thu, 29 April 2021 14:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
still cannot reproduce



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext-services and iframe [message #1840967 is a reply to message #1840965] Thu, 29 April 2021 14:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
which browser do you use? maybe its a security feature that prevents something?
do you have any messages in browser console?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext-services and iframe [message #1840969 is a reply to message #1840965] Thu, 29 April 2021 14:56 Go to previous messageGo to next message
z232 I is currently offline z232 IFriend
Messages: 48
Registered: February 2016
Member
That's pretty weird!
I guess that inside your web root folder there are two index files
a) index.html , that is created from the wizard while generating the artifacts
b) index_.html , that you created and contains the iframe, which points to the link "http://localhost.8080"

Maybe there is no confilict when both index files are inside the project. Have you try to move the index_html file outside the scope of the project?
Or maybe there might be some configuration problem or some issue with the version of xtext.

thanks

[Updated on: Thu, 20 May 2021 14:55]

Report message to a moderator

Re: xtext-services and iframe [message #1840970 is a reply to message #1840969] Thu, 29 April 2021 14:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
can you please provide your hello world project and the extra index html e.g. via github

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext-services and iframe [message #1840975 is a reply to message #1840970] Thu, 29 April 2021 16:07 Go to previous messageGo to next message
z232 I is currently offline z232 IFriend
Messages: 48
Registered: February 2016
Member
i have created the project and the index-Iframe.html
https://we.tl/t-YTfIzNU7cq
Re: xtext-services and iframe [message #1840982 is a reply to message #1840975] Thu, 29 April 2021 19:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
unfortunately your code works on my machine perfectly fine

maybe this is a problem with special browsers like chrome or safari and restrictions about cross origin

or with the jquery and other versions
does the resource id and co change between the requests?

maybe you also can remote debug the server.
maybe xtext sevlet has a org.eclipse.xtext.web.server.InvalidRequestException$ResourceNotFoundException

this might be caused by session not working correct with the iframe
thus you may put your local html to the server too


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 29 April 2021 20:02]

Report message to a moderator

Re: xtext-services and iframe [message #1840985 is a reply to message #1840982] Thu, 29 April 2021 20:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
another workaround would be to work stateless

xtext.createEditor({
					baseUrl: baseUrl,
					sendFullText: true,
					syntaxDefinition: "xtext-resources/generated/mode-mydsl"
				});


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext-services and iframe [message #1840986 is a reply to message #1840982] Thu, 29 April 2021 20:39 Go to previous messageGo to next message
z232 I is currently offline z232 IFriend
Messages: 48
Registered: February 2016
Member
No it keeps the same resourceID which is the default start -80000000
Thats because it can't do the update and decrease by 1.
The strange thing is that the validator works in Firefox.
In the other Browsers (Opera, Chrome and Edge) i get the errors i mentioned in my previous posts.
Have you tested only with Firefox ?
Did you tested also with the rest of the Browsers?

Bests

[Updated on: Thu, 20 May 2021 14:56]

Report message to a moderator

Re: xtext-services and iframe [message #1840992 is a reply to message #1840986] Fri, 30 April 2021 04:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
The problem is that session is not working con chrome
Cause they don't like the iFrame and two servers thing you do.

index.php/fa/40425/0/

If you ship both files via the server chrome is fine

Did you try the stateless? The sendFullText (and clear the cache)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 30 April 2021 04:53]

Report message to a moderator

Re: xtext-services and iframe [message #1840998 is a reply to message #1840992] Fri, 30 April 2021 06:08 Go to previous message
z232 I is currently offline z232 IFriend
Messages: 48
Registered: February 2016
Member
Hi Christian,

You are totally right. I used the send full text and it worked!!
Thank you very match for your support.
Have a nice day!!!

Best Regards

[Updated on: Thu, 20 May 2021 14:56]

Report message to a moderator

Previous Topic:Nested class and visibility of members
Next Topic:Resolving unresolved reference using IDerivedStateComputer
Goto Forum:
  


Current Time: Thu Mar 28 23:22:24 GMT 2024

Powered by FUDForum. Page generated in 0.03396 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top