开发者

Using GWT with SEAM

开发者 https://www.devze.com 2023-03-27 02:09 出处:网络
I want to use GWT with seam Framework, so i add the jar gwt-user-2.2.0.jar to my project. but when i invoke any method from the view (a xhtml page ) this exception is occured:

I want to use GWT with seam Framework, so i add the jar gwt-user-2.2.0.jar to my project. but when i invoke any method from the view (a xhtml page ) this exception is occured:

Caused by: java.lang.UnsupportedOperationException: ERROR: GWT.create() is only usable in client 开发者_JAVA技巧code! It cannot be called, for example, from server code. If you are running a unit test, check that your test case extends GWTTestCase and that GWT.create() is not called from within an initializer or constructor. at com.google.gwt.core.client.GWT.create(GWT.java:92) at com.google.gwt.user.client.ui.UIObject.(UIObject.java:188) ... 84 more

I use seam v2.2,I can post the code :

    @Name("scheduleHandler1")
public class SheduleHandler1 implements Serializable,EntryPoint
{   
public void onModuleLoad() {
        MyPopup p = new MyPopup();

            RootPanel.get().add(p);
          }

From my xhtml view i call this method:

 <h:commandLink value="showPopup" action="#{scheduleHandler1.onModuleLoad}" />

Thanks for Help.


GWT is client side technology - the java code that you write compiles down to js+html and is executed inside the browser.

OTOH, SEAM is server side technology - code that you write executes on server when a request is made and the HTML is produced which is returned back to browser for display.

In this sense GWT and Seam do not go well together. Most certainly you can not mix the code in the same compile unit.

You could use Seam for server side REST and GWT on the client side to consume REST, but this would only make sense if you already had an existing Seam REST code.

If you have written some GWT code and want to include it in you html pages (static or produced by Seam) then use them as GWT host pages - you simply include script tag to include GWT js code in the page: http://code.google.com/webtoolkit/doc/latest/DevGuideOrganizingProjects.html


GWT and Seam can actually work together, as you can see in this page in the Seam Reference Documentation.

However, what it looks like you are trying to do, and where the problem looks to me, is that you are trying to mix JSF and GWT. You are trying to call a Seam action from JSF where that action calls some GWT code. Hence, your server side Seam code is calling the client side GWT code and you are getting the exception that says GWT.create() is only usable in client code! It cannot be called, for example, from server code. I'm not sure why you're trying to do this.

JSF is a client side technology, written in XHTML. GWT is also a client side technology written in, well, Java. I'm not sure how these play together.

On the other hand, there is no reason, as per the link above, why your GWT widgets cannot call your Seam components. You just need to follow the instructions.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号