GWT URL routing and other features - java

I am thinking about using GWT in my future project. I have few questions:
How can I define the structure of URLs? Does it allow me to recognize the parts of the URL by some information I have in database? How it is defined? Directly in Java or XML?
Does it support HTML5 history tools to change the URL without the necessity of using hashes?
Forms and editation of items in database - does it allow to generate Forms by definition and generate their validation, without the necessity of writing everything hard by hand?
Are there any tools for uploading files (images) in iframes, so that the page does not have to me reloaded? Drag'n'drop uploading? Are there any tools to simply manipulate uploaded images? Resize, crop...
Is it natively possible to create similar hover information like it can be seen on (for inst. when you hover an item on the left, there is an information bubble appearing on the right side):
http://goout.cz/theatre/prague/
Is it natively possible to create similar search dialog like on the page http://goout.cz - for inst. when you type 'a' it starts to suggest items in the database with their pictures.
All the GWT application I've found, run in browser rather as an JS application - but is it possible for javascript disabled browser to use them? Can search engines go through them?
Thanks

1. How can I define the structure of URLs? Does it allow me to recognize the parts of the URL by some information I have in database? How it is defined? Directly in Java or XML?
It's up to you to code it all (or almost all) by hand, in Java.
2. Does it support HTML5 history tools to change the URL without the necessity of using hashes?
It's possible to do it (quite easily actually) but GWT doesn't provide built-in support.
3. Forms and editation of items in database - does it allow to generate Forms by definition and generate their validation, without the necessity of writing everything hard by hand?
No. Editors cut the boilerplate by half, but you still have to build your forms by hand (but that's not a bad things: generated things never look or behave like you'd like to). And UiBinder helps creating UIs.
4. Are there any tools for uploading files (images) in iframes, so that the page does not have to me reloaded?
Yes.
Drag'n'drop uploading?
Not directly. There's support for native drag-and-drop, but not for accessing dropped files and uploading them. It's not hard to add though.
Are there any tools to simply manipulate uploaded images? Resize, crop...
The canvas API is supported but you'd have to do it all "by hand" (including, particularly, getting the image to draw it to the canvas, and then upload the canvas content)
5. Is it natively possible to create similar hover information like it can be seen on (for inst. when you hover an item on the left, there is an information bubble appearing on the right side): http://goout.cz/theatre/prague/
Yes.
6. Is it natively possible to create similar search dialog like on the page http://goout.cz - for inst. when you type 'a' it starts to suggest items in the database with their pictures.
Yes.
7. All the GWT application I've found, run in browser rather as an JS application - but is it possible for javascript disabled browser to use them?
No.
Can search engines go through them?
Google can, with little effort.

Related

Can you add a GWT screen to an already existing screen in a webapp?

Is it possible to add GWT as a component in an already existing webpage?
I don't know what exactly do you mean by component, but GWT can be integrated in any web page,since GWT output is (mostly) javascript. JavaScript can be used in any page. It doesn't matter if the page is existing or you are just planning to create it. If you can include js on that page, you can use GWT.
Perhaps this is what you are looking for ?
Running a GWT application (including Applets) inside an IFRAME from an ASP.NET 3.5 app?
I think the answer on that question is relevant.
Yes, GWT can be added to any existing webpage.
GWT's RootPanel will be the div you place on that webpage.
Hope this helps.
You need to understand the constraints of browser technology. Perhaps, you already do.
To, answer your question, you have to return back to ground zero - javascript.
Are you able to write a simple javascript object that runs as a "component" of your current app, such that there could exists a duplex communication between your simple javascript object and the canvas of your current app? Can your simple javascript object invoke and be invoked by features of your current app?
Knowing that GWT ultimately gets compiled to javascript, and if even a simple javacript object cannot function componentially with your current app, would you think there is any hope to componentize a GWT app with your current app?
Setting up a communication channel
Componentization would require ability to communicate.
Let us say, you need to write your combo app using both jquery and GWT. Your jquery side should be able to dedicate a HTML element into which it could write. Like a simple DIV, ensuring that the element has an ID. You could have several elements for such a purpose.
On the GWT side, your GWT code would be able to grab these elements thro getElementById. Voila! There are your communication channels.
GWT is a dominating possessive creature, for one reason - it refuses to create widgets thro which you could name with an ID (except for ensuredebugId). For that reason, it does not fare very well running as a component.
More likely, your GWT app is the master and your non-GWT apps are the component.
It is a very "well-practiced field" of having non-GWT apps running as components to a GWT app. We have charting, chat, clocks, widgets, etc components written in jquery, javascript and even server-side services. And then we write GWT wrappers around their elements and use JSNI to communicate with them.
All these non-GWT avenues of creating DOM elements and javascript objects have the common ability to generate elements that can have an Id, which makes them more susceptible to be componentized under GWT than the other way around.
Good examples are the Javascript APIs for Google Maps, Google Location API. e.g. HighCharts http://www.highcharts.com/.
All you need to do is to create a div in your existing web-page and give it an Id.
Then use the following to insert your component into that div.
RootPanel.get("PUT THE DIV ID HERE").setWidget(superCoolGwtComponent);
Simple :D

