How to make GWT templates?
I'm new to GWT and I would like you to help me make the right decision. My job is to make a GUI with GWT,it was easy to use it because I know a lot of concepts that resemble those of Java / Swing ... The problem is that i want to have an homogeneous site with my teammates and i didn't find any concept similaire to template or facelets... How can i do this?? thank you in advance f开发者_JAVA百科or your help
Template in web app sense means that somebody else (template engine) is building view hierarchy for you, you just plug-in some components and logic.
With GWT you could:
Use a template engine (or build your own), that takes some UI description (usually XML) and then builds the widget tree for you. The downside would be that designers should learn this UI description language (unlikelly) or every time the design changes you'll be translating HTML to this UI language.
Use HTML as template, mark relevant parts with
id
and/orclass
and then just insert your GWT components/logic into marked places by your GWT code. This is much more designer friendly, but full widget hierarchy is not built by GWT. This means you'll need to attach/detach your widgets to DOM by hand (google around forComposite.onAttach()
andonDetach()
).Use HTML as template, mark relevant parts with
id
and/orclass
, but instead of creating and inserting GWT components, use pure HTML elements provided by designer. This means designer should provide all details: buttons, tables, everything. Then use gwtQuery to do do all HTML interaction: finding element, copying/manipulating them and adding event handlers.Since GTW is one-page app, all relevant HTML must be put into single file (gwt host file). I put them in tip-level divs and but set
display:none
on them so that don't show up. When I need them, I just copy them to where needed and display them.
精彩评论