Standalone GWT Deployment - gwt

So, this is a pretty trivial thing to accomplish apparently, but for some reason it just will not work for me. I created a VERY SIMPLE GWT app. It uses UIBinder just to display a label and a button, no actual processing or handling takes place. I did this to test deploying the app using strictly JS and html that is not hosted by Eclipse and Jetty or whatever.
I compile my app, run it in eclipse, and it works fine. However, when I try to run the html page directly from the WAR directory, it does not work.
Do I need this running on a webserver for it to work? It is just html and js, so I shouldn't? I've been to the GWT site about deploying, and surfed quite a few forums. They seem to always mention the necessity of a server, but it seems like it should not be necessary?

Since it is a pure JavaScript and HTML it should work properly without server. Checkout this link: Compile and run in Production Mode with Eclipse

In your EntryPoint class, in onModuleLoad() there's a RootPanel.get("someDivId") call somewhere. Make sure your html page (=the host page) contains a div with that id.
Also make sure your host page calls the right java script file. It's easy to forget to edit the host page after you renamed your GWT module (see rename-to in your .gwt.xml), as the generated JavaScript file matches your module name.

This will work locally on all browsers except Chrome for security reasons.
See http://code.google.com/p/chromium/issues/detail?id=31068
and http://code.google.com/p/chromium/issues/detail?id=70088

Related

How to run Inferno JSX on server?

I am trying to use Inferno to render on the server. The documentation inferno-server and server-side-rendering does not say show to set-up babel & run the sever.
All I could find is InfernoJS Babel Plugin but noting about running it on Node.
Any help would be appreciated.
Could you explain what you mean by "Running on node"?
Inferno Babel plugin converts the JSX code into a regular JS code, which runs without problems on node (the server uses renderToString). While you are not using browser elements (document and other tools), everything should be fine.
Then you need to make a separate component for the client, which when requested will be given as a bundle along with the html page, and then using hydrate function to "cling" into webpage and bind items.
you can check my repository (although this is for TypeScript): https://github.com/MrFoxPro/inferno-isomorphic-tempalte

Umbraco with Windsor Castle error after adding nuPickers plugin

With an existing Umbraco site running fine we added the nuPickers plugin which does not seem to like Castle. In the browser console we are seeing a lot of 404 / 500 errors being generated for the embedded resources within the plugin. (The plugin is a single DLL with css and js files embedded in it.)
The site continues running fine (back and front ends), except for the plugin.
The Event log is showing: "No component for supporting the service nuPickers.EmbeddedResourceController was found"
We have tried route.ignoreroute in our route config, and also adding a handler in web.config, both unsuccessfully, as we do not think the resource requests should be getting to castle?
Any help or pointers gratefully accepted!
Just in case anyone comes across this ticket, we 'solved' this by
Getting all of the embedded resources, (html, js & css - not the classes)
Physically placing them inside the App_plugins folder in the correct structure (as they were being requested),
Renaming the js and css files (by adding the .nu after the file
extension), and,
Adding the following mime types into the web.config
mimeMap fileExtension=".css.nu" mimeType="text/css"
mimeMap fileExtension=".js.nu" mimeType="application/javascript"
Then, everything seems to work - but there MUST be a better solution, surely?

SmartGWT DataSource adding QueryString to REST call

So, I have a Spring-MVC RESTful backend, that is cross-domain enabled. It is unit-tested, I can call my web-services and get back the correct JSON.
I have a SmartGWT 5.1p and GWT 2.7.0 front-end application that works great in SuperDev mode or Classic Dev Mode, either works great. When I do this, I am using the old Firefox 24 browser with the GWT plugin, and I can see my app work just great. My datasources are tied to RESTful web-services, and I can create, retrieve, update, and delete records via my DataSources.
I can compile the whole app via Maven, and get a WAR created just fine. I tried moving this WAR over to a tomcat server, and it deploys correctly. I can see the app running in tomcat with no errors in the logs.
Then when I go to the first page, the app comes up s normal with no errors. The first thing I do is add a username and password into a form, and then it is supposed to call a LoginDataSource which is tied into a LoginCOntroller, or login web-service.
What I can see from firebug is that when I make my call, rather than just calling:
http://mydomain:8080/admin/login/user/myusername/pwd/mypassword
I get:
http://mydomain:8080/admin/login/user/myusername/pwd/mypassword?0{and a whole lotta stuff after this) ... the query string I presume.
When I hit the Submit button, I get a SERVER TRANSPORT error, and that's it, I don't get any more information that that. There is nothing else to report from firebug except that the OPTIONS and GET add a whole lot of query string nonsense after the password.
I can look in the tomcat logs, and I don't see any errors in there at all. I don't even see the URL call to the web-service.
Any help on this would be much appreciated. I've been dealing with SmartGWT for years, and switched to back-end development for a while, and not I am trying to make my SmartGWT front-end work as well. But, I am a little rusty as to what is happening now.
Thanks!
The problem is not the querystring, it's the old base url I have in the datasource. There is a method in each datasource called: getServiceRoot
In getServiceRoot, I was using a hardcoded "localhost:8080", which in client code that doesn't work. That means whoever is running the app in their browser, "localhost" means their machine. So, I had to change the getServiceRoot to do the following:
protected String getServiceRoot()
{
String baseUrl = "http://" + Window.Location.getHostName();
return baseUrl + UrlConstants.SOME_URL_REST_ENDPOINT;
}
Since I have two WAR's on the same machine;
one WAR is a Spring MVC back-end RESTful web-services
the other WAR is the front-end, SmartGWT client application
This is a problem I run into ... I think just because both are on the same machine, that to the front-end, just call the code on the localhost, because it is there. But to the browser, that could be any other machine.
I suppose I could have just hard-coded the public IP address of the machine running tomcat, and then the client-side SmartGWT would then certainly find the RESTful web-services. Or, I could have used a Spring Env Profile to make that happen as well. But the code change I made should work, provided both WARS are on the same machine.
I just got to remember that client-side code in a browser is relevant to the machine the browser is running on.
So, this is fixed. If anyone needs any clarification, please let me know.

