Home‎ > ‎UI‎ > ‎

RequestFactory


GWT Request Factory setup

Demo

Wallet RequestFactory Demo - Demo built to store your wallets inventory incase you lost it. 
Wallet Demo Source - Source for the Wallet Demo

Demo

People Editor Demo - Another simple demo
People Editor Source - And the source for it


Official Documentation



Initialize Request Factory Client Side

If you don't initialize the request factory you'll get a null exception. (AbstractRequestContext.java:1102)
public interface ApplicationRequestFactory extends RequestFactory {
   
UserJdoRequest getUserJdoRequest();
   
//...
}
public class ClientFactory {
 
private final ApplicationRequestFactory requestFactory = GWT.create(ApplicationRequestFactory.class);
 
private EventBus eventBus;

 
public ClientFactory() {
   eventBus
= new SimpleEventBus();
   requestFactory
.initialize(eventBus);
 
}

 
public ApplicationRequestFactory getRequestFactory() {
   
return requestFactory;
 
}
}

web.xml Configuration

        <servlet>
               
<servlet-name>requestFactoryServlet</servlet-name>
               
<servlet-class>com.google.web.bindery.requestfactory.server.RequestFactoryServlet</servlet-class>
               
<init-param>
                       
<param-name>symbolMapsDirectory</param-name>
                       
<!-- You'll need to compile with -extras and move the symbolMaps directory
                                to this location if you want stack trace deobfuscation to work -->

                       
<param-value>WEB-INF/classes/symbolMaps/</param-value>
               
</init-param>
       
</servlet>
       
<servlet-mapping>
               
<servlet-name>requestFactoryServlet</servlet-name>
               
<url-pattern>/gwtRequest</url-pattern>
       
</servlet-mapping>

Validation Setup

To setup the Request Factory Annotation processing settings, right click on your eclipse project and select properties. 




Notes

1. Always instantiate lists as empty lists and not null when using editors
2. Clean your project if your getting errors and after validation is done try again. 
3. Creating new proxy/bean, instantiate the children proxies for editors. This helps avoid frozen errors. 
    a. always use the same context for creating your proxy and children proxies.


Clean the Project

What the validation looks like when its running in Eclipse when the project is cleaned. When you change your request factory, you can run clean project to fix errors. 
This is in the Lower Right corner of Eclipse. 



Manually Run Validation

If you have something funky going on with your RequestFactory validation, run this script and you'll get the error in the terminal. 
#!/bin/sh
# made by Brandon Donnelson
# http://c.gwt-examples.com

# Project Path to Web-inf folder (with no trailing /)
BASE
="/Users/branflake2267/git/Student-Learning-Plan-v2/Studen_Learning_Plan_V2/war/WEB-INF";

#add your Requestfactory class
REQUESTFACTORY
="org.gonevertical.client.app.requestfactory.ApplicationRequestFactory";


#----------------------------
# don't have to edit below - unless you have more Application Request Factories

OUTPUT
="$BASE/classes";

CP
="";
CP
="$CP$BASE/classes:";
CP
="$CP$BASE/lib/*:"; # '*' will only work with java 1.6+

# these need to be in there
#CP="$CP$BASE/lib/requestfactory-apt.jar:";
#CP="$CP$BASE/lib/requestfactory-server+src.jar:";

echo
"DEBUG ClassPath: $CP";

java
-cp $CP com.google.web.bindery.requestfactory.apt.ValidationTool $OUTPUT \
  $REQUESTFACTORY
 
# Do you need more Request Factories???
 

# the end
exit;

Debugging

This is good to check the awareness of the editor and sub editors. 
    String s = EditorHierarchyPrinter.toString(driver);
   
System.out.println("EditorHierarchyPrinter = " + s);

FAQ

1. If you get a compile error with "com.google.web.bindery.requestfactory.vm.impl.Deobfuscator.Builder;" you should run the manual validation to find your error quickly. Most likely you could be missing the mandatory find[DtoName](id) method.  




Comments