Author: dward
Date: 2008-01-09 17:47:48 +0100 (Wed, 09 Jan 2008)
New Revision: 6707

Modified:
   
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/client/Main.java
   
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/client/search/Searcher.java
   
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/client/search/history/ClientState.java
Log:
- CURRIKI-1190
 - Allow arguments for search to be passed via the page as well as the URL

Modified: 
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/client/Main.java
===================================================================
--- 
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/client/Main.java 
    2008-01-09 13:41:30 UTC (rev 6706)
+++ 
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/client/Main.java 
    2008-01-09 16:47:48 UTC (rev 6707)
@@ -97,8 +97,8 @@
         String dosearch = WindowUtils.getLocation().getParameter("search");
 
         if (dosearch == null) {
-            // Check if started with search set to 1 using javascript like
-            // var GWTArguments = { search: "1" };
+            // Check if started with search set using javascript like
+            // var GWTArguments = { search: "" };
             try {
                 Dictionary arguments = 
Dictionary.getDictionary("GWTArguments");
                 if (arguments != null && arguments.get("search") != null){
@@ -115,6 +115,7 @@
             // Bring up Site search app
             callSiteAddJSAPI(singleton); // Need to makes sure other GWT links 
still work
 
+            final String searchArgs = dosearch; // Need a final value for 
inner class below
             searcher = new Searcher();
             checkTranslator(new AsyncCallback() {
                 public void onFailure(Throwable throwable) {
@@ -122,7 +123,7 @@
                 public void onSuccess(Object object) {
                     Command loadSearcher = new Command(){
                         public void execute(){
-                            searcher.init();
+                            searcher.init(searchArgs);
                         }
                     };
                     fetchUser(loadSearcher);

Modified: 
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/client/search/Searcher.java
===================================================================
--- 
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/client/search/Searcher.java
  2008-01-09 13:41:30 UTC (rev 6706)
+++ 
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/client/search/Searcher.java
  2008-01-09 16:47:48 UTC (rev 6707)
@@ -33,7 +33,11 @@
     private SearcherHistory history;
     private ClientState state;
 
-    public void init()
+    public void init() {
+        init(null);
+    }
+
+    public void init(String passedToken)
     {
         history = new SearcherHistory();
         History.addHistoryListener(history);
@@ -42,6 +46,8 @@
 
         String initToken = History.getToken();
         state.InitFromToken(initToken);
+        state.AddFromToken(passedToken);
+        initToken = state.getHistoryToken();
 
         // History needs to track search parameters and what page we are on 
for results
         

Modified: 
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/client/search/history/ClientState.java
===================================================================
--- 
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/client/search/history/ClientState.java
       2008-01-09 13:41:30 UTC (rev 6706)
+++ 
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/client/search/history/ClientState.java
       2008-01-09 16:47:48 UTC (rev 6707)
@@ -52,6 +52,14 @@
     public void InitFromToken(String historyToken)
     {
         paramsMap.clear();
+        AddFromToken(historyToken);
+    }
+
+    /**
+     * Add state from token
+     */
+    public void AddFromToken(String historyToken)
+    {
         if (historyToken != null && historyToken.length() > 1) {
             String[] kvPairs = historyToken.split("&");
             for (int i = 0; i < kvPairs.length; i++) {

_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to