Help us continue to make it better
Service definition
public interface HelloWorldService
{
public abstract String getGreetingsFor(String name);
}
Service implementation
public class HelloWolrdServiceImpl implements HelloWorldService
{
public String getGreetingsFor(String name)
{
return "Hello " + name + "! (" + new Date() + ")";
}
}
Service consumer - GUI
@PageAlias(alias= "helloworld")
public class HelloWorldPage extends DragomeVisualActivity
{
HelloWorldService helloWorldService= serviceFactory.createSyncService(HelloWorldService.class);
public void build()
{
final VisualLabel<String> label= new VisualLabelImpl<String>("message");
final VisualButton button= new VisualButtonImpl("button", v -> label.setValue(helloWorldService.getGreetingsFor("World")));
mainPanel.addChild(label);
mainPanel.addChild(button);
}
}
HTML
<html>
<head>
<script type="text/javascript" src="dragome/dragome.js"></script>
</head>
<body>
Message: <b data-template="message">text</b> <br>
<button data-template="button">Say hello!</button>
</body>
</html>
You can start a servlet container using this maven command:
mvn jetty:run
To run any Dragome page you need to start it calling a HTML file that includes “dragome.js” file.
<script type="text/javascript" src="dragome/dragome.js"></script>
In case you want to debug some part in js, you can use a separated version of js files including the following instead:
<script type="text/javascript" src="dragome-resources/dragome-debug.js"></script>
Since HelloWorldPage class has an associated @PageAlias annotation with value “helloworld”, you can find this page in the following URL:
http://localhost:8080/my-app1/run.html?helloworld
Also in case your html file name is the same than the associated alias you could execute the application like this:
http://localhost:8080/my-app1/helloworld.html
This URL will execute the page in production mode (running everything on browser), but if you want debug it in Java you may add a query string “debug=true”
http://localhost:8080/my-app1/run.html?helloworld&debug=true