Changeset 4199 for vlo/branches/to-wicket-1.6/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/VloWebApplication.java
- Timestamp:
- 12/18/13 09:51:19 (10 years ago)
- Location:
- vlo/branches/to-wicket-1.6
- Files:
-
- 1 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
vlo/branches/to-wicket-1.6/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/VloWebApplication.java
r4021 r4199 10 10 import javax.servlet.ServletContext; 11 11 import org.apache.wicket.Application; 12 import org.apache.wicket.PageParameters;13 import org.apache.wicket.Request;14 12 import org.apache.wicket.RequestCycle; 13 import org.apache.wicket.request.RequestParameters; 15 14 import org.apache.wicket.Response; 16 15 import org.apache.wicket.protocol.http.WebApplication; 17 16 import org.apache.wicket.protocol.http.WebRequest; 18 17 import org.apache.wicket.protocol.http.WebRequestCycle; 19 import org.apache.wicket.protocol.http.WebSession; 20 import org.apache.wicket.request.RequestParameters; 18 import org.apache.wicket.protocol.http.WebResponse; 21 19 22 20 /** … … 31 29 32 30 /** 33 * Customi zed client request cycle<br><br>31 * Customised client request cycle<br><br> 34 32 * 35 33 * <intercept resquest in order to update session parameter list> 36 34 * 37 * Add behavio r to the web request handling by retrieving persistent35 * Add behaviour to the web request handling by retrieving persistent 38 36 * parameters to the application from from client requests, and store 39 37 * the in the application object. … … 47 45 48 46 /** 49 * Add the behavio r to the beginning of the processing of a request47 * Add the behaviour to the beginning of the processing of a request 50 48 */ 51 49 @Override … … 64 62 } else { 65 63 // check if the users requests a different theme 66 if (object[0].matches((( ThemedSession)getSession()).getCurrentTheme().name)) {64 if (object[0].matches(((VloSession)getSession()).getCurrentTheme().name)) { 67 65 // current theme requested, nothing to do 68 66 } else { 69 67 // different theme requested, compose it 70 (( ThemedSession)getSession()).setCurrentTheme(new Theme (object[0]));71 // remember the theme as a persistentparameter72 (( ThemedSession)getSession()).persistentParameters.put("theme", object[0]);68 ((VloSession)getSession()).setCurrentTheme(new Theme (object[0])); 69 // remember the theme as a vlo session page parameter 70 ((VloSession)getSession()).vloSessionPageParameters.add("theme", object[0]); 73 71 } 74 72 } 75 73 } 76 74 } 77 78 /**79 * Put the the customized request cycle up for installation<br><br>80 *81 * Note that casting the request to a WebRequest is assumed to be safe.82 *83 * @param request the request to be passed on the the new handler84 * @param response the response to be passed on the the new handler85 * @return the new handler86 */87 @Override88 public RequestCycle newRequestCycle(Request request, Response response){89 75 90 /* Pass on the application object and parameters to new the request91 * cycle when creating it.92 */93 CustomCycle cycle = new CustomCycle(this, (WebRequest)request, response);94 95 return cycle;96 }97 98 /**99 * Compose a map to be included in the HTML document, designating the100 * positions of the links to partner web sites101 *102 * @return103 */104 private String getClarinDPartnerLinkMap(){105 String map;106 107 map = "<map name=\"partnerLinks\">\n";108 map = map + "</map>";109 110 return map;111 }112 113 /**114 * Compose a map to be included in the HTML document, designating the115 * positions of the links to partner web sites116 *117 * @return118 */119 private String getDefaultPartnerLinkMap(){120 String map;121 122 map = "<map name=\"partnerLinks\">\n";123 map = appendToPartnerLinkMap (map,124 "114.00,65,167.50,104",125 "http://www.clarin.eu",126 "clarin link");127 map = appendToPartnerLinkMap (map,128 "177.00,65,214,104",129 "http://wals.info",130 "wals link");131 map = appendToPartnerLinkMap (map,132 "229,65,279,104",133 "http://linguistlist.org",134 "linguistlist link");135 map = appendToPartnerLinkMap (map,136 "290,65,320,104",137 "http://www.elra.info",138 "elra link");139 map = appendToPartnerLinkMap (map,140 "328,65,370,104",141 "http://www.mpi.nl/dobes",142 "dobes link");143 map = appendToPartnerLinkMap (map,144 "379,65,428,104",145 "http://www.dfki.de/web",146 "dfki link");147 map = appendToPartnerLinkMap (map,148 "434,65,484,104",149 "http://www.delaman.org",150 "deleman link");151 152 map = map + "</map>";153 154 return map;155 }156 157 /**158 * Add a link location to the map indicating the partner links159 *160 * @param map161 * @return162 */163 private String appendToPartnerLinkMap(String map, String coordinates,164 String URL, String alt) {165 166 if (map == null) {167 map = "<map name=\"partnerLinks\">\n";168 } else if (map.equals("")) {169 map = "<map name=\"partnerLinks\">\n";170 }171 172 map = map + "<AREA SHAPE=\"rect\" COORDS=\"" + coordinates + "\" HREF=\"" +173 URL + "\" alt=\"" + alt + "\"/>\n";174 175 return map;176 }177 178 public class ThemedSession extends WebSession {179 180 /**181 * Remember the parameters that should persist in URLs to VLO pages182 * <br><br>183 */184 public PageParameters persistentParameters = new PageParameters();185 186 /**187 *188 * @return189 */190 public PageParameters getPersistentParameters (){191 return persistentParameters;192 }193 194 /**195 * Reflect the persistent parameters in the page parameter map<br><br>196 *197 * @param parameters a page parameter map198 * @return the page parameter map including the current persistent199 * parameters200 */201 public PageParameters reflectPersistentParameters(PageParameters parameters) {202 203 parameters.putAll(persistentParameters);204 205 // parameters.add("theme", "defaultTheme");206 return parameters;207 }208 209 /**210 * Theme currently applied in the VLO web application211 */212 private Theme currentTheme = new Theme ("defaultTheme");213 214 public ThemedSession(Application application, Request request) {215 super(application, request);216 }217 218 public Theme getCurrentTheme() {219 return currentTheme;220 }221 222 public void setCurrentTheme(Theme currentTheme) {223 this.currentTheme = currentTheme;224 }225 }226 227 228 @Override229 public ThemedSession newSession(Request request, Response response) {230 231 return new ThemedSession(this, request);232 }233 234 /**235 * A theme is composed from a page title, a CSS file, two image files, and a236 * partner link map relating coordinates in the right image to partner links237 */238 public class Theme {239 240 public String name, pageTitle, topLeftImage, topRightImage, cssFile,241 partnerLinkMap;242 243 /**244 * Compose a theme<br><br>245 *246 * @param name the name of the theme to be composed247 */248 public Theme(String themeName) {249 250 String prefix = VloConfig.getReverseProxyPrefix();251 252 if (themeName.matches("CLARIN-D")) {253 // select the CLARIN-D theme's components254 255 pageTitle = "CLARIN-D Virtual Language Observatory - Resources";256 topLeftImage = "Images/topleft-clarin-d.png";257 topRightImage = "Images/topright-clarin-d.png";258 if (prefix.length() == 0) {259 cssFile = "css/clarin-d.css";260 } else {261 cssFile = prefix + "css/clarin-d.css";262 }263 partnerLinkMap = getClarinDPartnerLinkMap();264 name = "CLARIN-D";265 } else {266 // select the default theme elements267 pageTitle = "CLARIN Virtual Language Observatory - Resources";268 topLeftImage = "Images/topleftvlo.gif";269 topRightImage = "Images/toprightvlo.gif";270 271 if (prefix.length() == 0) {272 cssFile = "css/main.css";273 } else {274 cssFile = prefix + "css/main.css";275 }276 partnerLinkMap = getDefaultPartnerLinkMap();277 name = "defaultTheme";278 }279 // remember the theme as a persistent parameter280 // getPersistentParameters.put("theme", name);281 }282 }283 284 76 /** 285 77 * Flag indicating whether or not the application object lives in a web … … 320 112 VloContextConfig.switchToExternalConfig(servletContext); 321 113 } 114 115 // install the custom request cycle 116 WebRequest req = (WebRequest) RequestCycle.get().getRequest(); 117 WebResponse res = (WebResponse) RequestCycle.get().getResponse(); 118 119 CustomCycle cycle; 120 cycle = new CustomCycle(this, req, res); 322 121 323 122 // creata an object referring to the search results
Note: See TracChangeset
for help on using the changeset viewer.