Reputation: 1163
Is there something similar to Ruby on Rails Scaffolding for creating GWT CRUD?
Upvotes: 6
Views: 2043
Reputation: 574
GWT uses a different paradigm compared to all textbook CRUD frameworks that solve very little IMO. Think of it as a good old Swing. The communication is already built-in (GWT-RPC). The only way to improve it - none of those CRUD frameworks offers - would be to create some patterns (your own richer widget set, etc.) that works on some unified data. And of course the matching code on the server. This way you can use generic GWT-RPC methods and generic data structures to pass data, not millions of methods in all those interfaces. Otherwise GWT-RPC is as good, as any generic CRUD "framework" that'd have those millions methods in the "service facade".
One thing you can do is to "integrate" GWT-RPC with Spring MVC. Only few lines of code - and you can implement your GWT-RPC services as standard Spring @Controllers. They'll have access to all autowired components, etc. What more do you need? You can access absolutely anything through Spring.
So here's how you do it:
public abstract class GwtRpcController extends RemoteServiceServlet implements Controller, ServletConfigAware {
private static Log log = LogFactory.getLog(GwtRpcController.class);
private ServletConfig servletConfig;
@Override
public ServletConfig getServletConfig() {
return servletConfig;
}
@Override
public void setServletConfig(ServletConfig servletConfig) {
try {
this.init(servletConfig);
} catch (ServletException e) {
throw new RuntimeException(e);
}
this.servletConfig = servletConfig;
}
@Override
protected void onAfterRequestDeserialized(RPCRequest rpcRequest) {
super.onAfterRequestDeserialized(rpcRequest);
}
@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
super.doPost(request, response);
return null;
}
@Override
protected void doUnexpectedFailure(Throwable e) {
log.error(e.getMessage(), e);
}
}
And your GWT-RPC service:
@RemoteServiceRelativePath("gwtrpc/xxx")
public interface XxxService extends RemoteService {
...
}
@Controller
@RequestMapping(value = "xxx")
public class XxxServiceImpl extends GwtRpcController implements XxxService {
...
}
Make sure "gwtrpc/*" is mapped to SpringDispatcher servlet in web.xml. Typically you'd map everything ("/") to it and make exceptions for non-Spring resources like CSS, etc. so you don;t need to do anything explicitly.
Upvotes: 0
Reputation: 11
MyEclipse for Spring 8.6 M2 was just released and it now has GWT scaffolding.
You can download a free 30 day trial here.
Upvotes: 1
Reputation: 8874
Spring Roo was announced at Google I/O 2010. That might be what you're looking for.
Upvotes: 3
Reputation: 14187
GWT isn't a full application stack like Rails, so you might not find a solution that is as integrated and out of the box as Rails. GWT is primarily a view layer - you'd still need a persistence layer.
Upvotes: 0