CleverGWT
From PlcWiki
(Difference between revisions)
m (→SecuredServiceServlet) |
m (→SecuredServiceServlet) |
||
Line 31: | Line 31: | ||
== SecuredServiceServlet == | == SecuredServiceServlet == | ||
+ | |||
+ | Benefits: | ||
* Request without GWT permutation header will be blocked (potential CSRF attack) | * Request without GWT permutation header will be blocked (potential CSRF attack) | ||
Line 37: | Line 39: | ||
<java> | <java> | ||
public class GWTServiceImpl extends SecuredServiceServlet implements ... | public class GWTServiceImpl extends SecuredServiceServlet implements ... | ||
+ | |||
+ | @Override | ||
+ | protected boolean isInRole(String user, String method, Object value, Integer position) { | ||
+ | // check for permission | ||
+ | } | ||
</java> | </java> | ||
Revision as of 08:20, 20 June 2012
Contents |
ClvListGrid - Extension of ListGrid
Simplification of CRUD usage:
ClvListGrid 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.
SecuredServiceServlet
Benefits:
- Request without GWT permutation header will be blocked (potential CSRF attack)
- Authorization check before the servlet methods are called from client
public class GWTServiceImpl extends SecuredServiceServlet implements ... @Override protected boolean isInRole(String user, String method, Object value, Integer position) { // check for permission }
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 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);