Reputation: 317
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?
Upvotes: 3
Views: 2998
Reputation: 3658
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="[email protected]">
<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.
Upvotes: 7
Reputation: 1836
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?
Upvotes: 2