当前位置: 动力学知识库 > 问答 > 编程问答 >

java - 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

分享给朋友:
您可能感兴趣的文章:
随机阅读: