Changeset 2935
- Timestamp:
- 05/27/13 12:28:51 (11 years ago)
- Location:
- vlo/trunk/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/trunk/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/VloWebApplication.java
r2825 r2935 5 5 import eu.clarin.cmdi.vlo.dao.SearchResultsDao; 6 6 import eu.clarin.cmdi.vlo.pages.FacetedSearchPage; 7 import java.util.Map; 7 8 import javax.servlet.ServletContext; 9 import org.apache.wicket.Request; 10 import org.apache.wicket.RequestCycle; 11 import org.apache.wicket.Response; 8 12 import org.apache.wicket.protocol.http.WebApplication; 13 import org.apache.wicket.protocol.http.WebRequest; 14 import org.apache.wicket.protocol.http.WebRequestCycle; 15 import org.apache.wicket.request.RequestParameters; 9 16 10 17 /** … … 21 28 public class VloWebApplication extends WebApplication { 22 29 30 private String theme = null; 31 32 /** 33 * 34 * @return 35 */ 36 public String getTheme (){ 37 return theme; 38 } 39 40 /** 41 * 42 */ 43 public void setTheme (String theme){ 44 this.theme = theme; 45 } 46 47 /** 48 * Client request interception<br><br> 49 * 50 * Intercept client requests by adding to the default behavior of the web 51 * request handling. Define a request cycle that retrieves the URL 52 * parameters from the client requests. The URL parameters can then be 53 * reflected back in the pages created by the application. 54 */ 55 private class VloRequestCycle extends WebRequestCycle { 56 57 // find out why this is necessary 58 VloRequestCycle (WebApplication app, WebRequest req, Response res){ 59 super (app, req, res); 60 } 61 62 /** 63 * Redefine the beginning of the processing of a request 64 * 65 */ 66 @Override 67 public void onBeginRequest() { 68 /* Invoke the superclass method in order to have the default 69 * processing. 70 */ 71 super.onBeginRequest(); 72 /* After that, get the request parameters. Note that these are 73 * more elaborate than the parameters supplied in the URL of the 74 * original request. 75 */ 76 RequestParameters reqParam = this.request.getRequestParameters(); 77 // then, get the parameters in the URL from those 78 Map <String, String[]> map = this.getWebRequest().getParameterMap(); 79 // check if there is a theme parameter among the URL parameters 80 81 Object object = map.get("theme"); 82 if (object == null) { 83 // no theme parameters included in the URL, reset stored value 84 } else { 85 String value; 86 value = map.get("theme").toString(); 87 // the client included the theme parameter in the URL, save it 88 // by referencing the set method in the outer class 89 VloWebApplication.this.setTheme(value); 90 } 91 } 92 93 /** 94 * 95 */ 96 @Override 97 public void onEndRequest() { 98 super.onEndRequest(); 99 } 100 } 101 102 /** 103 * Install the custom request cycle. Note that the cast assumed to be safe. 104 * 105 * @param req 106 * @param res 107 * @return 108 */ 109 @Override 110 public RequestCycle newRequestCycle(Request req, Response res){ 111 VloRequestCycle cycle = new VloRequestCycle(this, (WebRequest)req, res); 112 return cycle; 113 } 114 23 115 private SearchResultsDao searchResults; 24 116 … … 34 126 @Override 35 127 public void init() { 128 129 // this.setRequestCycleProvider(IRequestCycleProvider); 130 131 36 132 37 133 if (inContext) { … … 53 149 // start the application 54 150 55 searchResults = new SearchResultsDao(); 151 searchResults = new SearchResultsDao(); 56 152 } 57 153 -
vlo/trunk/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/pages/BasePage.java
r2768 r2935 1 1 package eu.clarin.cmdi.vlo.pages; 2 2 3 import eu.clarin.cmdi.vlo.VloWebApplication; 3 4 import org.apache.wicket.PageParameters; 4 5 import org.apache.wicket.markup.html.WebPage; … … 6 7 7 8 public class BasePage extends WebPage { 8 9 9 10 public BasePage(PageParameters parameters) { 10 11 super(parameters); 11 12 13 // check for the theme parameter 14 VloWebApplication app = (VloWebApplication) this.getApplication(); 15 String theme = app.getTheme(); 16 17 if (theme == null) { 18 // client did not specify a theme parameter 19 } else { 20 // add the theme parameter 21 parameters.add("theme", theme); 22 23 // determine the intended css and "install" it 24 // determine the intended picture and install it 25 // this might not have to be done for every page 26 } 27 12 28 add(new BookmarkablePageLink("homeLink", FacetedSearchPage.class)); 13 } 14 29 } 15 30 }
Note: See TracChangeset
for help on using the changeset viewer.