From: Anjo K. <an...@us...> - 2004-01-09 12:28:13
|
Update of /cvsroot/wonder/Wonder/Common/Frameworks/ERDirectToWeb/Sources/er/directtoweb In directory sc8-pr-cvs1:/tmp/cvs-serv16170/Common/Frameworks/ERDirectToWeb/Sources/er/directtoweb Modified Files: ERD2WQueryPage.java Log Message: - queryBindings can now be saved Index: ERD2WQueryPage.java =================================================================== RCS file: /cvsroot/wonder/Wonder/Common/Frameworks/ERDirectToWeb/Sources/er/directtoweb/ERD2WQueryPage.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ERD2WQueryPage.java 24 Nov 2003 11:35:05 -0000 1.18 --- ERD2WQueryPage.java 9 Jan 2004 12:28:10 -0000 1.19 *************** *** 17,21 **** /** * Superclass for all query pages.<br /> ! * */ --- 17,23 ---- /** * Superclass for all query pages.<br /> ! * In addition to the rest of the goodies of ERD2WPage, it lets you ! * save and restore the initial query bindings by supplying a NS(Mutable)Dictionary which ! * contains the keys "queryMin", "queryMax" etc from the respective fields of the WODisplayGroup. */ *************** *** 23,33 **** public WODisplayGroup displayGroup = new WODisplayGroup(); ! public ERD2WQueryPage(WOContext context) { super(context); } public boolean isDeep() { return ERXValueUtilities.booleanValue(d2wContext().valueForKey("isDeep")); } public boolean usesDistinct() { return ERXValueUtilities.booleanValue(d2wContext().valueForKey("usesDistinct")); --- 25,107 ---- public WODisplayGroup displayGroup = new WODisplayGroup(); ! protected boolean didLoadQueryBindings; ! protected NSDictionary queryBindings; ! public ERD2WQueryPage(WOContext context) { super(context); } + protected void pullQueryBindingsForName(String name) { + NSDictionary queryBindings = queryBindings(); + if(queryBindings != null) { + NSDictionary source = (NSDictionary)queryBindings.objectForKey(name); + if(source != null) { + NSMutableDictionary destination = (NSMutableDictionary)NSKeyValueCoding.Utility.valueForKey(displayGroup, name); + destination.addEntriesFromDictionary(source); + } + } + } + + protected void pushQueryBindingsForName(String name) { + NSDictionary queryBindings = queryBindings(); + if(queryBindings != null && (queryBindings instanceof NSMutableDictionary)) { + NSMutableDictionary mutableQueryBindings = (NSMutableDictionary)queryBindings; + NSDictionary source = (NSDictionary)NSKeyValueCoding.Utility.valueForKey(displayGroup, name); + mutableQueryBindings.setObjectForKey(source.mutableClone(), name); + } + } + + public void takeValuesFromRequest(WORequest request, WOContext context) { + super.takeValuesFromRequest(request, context); + saveQueryBindings(); + } + + public void appendToResponse(WOResponse arg0, WOContext arg1) { + loadQueryBindings(); + super.appendToResponse(arg0, arg1); + } + + protected void saveQueryBindings() { + NSDictionary queryBindings = queryBindings(); + if(queryBindings != null) { + pushQueryBindingsForName("queryMin"); + pushQueryBindingsForName("queryMax"); + pushQueryBindingsForName("queryMatch"); + pushQueryBindingsForName("queryOperator"); + pushQueryBindingsForName("queryBindings"); + } + } + + protected void loadQueryBindings() { + if(!didLoadQueryBindings) { + NSDictionary queryBindings = queryBindings(); + if(queryBindings != null) { + pullQueryBindingsForName("queryMin"); + pullQueryBindingsForName("queryMax"); + pullQueryBindingsForName("queryMatch"); + pullQueryBindingsForName("queryOperator"); + pullQueryBindingsForName("queryBindings"); + didLoadQueryBindings = true; + } + } + } + + public void awake() { + super.awake(); + } + public boolean isDeep() { return ERXValueUtilities.booleanValue(d2wContext().valueForKey("isDeep")); } + public NSDictionary queryBindings() { + if(queryBindings == null) { + queryBindings = (NSDictionary)valueForBinding("queryBindings"); + } + return queryBindings; + } + + public void setQueryBindings(NSDictionary dictionary) { + queryBindings = dictionary; + } + public boolean usesDistinct() { return ERXValueUtilities.booleanValue(d2wContext().valueForKey("usesDistinct")); |