CleverGWT
From PlcWiki
(Difference between revisions)
m (→ClvListGrid - Extension of ListGrid) |
m |
||
Line 166: | Line 166: | ||
boolean verified = BCrypt.checkpw("password", hashed); | boolean verified = BCrypt.checkpw("password", hashed); | ||
</java> | </java> | ||
+ | |||
+ | == Externalizer == | ||
+ | |||
+ | <xml> | ||
+ | <target name="externalizer"> | ||
+ | <taskdef name="externalizer" classname="cz.clever.gwt.ext.ant.Externalizer"/> | ||
+ | <externalizer | ||
+ | substitution="ClientConst.Util.get().%label()" | ||
+ | labelMaxLength="20" | ||
+ | labelPrefix="lbl" | ||
+ | fileConst="src/cz/clever/cct/gwt/app/client/ClientConst.java"> | ||
+ | |||
+ | <fileset dir="src/cz/clever/cct/gwt/app/client"> | ||
+ | <include name="*.java" /> | ||
+ | <exclude name="ClientConst.java"/> | ||
+ | </fileset> | ||
+ | </externalizer> | ||
+ | </target> | ||
+ | </xml> |
Revision as of 14:12, 13 August 2012
Contents |
Installation Steps
- Repository: svn+ssh://username@oko.clever.cz
- Path: /java/CleverGWT
- Entry-point descriptor ...gwt.xml:
<inherits name="cz.clever.gwt.ext.Module" />
- Don't forget to check your current version of the GWT
ClvListGrid - Extension of ListGrid
Simplification of CRUD usage:
ListGrid grid = new ClvListGrid(new ClvListGrid.Delegate() { @Override public void executeUpdate(ClvListGridResponse response) { // Map<String, Object> reqMap = response.getRequestMap(); // response.response(... } @Override public void executeRemove(ClvListGridResponse response) {} @Override public void executeFetch(ClvListGridResponse response) {} @Override public void executeAdd(ClvListGridResponse response) {} @Override public DataSourceField[] createFields() { return new DataSourceField[] { new DataSourceTextField("Field Name") }; } });
Note: If you are implementing executeRemove/Add/Fetch you must call response.response(...). Not in executeUpdate.
Real-time data synchronization (only works with URL parameter "im"):
grid = new ClvListGrid(delegate, "MySubscribeId");
SecuredServiceServlet
Benefits:
- Request without GWT permutation header will be blocked (potential CSRF attack)
- Authorization check before the servlet methods are called from client (methods must be annotated as Secured)
public class MyGWTServiceImpl extends SecuredServiceServlet implements ... @Override protected boolean isInRole(String user, String method, Object value, Integer position) { // check for permission }
JettyLauncher
Allow you to set custom logging and configuration.
Example of startup arguments:
-startupUrl Entrypoint.html ... -server cz.clever.gwt.ext.server.JettyLauncher ...
Inside a class:
wac.setConfigurationClasses(new String[] { "org.mortbay.jetty.webapp.WebInfConfiguration", "org.mortbay.jetty.plus.webapp.EnvConfiguration",//jetty-env "org.mortbay.jetty.plus.webapp.Configuration", //web.xml "org.mortbay.jetty.webapp.JettyWebXmlConfiguration",//jettyWeb });
DocumentServlet and UploadServlet
HttpServlet solution for uploading and downloading documents.
Example of upload servlet configuration:
<servlet> <servlet-name>MaterialUpload</servlet-name> <servlet-class>cz.clever.cct.gwt.app.server.MyUploadServlet</servlet-class> <init-param> <param-name>repository</param-name> <param-value>/tmp</param-value> </init-param> <init-param> <param-name>maxMemSize</param-name> <param-value>2147483646</param-value> </init-param> <init-param> <param-name>maxFileSize</param-name> <param-value>2147483646</param-value> </init-param> </servlet>
StringUtil
java.util.StringTokenizer is prohibited in the GWT client side. Here is my substitution:
StringUtil.tokenizer("Jirka, Petr, Honza", ",", new ValueCallback() { @Override public void execute(String token) { // Your code } });
Way how to build a delimiter separated string from collection:
ToString<MaterialOption> toStr = new ToString<MaterialOption>() { @Override public String get(MaterialOption obj) { //make a token from object return obj.toString(); // or if you want: return obj == null? null:obj.getOptionString(); } }; // collection with filling of course Collection<MaterialOption> myCollection = new ArrayList<MaterialOption>(); String result = StringUtil.toString(myCollection, ", ", toStr);
ParserCSV
new ParserCSV(new ParserCSV.Delegate() { @Override public void token(String token, int position) { // working with parsed tokens } @Override public String getPath() { return "MyTable.csv"; } @Override public String getDelimeter() { return ";";} @Override public String getCharsetName() { return "UTF-16"; } });
BCrypt
String hashed = BCrypt.hashpw("password", BCrypt.gensalt()); boolean verified = BCrypt.checkpw("password", hashed);
Externalizer
<target name="externalizer"> <taskdef name="externalizer" classname="cz.clever.gwt.ext.ant.Externalizer"/> <externalizer substitution="ClientConst.Util.get().%label()" labelMaxLength="20" labelPrefix="lbl" fileConst="src/cz/clever/cct/gwt/app/client/ClientConst.java"> <fileset dir="src/cz/clever/cct/gwt/app/client"> <include name="*.java" /> <exclude name="ClientConst.java"/> </fileset> </externalizer> </target>