Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Model display on load in XTEXT Web Editor(when xtext editor loads it contains a model)
Model display on load in XTEXT Web Editor [message #1748329] Tue, 22 November 2016 10:24 Go to next message
tom KIRKHAM is currently offline tom KIRKHAMFriend
Messages: 16
Registered: August 2016
Junior Member
Hi All,

I have been following the XTEXT Web Editor for a DSL demo and have it working thanks to help from this forum.

I now want a model to load automatically when I goto the editor page, the model will be collected via a JQuery GET command. However, using the code below I can't get the model to load, can anybody help?

Thanks,
Tom

<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.10.0/xtext-ace.css"/>
<link rel="stylesheet" type="text/css" href="style.css"/>
<script src="webjars/requirejs/2.2.0/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/2.2.3/jquery.min",
"ace/ext/language_tools": "webjars/ace/1.2.2/src/ext-language_tools",
"xtext/xtext-ace": "xtext/2.10.0/xtext-ace"
}
});
require(["webjars/ace/1.2.2/src/ace"], function() {
require(["xtext/xtext-ace"], function(xtext) {
var editor = xtext.createEditor({
baseUrl: baseUrl,
syntaxDefinition: "xtext-resources/generated/mode-camel"
});
jQuery.get('http://127.0.0.1:8080/tom.txt', data, function(result){
editor.setValue(result.fullText);
});
e.preventDefault();
});
});
});
</script>
</head>
<body>
<div class="container">
<div class="header">
<h1>CamelDsl Web Editor</h1>
</div>
<div class="content">
<div id="xtext-editor" data-editor-xtext-lang="camel"></div>
</div>
</div>
</boy>
</html>
Re: Model display on load in XTEXT Web Editor [message #1748334 is a reply to message #1748329] Tue, 22 November 2016 10:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11075
Registered: July 2009
Senior Member
your js is incomplete (have a look at jaavascript console of your browser)

require(["webjars/ace/1.2.2/src/ace"], function() {
require(["xtext/xtext-ace"], function(xtext) {
var editor = xtext.createEditor({
baseUrl: baseUrl,
syntaxDefinition: "xtext-resources/generated/mode-mydsl1"
});
var data = {};
jQuery.get('http://localhost:8080/tom.txt', data, function(result){
console.log(result)
editor.setValue(result);
});
});
});


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Model display on load in XTEXT Web Editor [message #1748359 is a reply to message #1748334] Tue, 22 November 2016 13:01 Go to previous message
tom KIRKHAM is currently offline tom KIRKHAMFriend
Messages: 16
Registered: August 2016
Junior Member
Thanks again Christian,

This has solved my problem.

Cheers,
Tom
Previous Topic:Single Ecore domain model, two conflicting serializations, now what?
Next Topic:Problem while adding libraries to xtext Project
Goto Forum:
  


Current Time: Sat Aug 19 22:43:41 GMT 2017

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

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