View Javadoc
1   package fr.ifremer.quadrige3.synchro.server.pages;
2   
3   /*-
4    * #%L
5    * Quadrige3 Core :: Quadrige3 Synchro server
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2017 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU Affero General Public License as published by
13   * the Free Software Foundation, either version 3 of the License, or
14   * (at your option) any later version.
15   * 
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   * 
21   * You should have received a copy of the GNU Affero General Public License
22   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23   * #L%
24   */
25  
26  
27  import fr.ifremer.quadrige3.synchro.server.application.Application;
28  import fr.ifremer.quadrige3.synchro.server.application.WebSession;
29  import org.apache.wicket.AttributeModifier;
30  import org.apache.wicket.markup.html.WebMarkupContainer;
31  import org.apache.wicket.markup.html.WebPage;
32  import org.apache.wicket.markup.html.basic.Label;
33  import org.apache.wicket.markup.html.panel.FeedbackPanel;
34  import org.apache.wicket.model.IModel;
35  import org.apache.wicket.model.StringResourceModel;
36  import org.apache.wicket.request.mapper.parameter.PageParameters;
37  
38  import com.googlecode.wicket.jquery.ui.panel.JQueryFeedbackPanel;
39  
40  import fr.ifremer.quadrige3.synchro.server.config.SynchroServerConfiguration;
41  
42  public class BasePage extends WebPage {
43  
44  	private static final long serialVersionUID = 2589483412605551035L;
45  
46  	private final FeedbackPanel feedback;
47  	
48  
49  	public BasePage(final PageParameters parameters) {
50  	    WebSession session = (WebSession)getSession();
51  
52  	    // page title
53          add(new Label("pageTitle", getTitleModel()));
54  
55  		// contentLanguage
56  		WebMarkupContainer contentLanguage = new WebMarkupContainer("contentLanguage");
57  		contentLanguage.add(new AttributeModifier("content", session.getLocale().toString()));
58  		add(contentLanguage);
59  
60  		feedback = new JQueryFeedbackPanel("feedback");
61  		feedback.setOutputMarkupId(true);
62  		add(feedback);
63  		
64  		// In NOT compact mode : update version
65  		String version = getConfiguration().getVersionAsString();
66  		if (version == null) {
67  			version = "";
68  		} 
69  		add(new Label("version", version));
70  	}
71  	
72  	protected WebSession getWebSession() {
73          return (WebSession)getSession();
74      }
75  
76  	public final SynchroServerConfiguration getConfiguration() {
77          return ((Application)getApplication()).getConfiguration();
78      }
79  	
80  	protected IModel<String> getTitleModel() {
81  	    return new StringResourceModel("base.title", this, null);
82  	}
83  
84  	protected FeedbackPanel getFeedbackPanel() {
85  		return feedback;
86  	}
87  }