merge large existing web app into Sailjs site

I'm trying to merge large existing web app into sails.js. so I moved the folders into assets and build a custom route , 'GET /': '/assets/client/launch.html' and get 404 when I point my browser to http://localhost:1337/ as the / is correctly redirected to http://localhost:1337/assets/client/launch.html which produces the 404.
Now the file exists in the folder assets/client (and in .tmp), so I am thinking the Sails router is getting in the way.
I would leave the client (70K lines of JS) that generates all the UI dynamically and sailjs server that provides authentication separate and enable CORS but my customer wants client packaged with server. This type of operation is simple in frameworks like ASP.NET MVC but am wondering if Sails is up to the task.
Well, If everything you tried did not work out. There might be another solution ,
First of all since you are talking about sails app I am assuming other bundle must be sails as well ,
So here is what you do-
Change the port for another app that you want to attach to this.
Second whenever you want to go to page on another app simply redirect the client to another port ie
in html or esp put a href tag with different port.
<a href="localhost:PORT/route_to_file">
</a>
I got it working by placing my app into assets where we need to launch from assets/client/index.html as there would be too many dependencies to change. As I said above could not just add a route as Sails must getting in the way. However as in Chapter 3.2.2 of Sails in Action I generated a static asset npm install sails-generate-static --save. then I redirected to assets/client/index.html. As an aside that book is great and would highly recommend it.

Making GWT application crawlable by a search engine

I want to use the #! token to make my GWT application crawlable, as described here:
http://code.google.com/web/ajaxcrawling/
There is a GWT sample app available online that uses this, for example:
http://gwt.google.com/samples/Showcase/Showcase.html#!CwRadioButton
Will serve the following static webpage to the googlebot:
http://gwt.google.com/samples/Showcase/Showcase.html?_escaped_fragment_=CwRadioButton
I want my GWT app to do something similar. In short, I'd like to serve a different flavor of the page whenever the _escaped_fragment_ parameter is found in the URL.
What should I modify in order for the server to serve something else (a static page, or a page dynamically generated through a headless browser like HTML Unit)? I'm guessing it could be the web.xml file, but I'm not sure.
(Note: I thought of checking the Showcase app provided with the GWT SDK, but unfortunately it doesn't seem to support serving static files on _escaped_fragment_ and it doesn't use the #! token..)
If you want to use web.xml, then I think it won't work with a servlet-mapping, because the url-patterns ignore the get parameters. (Not 100% sure, if there is another way to make this possible.)
You could of course map Showcase.html to a servlet, and in that servlet decide what to do, based on the get parameter "_escaped_fragment_". But it's a little bit expensive to call a Servlet just to serve a static page for the majority of the requests (not too bad, but still. You could set cache headers, if you're sure that it doesn't change).
Or you could have an Apache or something in front of your server - but I understand, I wouldn't like to have to do that either. Maybe your JavaEE server (which one are you using BTW?) provides some mechanism for URL filtering before the request gets passed on to the web container - I'd like to know that, too!
Found my answer! The Showcase sample supporting crawlable hyperlinks is in the following branch:
http://code.google.com/p/google-web-toolkit/source/browse/branches/crawlability/samples/showcase/?r=7726
It defines a filter in the web.xml to redirect URLs with the _escaped_fragment_ token to the output of HTML Unit.