Changeset 2935


Ignore:
Timestamp:
05/27/13 12:28:51 (11 years ago)
Author:
keeloo
Message:

Some preparations for sub theming.

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  
    55import eu.clarin.cmdi.vlo.dao.SearchResultsDao;
    66import eu.clarin.cmdi.vlo.pages.FacetedSearchPage;
     7import java.util.Map;
    78import javax.servlet.ServletContext;
     9import org.apache.wicket.Request;
     10import org.apache.wicket.RequestCycle;
     11import org.apache.wicket.Response;
    812import org.apache.wicket.protocol.http.WebApplication;
     13import org.apache.wicket.protocol.http.WebRequest;
     14import org.apache.wicket.protocol.http.WebRequestCycle;
     15import org.apache.wicket.request.RequestParameters;
    916
    1017/**
     
    2128public class VloWebApplication extends WebApplication {
    2229
     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
    23115    private SearchResultsDao searchResults;
    24116   
     
    34126    @Override
    35127    public void init() {
     128       
     129        // this.setRequestCycleProvider(IRequestCycleProvider);
     130       
     131               
    36132
    37133        if (inContext) {
     
    53149        // start the application
    54150
    55         searchResults = new SearchResultsDao();
     151        searchResults = new SearchResultsDao();       
    56152    }
    57153
  • vlo/trunk/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/pages/BasePage.java

    r2768 r2935  
    11package eu.clarin.cmdi.vlo.pages;
    22
     3import eu.clarin.cmdi.vlo.VloWebApplication;
    34import org.apache.wicket.PageParameters;
    45import org.apache.wicket.markup.html.WebPage;
     
    67
    78public class BasePage extends WebPage {
    8 
     9   
    910    public BasePage(PageParameters parameters) {
    1011        super(parameters);
    1112       
     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       
    1228        add(new BookmarkablePageLink("homeLink", FacetedSearchPage.class));
    13     }
    14    
     29    }   
    1530}
Note: See TracChangeset for help on using the changeset viewer.