Building and deploying Dojo widgets - java

I've written some basic widgets within a Java web app I've built using Maven. I've referred to the Dojo documentation here:
http://dojotoolkit.org/documentation/tutorials/1.9/recipes/custom_widget/
to create them. What I want to do now is deploy them separately and access them from my original web app, but I haven't found a complete example on how to do this. Ultimately, I'd like to pass data to the widgets from my web app. This is my first attempt at widget programming, and I picked Dojo to create my first examples. It's also my first time using Dojo, as I normally use jQuery for any front-end work I do.
I'm using:
Java 1.6 and Spring 3.2 to build the web app
Maven 3.1.4
Dojo 1.9.2
Any pointers and/or links to tutorials much appreciated!

You can deploy the Dojo widget code seperately as a web application/resource bundle. Then in your main web application you just have to define the path to the external web resource, I suggest reading following articles:
Advanced AMD Usage (especially the part "Configuring the loader")
Configuring Dojo with dojoConfig (especially the part "loader configuration")
You can configure your Dojo packages using:
var dojoConfig = {
packages: [
{ name: "myWidgets", location: "/MyDojoResources/myWidgets" }
]
};
Then, if you use the following code in your web application:
require(["myWidgets/aWidget"], function(aWidget) {
// Use "aWidget"
});
The Dojo AMD loader will then load the file from /MyDojoResources/myWidgets/aWidget.js. So if you deploy your widgets under the /MyDojoResources context, it will work fine.

Related

Java template project for Automation Testing for a new WebApp? In any framework

Can anybody suggest me any preset template project for a new web application?
Using Java and Selenium Webdriver I’m looking for a skeleton project with preset pages and basic methods for automation. For pages like LoginPage, BasePage etc. With list of web elements, which will be corrected and specified of course.
Framework could be like Gauge, Sahi, TestNG or something similiar.
What I need is a template project, to not start from absolute scratch. Thank you for any help.
If you have maven installed in your machine. Then you have to just run two commands to get the skeleton project in a given directory.
mvn archetype:generate
Enter project template code : 978 (testNG based)
Input groupId , artefactId, version and packaging type. After few seconds, you shall get a template project in your directory.
I am often in the situation where I ask myself "how do I rapidly prototype a java & maven web app with login and basic authentication?"
Using Java and Spring Boot, you can follow one of the tutorials on Spring website, such as: https://spring.io/guides/gs/securing-web/. It's a partial response to a question that is a little bit too broad.

How to Integrate SpagoBI server in Grails or Java application

I want to Integrate SpagoBI server in Grails or Java applications. I have developed some report in SpagoBI server and it is working fine. The same reports I want to display in Grails or Java applications.
You can use the SpagoBI SDK to integrate it in your web application (especially Java). Take a look here: http://wiki.spagobi.org/xwiki/bin/view/spagobi_sdk/
The SpagoBI SDK download contains examples of using the JavaScript tag library and Java libraries for retrieving available reports, executing, and displaying the report
You can also see a code sample I posted previously at the link below. It uses JSP and the SpagoBI Java library to execute a specified report (by label) and return a PDF or XLS.
http://www.spagoworld.org/jforum/posts/list/3592.page

Vaadin project compilation and execution

I have a little question on how Vaadin and GWT works. When I develop my views using Vaadin or GWT I only write Java code. But when does my Java is generated into HTML and JS files ? During the compilation of my project or on runtime ?
I tryed to find this information on the Vaadin guide but I didn't found anything yet :(
edit:
Not really duplicate of Cannot run mvn vaadin:compile on Vaadin Maven project, I don't have a problem with the code or execution of my project but for myself, I just wanna know when does Vaadin or GWT generates its HTML and JS files ? During the Maven build itslef or on runtime, on demand only?
In vaadin you have to distinct two things:
Backend is written in Java and is run on a servlet engine like Tomcat, Glasfish,...
Frontend is written in Java, GWT or Javascript
For the backend the java compiler just creates the .class files from the .java source code
For the frontend, the java code is GWT based, and thus compiled into highly optimized javascript code, this happens in the "Compile/Build Widgetset" phase ob your build process
Frontend code can also be written in javascript, this is then passed as is to the browser, but with the addition of some logic to connect the JS components to it's serverside part.
The generated frontend javascript code is then also responsible to build the html content.
The Vaadin Architecture

What does Java Web Start Run?

What UI Framework does Java Web Start use? And where can I begin development for it? I'm running Netbeans but I'm fairly confused as to how Java Web Start works
JWS can launch any rich client UI framework. That means a J2SE based (J)Frame, or (J)Applet, or if you provide the necessary classes and natives on the server and specify them in the JNLP file, an SWT based UI.
Perhaps it would help to play about with some self contained JWS examples. You can find a number of them in my JNLP API demo. page, which provides a zip archive of the complete source (JNLP, .java & an an ant based build file) of each demo.
Netbeans should be able to deal with Ant based projects with ease.

Build a JS server inside of Java for Google AppEngine

I just needed to create a little interface for a project. So I decided to take given code and to run it on Google AppEngine. My problem is, that I'm experienced in JavaScript and got some basic knowledge of Java, but I got no clue how a Java webapp has to be structured. I started Eclipse and installed the AppEngine-addon, downloaded Rhino and env.js (which is necessary for the bunch of code I need to run) but then found me in the situation of sitting on this files not knowing where to put them.
It would be great if someone could tell me in which directory to put which files for Rhino (I assume it's "/war/WEB-INF/lib/"), how to add the env.js-file and how to access all these files inside the .java-file which is the index of the app.
I don't know about app engine in particular, but I have had good success using Rhino jsc to compile script files which extend the Servlet API. The end result is a nice WAR file which you can deploy in any servlet container, and perhaps App Engine as well. See here for my relevant blog post about this technique, and here for a sample Eclipse project.
Have you taken a look at this tutorial on running Rhino on GAE?
It's a link from the official "Will it play in App Engine?" thread.
http://www.appenginejs.org/ may be of interest as well.

Categories

Resources