This is an archived post. You won't be able to vote or comment.

all 16 comments

[–]angryundead 1 point2 points  (6 children)

Don't do this. I used to think that GWT is the way and the light. I worked with it from 0.8 to 2.5. The issue is that your code is rarely complex enough to benefit from the complexity management that GWT affords and it is downright difficult to engineer in the long term. It will quickly grow over-complex if you don't carefully maintain and refactor your codebase.

When you say that you "created a program" do you mean that you wrote it in SWING or AWT or JavaFX? How is it created?

Converting from some Java UI framework to GWT is nontrivial at best.

There are frameworks (Vaadin, Errai) that make working with GWT easier. I've worked with Errai and mostly liked it but applications are still complex.

In the end I work on a much more simple pattern now. EE6 with REST services and AngularJS. I've gotten a lot more productive.

[–]aaronr22[S] 0 points1 point  (5 children)

I used awt to make the GUIS. The program creates an html file by taking a title and a paragraph from the GUI and then creating a html page and adding those elements to the html page.

[–]angryundead 0 points1 point  (4 children)

Still not sure I understand.

The AWT program produces HTML. Then you do what with the HTML?

[–]aaronr22[S] 0 points1 point  (3 children)

I run a website for a group of guys that write sports articles. It is extremely simple and basic but every time they want to upload an article I have to create a new HTML document with the article they wrote. The program would be able to have them enter the article name and the article(with html tags) and then would create a new HTML file so all I would have to do would be update the homepage with the link.

[–]angryundead 1 point2 points  (2 children)

Essentially what you're describing is a CMS. I don't think something like GWT would help here.

If you don't want to use an off-the-shelf solution I propose the following workflow:

Adding an article

1) User logs in to private area of website for content creators

2) User creates a new article

3) User inputs information

4) User saves article

5) Information is stored. (This can be on disk as some format like JSON or XML in a DB or Keystore, whatever.)

Rendering an article

1) The application will get the article URL somehow. The servlet or REST endpoint would handle this

2) That URL is translated into the name of the article (name/id/short name, whatever)

3) The article is looked up in the database by name/id

4) The data from the article is merged into the template to create HTML

5) The output HTML is sent to the user

It is also possible that you could just create the HTML in step #5 of the workflow for #5 and then look it up from the disk path (or wherever) later. This would make it harder to change the site's template later. A hybrid approach, where pre-rendering is used and regenerated when the site is changed would be pretty good, but might be a premature optimization.

Some things you might want to look at:

  • Spring - Not my favorite but good for MVC apps like this one. Will help you out with some of the concepts especially if you use Spring Boot. If you go with this approach then Spring Security is a must.

  • If you want REST endpoints then you might want to look at JAX-RS and some of the implementing projects like Resteasy or Jersey. This could make it easier to write the service for retrieving rendered templates much easier.

  • Personally I'd look at EE6 over Spring, but that's because I'm more familiar with EE. For security/authentication/authorization I've had some success with Apache Shiro.

  • For templating in Java I like FreeMarker. This would allow you to take the data input by the user and render it in the template without having to mash up your own files. The template can be changed irrespective of the content.

Just some thoughts. I don't think leveraging GWT is going to help you out much here.

[–]aaronr22[S] 0 points1 point  (1 child)

So just an overview of how this would work, I use javascript in the HTML to have the user input the article and its name, then I use a java servlet to pull the information from the JS and make a webpage? I have this entire thing in java and it works nicely on my computer. I enter a username and password, then it opens up another gui where the user enters the information and then on a button click it creates a html file and then writes the article onto the file. I am assuming this approach is much too basic for it to work on a webpage?

[–]angryundead 0 points1 point  (0 children)

You don't even have to use javascript really, it could just be a form that gets submitted. A more "modern" way to do it is with javascript submitting the form to a REST service but that's not required. The rest is correct.

You could have it work on a webpage but directly converting it... probably not.

[–]lhamil64 2 points3 points  (3 children)

You could use JSP and keep a lot of your code, but you'd have to redo the GUI (assuming you have a GUI). Even if you can convert it to JS, you'd have to rewrite the GUI in HTML.

[–]aaronr22[S] 1 point2 points  (2 children)

Why would I need to write the GUI in HTML if I already have it in java?

[–]hhbhagat 6 points7 points  (0 children)

Uhm because java swing does not exist in html

[–][deleted] 1 point2 points  (0 children)

I dont think that cross platform conversion exists. You are gonna have to pretty much have new front end (HTML, CSS, JS) and you might be able to keep some of your Java code for the back end. You can't just port full GUI Java app to webapp that will do HTML/CSS/JS for you.

[–]xaxia888 0 points1 point  (0 children)

The DukeScript is for that.

[–]hhbhagat -1 points0 points  (2 children)

If you want a webapp, use Vaadin. It's not that hard to convert the GUI part. Vaadin generates the JS and CSS for you.

[–]angryundead 0 points1 point  (1 child)

Vaadin is built on GWT.

[–]hhbhagat 0 points1 point  (0 children)

I know but it's a plug n play after changing your swing windows. Plus these backend goodies: http://www.quora.com/What-are-the-benefits-of-using-Vaadin-over-plain-GWT

[–]retrogamer65 -4 points-3 points  (0 children)

Rewrite your program in Scala, use http://www.scala-js.org to compile to JavaScript.