Re: Webbrowser game made with GWT 2.0: lacesfirst.com
Ohh, I almost forgot... your SessionBean has to implement your GWT RemoteService interface (not the Async one!) ofcourse.. On 8 jan, 19:19, Fushion wrote: > Assuming a setup with Eclipse, I did the following: > > * Create file /src/jndi.properties: > > java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory > java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces > java.naming.provider.url= > > > * Create file /war/WEB-INF/jetty-web.xml: > > > > "http://jetty.mortbay.org/configure.dtd";> > > > > > java. > javax.servlet. > javax.xml. > org.mortbay. > org.xml. > org.w3c. > org.apache.commons.logging. > org.apache.log4j. > org.slf4j. > > > > > > org.mortbay.jetty. > org.mortbay.start. > org.mortbay.stop. > > > > > > Create a servlet which will forward all requests to a SessionBean on > the JBoss Server: > > public class RemoteEJBProxyServlet extends RemoteServiceServlet { > > protected InitialContext ctx; > > @Override > public void init() throws ServletException { > > super.init(); > > try { > this.ctx = new InitialContext(); > } catch (Exception e) { > System.err.println(e.getMessage()); > throw new ServletException("Could not create > InitialContext", e); > } > } > > @Override > public String processCall(String payload) throws > SerializationException { > try { > // Get the session bean > Object bean = ctx.lookup(" SessionBean>"); > > // Decode the request and test if it is legal > RPCRequest rpcRequest = RPC.decodeRequest(payload, > bean.getClass(), > this); > > // Invoke the requested method on the bean and return > the encoded > (=RPC serialized) result > return invokeAndEncodeResponse(bean, rpcRequest, > rpcRequest.getSerializationPolicy()); > > } catch (NamingException ex) { > ex.printStackTrace(); > return RPC.encodeResponseForFailure(null, new > Exception > (ex.getMessage())); > > } catch (IncompatibleRemoteServiceException ex) { > ex.printStackTrace(); > return RPC.encodeResponseForFailure(null, ex); > } > > } > > private String invokeAndEncodeResponse(Object target, RPCRequest > rpcRequest, SerializationPolicy serializationPolicy) throws > SerializationException { > > String responsePayload; > > Method method = rpcRequest.getMethod(); > Object[] args = rpcRequest.getParameters(); > > try { > Object result = method.invoke(target, args); > responsePayload = > RPC.encodeResponseForSuccess(method, result, > serializationPolicy); > } catch (IllegalAccessException e) { > throw new SecurityException(e); > } catch (IllegalArgumentException e) { > throw new SecurityException(e); > } catch (InvocationTargetException e) { > Throwable cause = e.getCause(); > responsePayload = > RPC.encodeResponseForFailure(method, cause, > serializationPolicy); > } > > return responsePayload; > } > > } > > > > Also make sure that the J2EE Server libraries are included in the > Eclipse Run Configuration of your GWT Development Mode. > These are needed by Jetty to connect to the J2EE Server. > In the case of JBOSS these are all of the JAR files in "/ > client" and "/common/lib". > > Greetz, > > Menno. > > On 7 jan, 17:31, mariyan nenchev wrote: > > > > > Could you give us small step b
Re: Webbrowser game made with GWT 2.0: lacesfirst.com
Assuming a setup with Eclipse, I did the following: * Create file /src/jndi.properties: java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces java.naming.provider.url= * Create file /war/WEB-INF/jetty-web.xml: http://jetty.mortbay.org/configure.dtd";> java. javax.servlet. javax.xml. org.mortbay. org.xml. org.w3c. org.apache.commons.logging. org.apache.log4j. org.slf4j. org.mortbay.jetty. org.mortbay.start. org.mortbay.stop. Create a servlet which will forward all requests to a SessionBean on the JBoss Server: public class RemoteEJBProxyServlet extends RemoteServiceServlet { protected InitialContext ctx; @Override public void init() throws ServletException { super.init(); try { this.ctx = new InitialContext(); } catch (Exception e) { System.err.println(e.getMessage()); throw new ServletException("Could not create InitialContext", e); } } @Override public String processCall(String payload) throws SerializationException { try { // Get the session bean Object bean = ctx.lookup(""); // Decode the request and test if it is legal RPCRequest rpcRequest = RPC.decodeRequest(payload, bean.getClass(), this); // Invoke the requested method on the bean and return the encoded (=RPC serialized) result return invokeAndEncodeResponse(bean, rpcRequest, rpcRequest.getSerializationPolicy()); } catch (NamingException ex) { ex.printStackTrace(); return RPC.encodeResponseForFailure(null, new Exception (ex.getMessage())); } catch (IncompatibleRemoteServiceException ex) { ex.printStackTrace(); return RPC.encodeResponseForFailure(null, ex); } } private String invokeAndEncodeResponse(Object target, RPCRequest rpcRequest, SerializationPolicy serializationPolicy) throws SerializationException { String responsePayload; Method method = rpcRequest.getMethod(); Object[] args = rpcRequest.getParameters(); try { Object result = method.invoke(target, args); responsePayload = RPC.encodeResponseForSuccess(method, result, serializationPolicy); } catch (IllegalAccessException e) { throw new SecurityException(e); } catch (IllegalArgumentException e) { throw new SecurityException(e); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); responsePayload = RPC.encodeResponseForFailure(method, cause, serializationPolicy); } return responsePayload; } } Also make sure that the J2EE Server libraries are included in the Eclipse Run Configuration of your GWT Development Mode. These are needed by Jetty to connect to the J2EE Server. In the case of JBOSS these are all of the JAR files in "/ client" and "/common/lib". Greetz, Menno. On 7 jan, 17:31, mariyan nenchev wrote: > Could you give us small step by step guide how to make gwt 2.0 development > mode working with gwt RPC and JBoss ejb beans? I never got it to work. > On Thu, Jan 7, 2010 at 5:47 PM, Fushion wrote: > > > > > Well, I started about 2 years ago, just a few hours a month trying out > > various GWT things and gradually upgrading to newer GWT versions (1.3 > > - 1.4 - 1.5 - 1.6 - 1.7 - 2.0). > > > Upgrading was always easy as I found out. The only hard part was > > getting Jetty to communicate with my JBoss application server in > > developmode, but that seems to work just fine now. > > Debugging is a lot easier now that OOPHM is implemented in 2.0. I > > would REALLY encourage people to start using it as it makes developing/ > > debugging in various browser simulatious a no brainer and saves a lot >
Re: How to compile multiple modules independent of each other
You can do this quite easily. Just compile your widgets as it were separate projects (each with their own Entrypoint and onModuleLoad functions). Now to be able to use methods from widget1 by widget2, you'll have to 'export' the functions from widget1 that you want to be used to javascript. See http://code.google.com/p/gwtchismes/wiki/Tutorial_ExportingGwtLibrariesToJavascript_en how to do this. In widget2 you can now make a JSNI function that calls the 'exported' javascript function from widget1. Good luck, Menno. On 31 dec 2009, 14:04, Ganesh wrote: > Hi All > > I am using GWT2.0. I want to create some client side widgets by > extending GWT's widgets. These widgets will be deployed on my server & > I will provide public links of js (.nocache.js) file of these widgets > so that a user can include these in his application's html page & use > them. I will deploy many of such widgets on my server. If a user wants > to use more than one widget, he need to include js file of each widget > in his html file. Each widget will have it's own module. > > Further my widgets can be dependent on each other. Suppose Widget1 is > dependent on Widget2 & user wants to use Widget1, he needs to include > js of both widgets (Widget1 & Widget2) in his html file. > > Now my problem is > - How to compile my Widget1's module so that while compiling Widget1, > it doesn't generate js for Widget2 as it will be provided to it at run > time (as user will include Widget2's js file in his html file). > - How Widget1 will be able to use Widget2 & it's method as GWT > obfuscates all java code at compile time. I can't choose option for > not obfuscating code due to size of js & security issues. > > Kindly also consider that I would like to compile Widget1 & Widget2 > separetly & a new version of Widget2 can be compiled at any time. > After this compile, changes done in Widget2 shd reflect while it is > being used through Widget1 without compiling Widget1 again. > > Any help/suggestion in this regard will be highly appreciable. > > Thanks in advance. > > Ganesh Bansal -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Webbrowser game made with GWT 2.0: lacesfirst.com
Well, I started about 2 years ago, just a few hours a month trying out various GWT things and gradually upgrading to newer GWT versions (1.3 - 1.4 - 1.5 - 1.6 - 1.7 - 2.0). Upgrading was always easy as I found out. The only hard part was getting Jetty to communicate with my JBoss application server in developmode, but that seems to work just fine now. Debugging is a lot easier now that OOPHM is implemented in 2.0. I would REALLY encourage people to start using it as it makes developing/ debugging in various browser simulatious a no brainer and saves a lot of time! I only have to start the development-mode once a day and start 4 browsers to connect to it. Most time is spend on CSS styling, as that is still the main problem when developing for web browsers today. The page is still in quirks mode (transitional html) as I found out that it gives me the most consistent UI on all browsers I tested on (IE6, IE7, IE8, Firefox, Chrome and Safari). One of the future improvements will be to set the page in standards mode (html or xhtml), but my first impression on that is that IE7 is very buggy in that area, especially when trying to do a centered layout. I hope MS will give IE7 a firm kick out of the browser world... ;-) The game still uses a lot of pre 2.0 options, but this will be upgraded over the next weeks (e.g. *LayoutPanels, more UiBinding and ClientResource integration ). The GWT things that you are able to see in the game include: - GlassPanels (in various ways) - Timers - RunAsync - Popups - History management - GWT RPC (no deRPC yet...) - Paging tables - ImageBundles (still pre 2.0) - MenuBar If I had all the tools and ideas I used in the game at the beginning of development, I estimate that it would have taken me 2-3 months full time to develop it (client AND server code, don't underestimate your server coding) Menno. On 7 jan, 11:28, mariyan nenchev wrote: > Nice. > How much time the game took to be designed and developed? > > On Thu, Jan 7, 2010 at 3:40 AM, Fushion wrote: > > > > > I started playing around with GWT since version 1.3 just fooling > > around with the code and trying out some various things. > > One thing I did was starting to develop a browser game, so I could see > > how things worked out in a real application instead of just mocking up > > some fancy gadgets. > > > Well, one thing led to another and now it is starting to look like an > > actual application. > > You can find it onhttp://lacesfirst.com > > > It is an online football manager game where you can manage a football > > team. > > You can train players, hire employees, change formations and tactics, > > sell/buy players, change the lineup of your team, upgrade your stadium/ > > shops etc. > > The games are simulated every day at specified times and take into > > account the tactics and linup of your team (and the opponents' team). > > The teams and players are all fictional and randomly generated, as > > there is no way I want to get into licencing troubles with the NFL > > ofcourse. > > > One thing to notice is that the entire game (client and server code) > > is made of 100% Java (Using EJB3on server side). > > This made it possible to have just one servlet containing about 40 > > lines of code that just calls a SessionBean on the EJB server. > > Also the code of the data model is used in both client and server > > side, so no extra DTO objects were needed. > > All this makes the code very slim and manageble. > > It is not exactly a UI that you would find in a typical GWT > > application though... > > > The game is still in beta as there are many things that can be made > > better, but it is playable anyway. > > Have fun! > > > Greetz, > > > Menno. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Google Web Toolkit" group. > > To post to this group, send email to google-web-tool...@googlegroups.com. > > To unsubscribe from this group, send email to > > google-web-toolkit+unsubscr...@googlegroups.com > cr...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
[ANN] Webbrowser game made with GWT 2.0: lacesfirst.com
I started playing around with GWT since version 1.3 just fooling around with the code and trying out some various things. One thing I did was starting to develop a browser game, so I could see how things worked out in a real application instead of just mocking up some fancy gadgets. Well, one thing led to another and now it is starting to look like an actual application. You can find it on http://lacesfirst.com It is an online football manager game where you can manage a football team. You can train players, hire employees, change formations and tactics, sell/buy players, change the lineup of your team, upgrade your stadium/ shops etc. The games are simulated every day at specified times and take into account the tactics and linup of your team (and the opponents' team). The teams and players are all fictional and randomly generated, as there is no way I want to get into licencing troubles with the NFL ofcourse. One thing to notice is that the entire game (client and server code) is made of 100% Java (Using EJB3on server side). This made it possible to have just one servlet containing about 40 lines of code that just calls a SessionBean on the EJB server. Also the code of the data model is used in both client and server side, so no extra DTO objects were needed. All this makes the code very slim and manageble. It is not exactly a UI that you would find in a typical GWT application though... The game is still in beta as there are many things that can be made better, but it is playable anyway. Have fun! Greetz, Menno. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.