Templated correspondence generation using Java

I am looking for a way to create pixel perfect, paginated, styled correspondence in a Java web application.
The requirements for this functionality are
- Ability to define outer/ master template with header/ footer/ logo etc...
- Ability to define inner content template where specific variables/ fields can be substituted with instance values at run time - e.g. employeeName. employeeAddress. The content template would be defined online using rich text editor or something similar
- Supports tables/ list
I believe iText does most/ if not all. Other options that I have considered is BIRT. Are there other/ better choices for this purpose?
Thanks
I have done something like with iText, although our case did not use an online text editor (we had a small number of templates and they were defined as part of the development cycle)
[Note: We did this under an older version of iText when it was still LGPL rather than Affero GPL]
The results were excellent, but in order to get it pixel-perfect we had to do a lot of work ourselves. We did manual layout and pagination - including manual text wrapping, etc. The layout tools that iText provides looked good, but they didn't give us the pixel-perfect control that we needed for the use case we had.
Have a look at iReport.

Can I realistically move all templating to javascript for my webapp?

I have a Spring-MVC based webapp with a JSP front end. It is your basic CRUD app with various other management and reporting screens thrown in.
We are currently using JSP with JSTL for our view, but our designer doesn't know JSP so it's been a real pain to merge his design changes into the source. Due to that, my recent thought has been that if we could just hand the entire UI over to him and let him implement it entirely in HTML/Javascript, making ajax requests for JSON data for the dynamic portions, we would be able to remove that entire merge process and just host his static HTML files. Development for him would be simple as he would be able to hit our REST webapp on our test server for sample JSON data using jsonp.
If the designer is proficient with javascript, what would we lose by changing our spring-mvc webapp to only return JSON views and use jQote or jquery-tmpl to do all dynamic bits in the HTML?
Are there any deal breakers in going this route?
You'd just lose the ability to take advantage of JSP-based frameworks and templates. If:
your developer is proficient in Javascript,
you expect future developers in his place to be proficient as well, and
you are okay with making javascript a requirement for your site
then this can be a good strategy. The JSON will probably make your AJAX calls a lot faster than returning actual content would do. You'll probably be able to make the site a lot more responsive to user interaction.
The problem with injecting content via JavaScript is that search engines cannot see it. They get the page source as it is a load time. If this is an internal application that may not matter, but if it's a public-facing site it could mean very bad things.
You can build entire interfaces from JSON data and a bit of JavaScript on the client. As a technique it works quite well and is fast, but beware of the SEO implications.
One more point to add:
Say you are loading 300 rows of data to show, then you will have to load 100 row using JS and then show it to user.
It will mimic the streaming features. Content will be shown after request is populated.

HTML with JS to Image/PDF

