GWT and web template with javascript - gwt

I have GWT Web application and web template that consists of html+css+javascript files.
UiBinder holds html template in HTMLPanel. Problem is that this template is based on many javascript files and I know that GWT have problems with that. So my page is rendered without some javascript features.
What can I do with this? What is correct solution for GWT and external web templates?

The issue is not GWT-specific: you cannot inject <script>s using innerHTML (which HTMLPanel ultimately uses).
If you need to dynamically inject scripts in your app, then use ScriptInjector.

Related

Google Web Toolkit - UiBinder

I am new in GWT. I want to ask some questions about UI binder:
<ui:with field='res' type='com.my.app.widgets.logoname.Resources'/>
(1) Refer to code above. What is the meaning of type? Is meant the file location?
(2) Why need to use external resource for the UI binder?
(3) When I write css, in java file should I need to write the "extends CssResource" word?
I really don't understand. Please help me to answer the question. Thanks.
<ui:with field='res' type='com.my.app.widgets.logoname.Resources'/>
Refer to code above. What is the meaning of type? Is meant the file location?
Here type is equivalent to below java code
Resources res = new com.my.app.widgets.logoname.Resources();
Why need to use external resource for the UI binder?
Sometimes your template will need to work with styles or other objects that come from outside of your template.
When I write css, in java file should I need to write the "extends CssResource" word?
Yes you have to use extends CssResource
For detailed explaination and samples please have a look at GWT UIBinder - Using an external resource.
Find a sample code here about GWT - Using UiBinder.
Here is the key points of using UIBinder:
The UiBinder is a framework designed to separate Functionality and View of User Interface.
The UiBinder framework allows developers to build gwt applications as HTML pages with GWT widgets configured throughout them.
The UiBinder framework makes easier collaboration with UI designers who are more comfortable with XML, HTML and CSS than Java source code
The UIBinder provides a declarative way of defining User Interface.
The UIBinder seperates the programmic logic from UI.
The UIBinder is similar to what JSP is to Servlets.

How to add jquery in GWT page

I have a GWT Application , I need to add Jquery in my GWT
as i wish to have HighCharts in GWT and for that i have to have Jquery coz HighCharts need them for that purpose I need to have Jquery in my Page
How to add Jquery in my GWT Page ?
Thanks
You should probably use gwtQuery instead. It's a port of jQuery written for GWT.
If you really think you need to use jQuery, download the js from their site, add it to your war directory, and reference it in your entry point's HTML file.
you can use jquery in gwt application easily using native method.
you have to add js files in html page and than create class that contain only JSNI methods and jsobject and you can easily use jquery in your gwt application
you can easily learn from http://code.google.com/p/gwtquery-ui/

Adding gwt Tag inside GSP Page

Is it possible to include gwt tags into gsp page. I've installed gwt grails plugin but I haven't been able to achieve this yet.
Its possible to include dojo tags into gsp page after u install the dojo grails plugin
I think you're mixing up the context where these tags are supposed to be used.
GSP tags are for creating a server-side template that will be rendered and sent to the browser as completed HTML. GWT's ui:binder tags are for creating a template that's compiled by GWT and used to generate a page on the client-side within the browser. They operate in two different realms.

GWT and templating engine

I want to design a website using GWT. This is my understanding of how GWT pages will be delivered to the client browser - When the user puts in the URL into her browser she receives all the static HTML + GWT javascript, and then the javascript queries the server for the dynamic page content and adds it to the DOM. eg - For a blog page the content of the blog is queried by the javascript. is my understanding correct?
If I know that the content will surely be a part of the page(add does not depend on user clicking an expand button etc.), Will it be more efficient if the blog content was a part of the HTML initially served? Something that could be done by using a templating engine like django.
Is there a way to make a templating mechanism in GWT?
Yes, putting your content into the HTML will reduce the number of round trips the client makes to your server. It also means that the blog content won't have to wait for your GWT javascript to load before it can be displayed.
GWT itself isn't useful for a template system, but most servers that run GWT servlets will also support JSP pages. GWT works fine with these pages, you just need to put the GWT script tag in as usual. You will no doubt be able to find a ready-made templating solution but rolling your own is not too hard.

GWT/java and javascript

can i design my web pages in html and css instead of java methods and use gwt only in parts of page that i need ajax? and which one is better gwt, extgwt, vaadin(it run apps in server-side.can i also use it in client-side?), etc...? do i also need to know javascript for using gwt?
thanks
can i design my web pages in html and
css instead of java methods and use
gwt only in parts of page that i need
ajax?
Yes, you can. You can create a div on your HTML page and insert your GWT widget there.
which one is better gwt, extgwt,
vaadin(it run apps in server-side.can
i also use it in client-side?)
I don't know about vaadin but Ext-GWT is a set of ready made components to use with GWT which make your life easier especially if you want to build an web app that looks and feels like a desktop application.
do i also need to know javascript for
using gwt?
No, it can be useful sometimes but is not necessary.