Changeset 4234


Ignore:
Timestamp:
01/09/14 15:03:36 (10 years ago)
Author:
twagoo
Message:

Refactored adding theme as session page parameter
Merging with session parameters in FacetLinkPanel? and in ShowResultPage?

Location:
vlo/branches/to-wicket-1.6/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • vlo/branches/to-wicket-1.6/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/VloSession.java

    r4232 r4234  
    1 
    21package eu.clarin.cmdi.vlo;
    32
     
    76
    87/**
    9  * A web session containing a VLO theme and parameters that are considered to
    10  * be persistent in a VLO session.
    11  * 
     8 * A web session containing a VLO theme and parameters that are considered to be
     9 * persistent in a VLO session.
     10 *
    1211 * Note that these parameters can include the specification of the theme.
    13  * 
     12 *
    1413 * @author keeloo
    1514 */
     
    1716
    1817    // remember the parameters that need to persist in URLs to VLO pages in this session
    19     public PageParameters vloSessionPageParameters = new PageParameters();
     18    private PageParameters vloSessionPageParameters = new PageParameters();
    2019
    2120    // remember this session's theme
     
    2423    /**
    2524     * Construct a session object with a request parameter
    26      * 
    27      * @param request 
     25     *
     26     * @param request
    2827     */
    2928    public VloSession(Request request) {
     
    3433    /**
    3534     * Get the session's theme
    36      * 
    37      * @return the session's theme 
     35     *
     36     * @return the session's theme
    3837     */
    3938    public Theme getCurrentTheme() {
     
    4342    /**
    4443     * Set the session's theme
    45      * 
     44     *
    4645     * @param theme the session's theme
    4746     */
     
    4948        this.currentTheme = theme;
    5049    }
    51    
     50
    5251    /**
    5352     * Return the session's persistent parameters
    54      * 
     53     *
    5554     * @return session parameters
    5655     */
     
    6160    /**
    6261     * Add parameters to the session's persistent parameters
    63      * 
     62     *
    6463     * @param parameters a page parameter map
    6564     *
    6665     */
    6766    public void addVloSessionPageParameters(PageParameters parameters) {
    68        
     67
    6968        vloSessionPageParameters.mergeWith(parameters);
    7069    }
  • vlo/branches/to-wicket-1.6/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/VloWebApplication.java

    r4232 r4234  
    1818import org.apache.wicket.request.cycle.AbstractRequestCycleListener;
    1919import org.apache.wicket.request.cycle.RequestCycle;
     20import org.apache.wicket.request.mapper.parameter.PageParameters;
    2021import org.apache.wicket.util.string.StringValue;
    2122
     
    6364                    ((VloSession) Session.get()).setCurrentTheme(new Theme(object.toString()));
    6465                    // remember the theme as a vlo session page parameter
    65                     ((VloSession) Session.get()).vloSessionPageParameters.add("theme", object);
     66                    PageParameters params = new PageParameters();
     67                    params.add("theme", object);
     68                    ((VloSession) Session.get()).addVloSessionPageParameters(params);
    6669                }
    6770            }
  • vlo/branches/to-wicket-1.6/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/pages/FacetLinkPanel.java

    r4232 r4234  
    11package eu.clarin.cmdi.vlo.pages;
    22
     3import eu.clarin.cmdi.vlo.VloSession;
    34import org.apache.solr.client.solrj.response.FacetField.Count;
    45import org.apache.wicket.markup.html.basic.Label;
     
    1920        q.setFilterQuery(count);
    2021        PageParameters param = q.getPageParameters();
     22        param.mergeWith(((VloSession) VloSession.get()).getVloSessionPageParameters());
    2123       
    2224        Link<Count> facetLink = new BookmarkablePageLink("facetLink", FacetedSearchPage.class, param);
  • vlo/branches/to-wicket-1.6/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/pages/ShowResultPage.java

    r4232 r4234  
    7474    public ShowResultPage(final PageParameters currentParam) {
    7575        super(currentParam);
    76         //TODO: Is encoding/decoding of the page parameter required (or can it be automated?)
     76        //Document ID is assumed to have been encoded (typcially in DocumentLinkPanel) decode here
    7777        final String docId = UrlDecoder.QUERY_INSTANCE.decode(
    7878                getPageParameters().get(PARAM_DOC_ID).toString(),
     
    8383
    8484            // create parameters from the query, and add them with session related parameters
    85             PageParameters newParam;
    86             newParam = new PageParameters(query.getPageParameters());
     85            PageParameters newParam = new PageParameters(query.getPageParameters());
    8786            // add the session persistent parameters
    88             newParam.mergeWith(((VloSession)this.getSession()).getVloSessionPageParameters());
     87            newParam.mergeWith(((VloSession) this.getSession()).getVloSessionPageParameters());
    8988
    9089            BookmarkablePageLink<String> backLink = new BookmarkablePageLink<String>("backLink", FacetedSearchPage.class, newParam);
     
    429428        PageParameters newParam = new PageParameters(parameters);
    430429        // add the session persistent paremeters
    431         newParam.mergeWith(((VloSession)this.getSession()).getVloSessionPageParameters());
     430        newParam.mergeWith(((VloSession) this.getSession()).getVloSessionPageParameters());
    432431
    433432        final RequestCycle reqCycle = getRequestCycle();
     
    460459        PageParameters newParam;
    461460        newParam = new PageParameters(query.getPageParameters());
    462         // add the session persistent parameters
    463         // newParam.add(((VloSession)this.getSession()).getVloSessionPageParameters());
    464461        newParam.add(ShowResultPage.PARAM_DOC_ID, UrlEncoder.QUERY_INSTANCE.encode(
    465462                docId,
    466463                Application.get().getRequestCycleSettings().getResponseRequestEncoding())); // get current character set from request cycle
    467 
     464        // add the session persistent parameters
     465        newParam.mergeWith(((VloSession) VloSession.get()).getVloSessionPageParameters());
    468466        BookmarkablePageLink<ShowResultPage> docLink = new BookmarkablePageLink<ShowResultPage>(linkId, ShowResultPage.class,
    469467                newParam);
Note: See TracChangeset for help on using the changeset viewer.