Is it possible to convert an html page with charts generated by javascript to an Image or PDF in Java?
I familiar with iText framework and it seems to be suitable but I am not sure how it handle JS generated things.
A quick search turned up this as a possible answer.
Using a library to convert to XSL-FO then another one to convert that to PDF.
Edit: This might interest you as well. There's a bit on some JBrowser class that seems to let you print web pages.
It depends on how the were generated. I suppose three possibilities:
Canvas tag.
You need to add a bit of JS code to get image using toDataURL canvas method
SVG.
You can add some code to get the full code of generated SVG document via innerHTML method.
Flash.
The worst case. I think it's hardly possible to achive what you want.
Solution 1
If you have access to plain HTML (taken after the JavaScript has executed and built the page), you can easily pass it to iText and convert it to PDF. I would recommend using Flyng-Saucer (which in turn uses iText) which has a very good and convenient API for this (See http://code.google.com/p/flying-saucer/ ).
Solution 2
On the other hand, if you do not have access to the final HTML output, you could use the Swing libraries to render the page and then take a screenshot of it. This will allow you to even use Flash, but I'm not sure whether this approach will be suitable to your problem.
However, if it is the case, you can load the web page into a Swing application (you will need to rely on a third-party browser component for JS support, but there are quite a lot out there), and then you can use the Robot class to get a screenshot of it.
Take a look at http://download.oracle.com/javase/6/docs/api/java/awt/Robot.html

Highlight and Edit XML in a browser

Trying to provide a user with editable XML page in a browser.
For example, the following is part of an XML.
<Employee name="John Doe" type="contract" ID="1000">
<Salary>10000</Salary>
<Email>johndoe#johndoe.com</Email>
</Employee>
When the above is presented to the user in a brower (either IE or FF), the user should be able to highlight an attribute or the value. When highlighted and the second mouse button is pressed, this would pop up a menu for editing. For attributes and tags, it could be something like ID-TEST-PRESENT or ID-TEST-OPTIONAL. Now instead of ID, the attribute should change to ID-TEST-PRESENT when selected.
Likewise, for values, a text box can be presented, where the user can enter a new value. Then this updated XML file needs to be sent to the back end and saved.
Is this doable? If yes, what would be the easiest way.
I have always written embedded applications. This is my first foray on the web browser side. Any help is appreciated.
It is doable of course, but it's not trivial. At least not for someone who is not used to Javascript and manipulating the DOM. You would have to parse the XML and create a HTML document with Javascript event listeners on each element.
You could try and use an existing component and modify it if necessary. I found a similar question here:
https://stackoverflow.com/questions/378205/web-xml-editor-with-xml-syntax-highlighting
Unless you are dealing with generic XML files, you are probably better off just reading the XML and generate a standard HTML form. The simplest way would be to base everything on a database that will export to XML to the backend processes if needed. This makes it much simpler to add/edit multiple rows of data
One way to to create an interface for editing information in a particular XML vocabulary is to use XForms. (I think it is by far the easiest and best, but YMMV.) Given an appropriate infrastructure (see below), using XForms for what you describe would involve:
Write a form, using XHTML + XForms. Specify editing widgets for the parts of the XML you want the user to be able to edit; make other parts of the XML read-only (or don't display them at all). Define how you want the edited data to be submitted. Style using CSS.
When the user opens the form, the XForms processor loads the XML document automatically and provides editing widgets as specified in the XForm you specified in step 1. The user edits.
When the user clicks on the submit button, the browser sends the data back to the server as XML, and software on the server performs the necessary validations (this is user input from the open web, you do want to check it) and processes it appropriately.
As you can see, it's a little simpler than rolling your own using AJAX (at least once you have the infrastructure set up).
What infrastructure is necessary for XForms depends in part on which XForms implementation you are using.
For client-based implementations of XForms (such as XSLTForms from AgenceXML, or Formula from EMC), you need (a) a copy of the software on your server (in the case of XSLTForms, this means one XSLT stylesheet, one Javascript library, and one CSS file), (b) possibly an appropriate link in the form itself (how this needs to be done varies with the implementation), and (c) a server willing to accept PUT requests. In some contexts, it will be (c) that is the hardest to get set up, but any server that provides a WebDAV interface will do, so SVN with auto-versioning, Apache (alone or on top of Subversion), and other tools can all be used.
For server-based implementations (such as Orbeon Forms or BetterForm), you need to install the XForms implementation and run it on your Web server; since they are typically servlets, you will need to put them in a servlet engine. In general, they will ship with some form of WebDAV server included.
Steven Pemberton of W3C and CWI has written a helpful tutorial introduction to XForms; I maintain a list of pointers to that and to other XForms-related materials that may also be helpful.
In order to do this you would need to work a lot. To do generic editing you would need the following
XML parser at back end to parse XML file to 2 formats (A) To convert to the required HTML format for front end. (B) To convert into a required backend format. This is tricky and requires some thought. A brute force method is easy but very inefficient.
Setup an AJAX connection to your script which can take and recognize parts of the XML. For this you will need some mechanism to identify the part... may be an ID passed though HTML.
The interface for AJAX should the update the Database/file and do the needful.
This is a simple layout. It needs a lot of work to be done. Do some research
item
codemirror seems to be the best one
The jquery.xmleditor might be what you are looking for. They offer a graphical UI for editing XML. For the text-based XML editor, they rely on the Cloud9 editor. Be aware that Cloud9 is GPL licensed.
LiveXMLEdit is more an explorer-like editor, but maybe it helps, too
AXEL is a library for creating XML authoring applications based on document templates.

Categories