Question

I want to realize a MVP gwt application using this external HTML template.

Is it possible create HTML pages and use them in a gwt project instead of write java code in "view" classes to produce HTML?

Was it helpful?

Solution 2

The closest thing you can get to HTML in GWT is UiBinder

At heart, a GWT application is a web page. And when you're laying out a web page, writing HTML and CSS is the most natural way to get the job done. The UiBinder framework allows you to do exactly that: build your apps as HTML pages with GWT widgets sprinkled throughout them.

Creating lots of HTML pages is not really what GWT is about. It uses a single HTML page and loads your GWT pages in there using JavaScript.

If you want a Bootstrap theme, you can use GWTBootstrap3, or GWT-Bootstrap (still runs bootstrap 2) perhaps?

OTHER TIPS

I'd like also to mention HTML Module of JBoss Errai project as it allows to write a valid html 5 templates and wire them to GWT Java classes. for example here's the code:

ComplaintForm.html

<div class="complaint">
 <input id="name" type="text" placeholder="Full Name">
 <input id="email" type="email" placeholder="you@example.com">
 <textarea id="text" placeholder="How can we help?"></textarea>
 <button id="saveButton">Save</button>
</div>

ComplaintForm.java

@Templated @Page
public class ComplaintForm extends Composite {
  @Inject @Model Complaint complaint;
  @Inject @Bound @DataField TextBox name;
  @Inject @Bound @DataField TextBox email;
  @Inject @Bound @DataField TextArea text;
  @Inject @DataField Button saveButton;

  @EventHandler("saveButton")
  public void onSave(ClickEvent event) {    
    sendComplaintToServer(complaint);
  }
}     

as you can see there's even no need of instantiating of the widgets.

and there's a lot of more stuff.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top