You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jc...@apache.org on 2007/06/18 14:01:13 UTC
svn commit: r548335 - in
/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages:
BrowserInfoForm.html BrowserInfoForm.java BrowserInfoPage.html
BrowserInfoPage.java
Author: jcompagner
Date: Mon Jun 18 05:01:12 2007
New Revision: 548335
URL: http://svn.apache.org/viewvc?view=rev&rev=548335
Log:
extracted the form out of the page so that it is easier reusable (form ajax if needed or there own info page)
Added:
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.html (with props)
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.java (with props)
Modified:
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoPage.html
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoPage.java
Added: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.html
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.html?view=auto&rev=548335
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.html (added)
+++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.html Mon Jun 18 05:01:12 2007
@@ -0,0 +1,65 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+ <wicket:head>
+ <script language="JavaScript">
+ function submitform() {
+ document.postback.navigatorAppName.value = window.navigator.appName;
+ document.postback.navigatorAppVersion.value = window.navigator.appVersion;
+ document.postback.navigatorAppCodeName.value = window.navigator.appCodeName;
+ var cookieEnabled = (window.navigator.cookieEnabled)? true : false;
+ if (typeof window.navigator.cookieEnabled == "undefined" && !cookieEnabled) {
+ document.cookie = "wickettestcookie";
+ cookieEnabled = (document.cookie.indexOf("wickettestcookie")!=-1)? true : false;
+ }
+ document.postback.navigatorCookieEnabled.value = cookieEnabled;
+ document.postback.navigatorJavaEnabled.value = window.navigator.javaEnabled();
+ document.postback.navigatorLanguage.value = window.navigator.language ? window.navigator.language : window.navigator.userLanguage;
+ document.postback.navigatorPlatform.value = window.navigator.platform;
+ document.postback.navigatorUserAgent.value = window.navigator.userAgent;
+ if (window.screen) {
+ document.postback.screenWidth.value = window.screen.width;
+ document.postback.screenHeight.value = window.screen.height;
+ document.postback.screenColorDepth.value = window.screen.colorDepth;
+ }
+ document.postback.utcOffset.value = (new Date().getTimezoneOffset() / -60);
+ document.postback.browserWidth.value = window.innerWidth || document.body.offsetWidth;
+ document.postback.browserHeight.value = window.innerHeight || document.body.offsetHeight;
+ document.postback.submit();
+ }
+ </script>
+ </wicket:head>
+ <wicket:panel>
+ <form name="postback" wicket:id="postback" style="position:absolute; left: -10000px;">
+ <input type="text" wicket:id="navigatorAppName" value="test" />
+ <input type="text" wicket:id="navigatorAppVersion" value="test" />
+ <input type="text" wicket:id="navigatorAppCodeName" />
+ <input type="text" wicket:id="navigatorCookieEnabled" />
+ <input type="text" wicket:id="navigatorJavaEnabled" />
+ <input type="text" wicket:id="navigatorLanguage" />
+ <input type="text" wicket:id="navigatorPlatform" />
+ <input type="text" wicket:id="navigatorUserAgent" />
+ <input type="text" wicket:id="screenWidth" />
+ <input type="text" wicket:id="screenHeight" />
+ <input type="text" wicket:id="screenColorDepth" />
+ <input type="text" wicket:id="utcOffset" />
+ <input type="text" wicket:id="browserWidth" />
+ <input type="text" wicket:id="browserHeight" />
+ </form>
+ </wicket:panel>
+</html>
Propchange: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.java?view=auto&rev=548335
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.java (added)
+++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.java Mon Jun 18 05:01:12 2007
@@ -0,0 +1,464 @@
+package org.apache.wicket.markup.html.pages;
+
+import org.apache.wicket.IClusterable;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.CompoundPropertyModel;
+import org.apache.wicket.protocol.http.ClientProperties;
+import org.apache.wicket.protocol.http.WebRequestCycle;
+import org.apache.wicket.protocol.http.WebSession;
+import org.apache.wicket.protocol.http.request.WebClientInfo;
+import org.apache.wicket.request.ClientInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Form for posting JavaScript properties.
+ */
+public class BrowserInfoForm extends Panel
+{
+ /** log. */
+ private static final Logger log = LoggerFactory.getLogger(BrowserInfoForm.class);
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct.
+ *
+ * @param id
+ * component id
+ */
+ public BrowserInfoForm(String id)
+ {
+ super(id);
+
+ Form form = new Form("postback", new CompoundPropertyModel(new ClientPropertiesBean()))
+ {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * @see org.apache.wicket.markup.html.form.Form#onSubmit()
+ */
+ protected void onSubmit()
+ {
+ ClientPropertiesBean propertiesBean = (ClientPropertiesBean)getModelObject();
+
+ WebRequestCycle requestCycle = (WebRequestCycle)getRequestCycle();
+ WebSession session = (WebSession)getSession();
+ ClientInfo clientInfo = session.getClientInfo();
+
+ if (clientInfo == null)
+ {
+ clientInfo = new WebClientInfo(requestCycle);
+ getSession().setClientInfo(clientInfo);
+ }
+
+ if (clientInfo instanceof WebClientInfo)
+ {
+ WebClientInfo info = (WebClientInfo)clientInfo;
+ ClientProperties properties = info.getProperties();
+ propertiesBean.merge(properties);
+ }
+ else
+ {
+ warnNotUsingWebClientInfo(clientInfo);
+ }
+
+ afterSubmit();
+ }
+ };
+ form.add(new TextField("navigatorAppName"));
+ form.add(new TextField("navigatorAppVersion"));
+ form.add(new TextField("navigatorAppCodeName"));
+ form.add(new TextField("navigatorCookieEnabled"));
+ form.add(new TextField("navigatorJavaEnabled"));
+ form.add(new TextField("navigatorLanguage"));
+ form.add(new TextField("navigatorPlatform"));
+ form.add(new TextField("navigatorUserAgent"));
+ form.add(new TextField("screenWidth"));
+ form.add(new TextField("screenHeight"));
+ form.add(new TextField("screenColorDepth"));
+ form.add(new TextField("utcOffset"));
+ form.add(new TextField("browserWidth"));
+ form.add(new TextField("browserHeight"));
+ add(form);
+ }
+
+
+ /**
+ * Log a warning that for in order to use this page, you should really be
+ * using {@link WebClientInfo}.
+ *
+ * @param clientInfo
+ * the actual client info object
+ */
+ void warnNotUsingWebClientInfo(ClientInfo clientInfo)
+ {
+ log.warn("using " + getClass().getName() + " makes no sense if you are not using "
+ + WebClientInfo.class.getName() + " (you are using "
+ + clientInfo.getClass().getName() + " instead)");
+ }
+
+ protected void afterSubmit()
+ {
+
+ }
+
+ /**
+ * Holds properties of the client.
+ */
+ public static class ClientPropertiesBean implements IClusterable
+ {
+ private static final long serialVersionUID = 1L;
+
+ private String navigatorAppCodeName;
+ private String navigatorAppName;
+ private String navigatorAppVersion;
+ private Boolean navigatorCookieEnabled = Boolean.FALSE;
+ private Boolean navigatorJavaEnabled = Boolean.FALSE;
+ private String navigatorLanguage;
+ private String navigatorPlatform;
+ private String navigatorUserAgent;
+ private String screenColorDepth;
+ private String screenHeight;
+ private String screenWidth;
+ private String utcOffset;
+ private String browserWidth;
+ private String browserHeight;
+
+ /**
+ * Gets browserHeight.
+ *
+ * @return browserHeight
+ */
+ public String getBrowserHeight()
+ {
+ return browserHeight;
+ }
+
+ /**
+ * Gets browserWidth.
+ *
+ * @return browserWidth
+ */
+ public String getBrowserWidth()
+ {
+ return browserWidth;
+ }
+
+ /**
+ * Gets navigatorAppCodeName.
+ *
+ * @return navigatorAppCodeName
+ */
+ public String getNavigatorAppCodeName()
+ {
+ return navigatorAppCodeName;
+ }
+
+ /**
+ * Gets navigatorAppName.
+ *
+ * @return navigatorAppName
+ */
+ public String getNavigatorAppName()
+ {
+ return navigatorAppName;
+ }
+
+ /**
+ * Gets navigatorAppVersion.
+ *
+ * @return navigatorAppVersion
+ */
+ public String getNavigatorAppVersion()
+ {
+ return navigatorAppVersion;
+ }
+
+ /**
+ * Gets navigatorCookieEnabled.
+ *
+ * @return navigatorCookieEnabled
+ */
+ public Boolean getNavigatorCookieEnabled()
+ {
+ return navigatorCookieEnabled;
+ }
+
+ /**
+ * Gets navigatorJavaEnabled.
+ *
+ * @return navigatorJavaEnabled
+ */
+ public Boolean getNavigatorJavaEnabled()
+ {
+ return navigatorJavaEnabled;
+ }
+
+ /**
+ * Gets navigatorLanguage.
+ *
+ * @return navigatorLanguage
+ */
+ public String getNavigatorLanguage()
+ {
+ return navigatorLanguage;
+ }
+
+ /**
+ * Gets navigatorPlatform.
+ *
+ * @return navigatorPlatform
+ */
+ public String getNavigatorPlatform()
+ {
+ return navigatorPlatform;
+ }
+
+ /**
+ * Gets navigatorUserAgent.
+ *
+ * @return navigatorUserAgent
+ */
+ public String getNavigatorUserAgent()
+ {
+ return navigatorUserAgent;
+ }
+
+ /**
+ * Gets screenColorDepth.
+ *
+ * @return screenColorDepth
+ */
+ public String getScreenColorDepth()
+ {
+ return screenColorDepth;
+ }
+
+ /**
+ * Gets screenHeight.
+ *
+ * @return screenHeight
+ */
+ public String getScreenHeight()
+ {
+ return screenHeight;
+ }
+
+ /**
+ * Gets screenWidth.
+ *
+ * @return screenWidth
+ */
+ public String getScreenWidth()
+ {
+ return screenWidth;
+ }
+
+ /**
+ * Gets utcOffset.
+ *
+ * @return utcOffset
+ */
+ public String getUtcOffset()
+ {
+ return utcOffset;
+ }
+
+ /**
+ * Merge this with the given properties object.
+ *
+ * @param properties
+ * the properties object to merge with
+ */
+ public void merge(ClientProperties properties)
+ {
+ properties.setNavigatorAppName(navigatorAppName);
+ properties.setNavigatorAppVersion(navigatorAppVersion);
+ properties.setNavigatorAppCodeName(navigatorAppCodeName);
+ properties.setCookiesEnabled((navigatorCookieEnabled != null) ? navigatorCookieEnabled
+ .booleanValue() : false);
+ properties.setJavaEnabled((navigatorJavaEnabled != null) ? navigatorJavaEnabled
+ .booleanValue() : false);
+ properties.setNavigatorLanguage(navigatorLanguage);
+ properties.setNavigatorPlatform(navigatorPlatform);
+ properties.setNavigatorUserAgent(navigatorUserAgent);
+ properties.setScreenWidth(getInt(screenWidth));
+ properties.setScreenHeight(getInt(screenHeight));
+ properties.setBrowserWidth(getInt(browserWidth));
+ properties.setBrowserHeight(getInt(browserHeight));
+ properties.setScreenColorDepth(getInt(screenColorDepth));
+ properties.setUtcOffset(utcOffset);
+ }
+
+ /**
+ * Sets browserHeight.
+ *
+ * @param browserHeight
+ * browserHeight
+ */
+ public void setBrowserHeight(String browserHeight)
+ {
+ this.browserHeight = browserHeight;
+ }
+
+ /**
+ * Sets browserWidth.
+ *
+ * @param browserWidth
+ * browserWidth
+ */
+ public void setBrowserWidth(String browserWidth)
+ {
+ this.browserWidth = browserWidth;
+ }
+
+ /**
+ * Sets navigatorAppCodeName.
+ *
+ * @param navigatorAppCodeName
+ * navigatorAppCodeName
+ */
+ public void setNavigatorAppCodeName(String navigatorAppCodeName)
+ {
+ this.navigatorAppCodeName = navigatorAppCodeName;
+ }
+
+ /**
+ * Sets navigatorAppName.
+ *
+ * @param navigatorAppName
+ * navigatorAppName
+ */
+ public void setNavigatorAppName(String navigatorAppName)
+ {
+ this.navigatorAppName = navigatorAppName;
+ }
+
+ /**
+ * Sets navigatorAppVersion.
+ *
+ * @param navigatorAppVersion
+ * navigatorAppVersion
+ */
+ public void setNavigatorAppVersion(String navigatorAppVersion)
+ {
+ this.navigatorAppVersion = navigatorAppVersion;
+ }
+
+ /**
+ * Sets navigatorCookieEnabled.
+ *
+ * @param navigatorCookieEnabled
+ * navigatorCookieEnabled
+ */
+ public void setNavigatorCookieEnabled(Boolean navigatorCookieEnabled)
+ {
+ this.navigatorCookieEnabled = navigatorCookieEnabled;
+ }
+
+ /**
+ * Sets navigatorJavaEnabled.
+ *
+ * @param navigatorJavaEnabled
+ * navigatorJavaEnabled
+ */
+ public void setNavigatorJavaEnabled(Boolean navigatorJavaEnabled)
+ {
+ this.navigatorJavaEnabled = navigatorJavaEnabled;
+ }
+
+ /**
+ * Sets navigatorLanguage.
+ *
+ * @param navigatorLanguage
+ * navigatorLanguage
+ */
+ public void setNavigatorLanguage(String navigatorLanguage)
+ {
+ this.navigatorLanguage = navigatorLanguage;
+ }
+
+ /**
+ * Sets navigatorPlatform.
+ *
+ * @param navigatorPlatform
+ * navigatorPlatform
+ */
+ public void setNavigatorPlatform(String navigatorPlatform)
+ {
+ this.navigatorPlatform = navigatorPlatform;
+ }
+
+ /**
+ * Sets navigatorUserAgent.
+ *
+ * @param navigatorUserAgent
+ * navigatorUserAgent
+ */
+ public void setNavigatorUserAgent(String navigatorUserAgent)
+ {
+ this.navigatorUserAgent = navigatorUserAgent;
+ }
+
+ /**
+ * Sets screenColorDepth.
+ *
+ * @param screenColorDepth
+ * screenColorDepth
+ */
+ public void setScreenColorDepth(String screenColorDepth)
+ {
+ this.screenColorDepth = screenColorDepth;
+ }
+
+ /**
+ * Sets screenHeight.
+ *
+ * @param screenHeight
+ * screenHeight
+ */
+ public void setScreenHeight(String screenHeight)
+ {
+ this.screenHeight = screenHeight;
+ }
+
+ /**
+ * Sets screenWidth.
+ *
+ * @param screenWidth
+ * screenWidth
+ */
+ public void setScreenWidth(String screenWidth)
+ {
+ this.screenWidth = screenWidth;
+ }
+
+ /**
+ * Sets utcOffset.
+ *
+ * @param utcOffset
+ * utcOffset
+ */
+ public void setUtcOffset(String utcOffset)
+ {
+ this.utcOffset = utcOffset;
+ }
+
+ private int getInt(String value)
+ {
+ int intValue = -1;
+ try
+ {
+ intValue = Integer.parseInt(value);
+ }
+ catch (NumberFormatException e)
+ {
+ // Do nothing
+ }
+ return intValue;
+ }
+ }
+}
\ No newline at end of file
Propchange: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoPage.html
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoPage.html?view=diff&rev=548335&r1=548334&r2=548335
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoPage.html (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoPage.html Mon Jun 18 05:01:12 2007
@@ -18,52 +18,11 @@
<html>
<head>
<meta wicket:id="meta" http-equiv="refresh">
- <script language="JavaScript">
- function submitform() {
- document.postback.navigatorAppName.value = window.navigator.appName;
- document.postback.navigatorAppVersion.value = window.navigator.appVersion;
- document.postback.navigatorAppCodeName.value = window.navigator.appCodeName;
- var cookieEnabled = (window.navigator.cookieEnabled)? true : false;
- if (typeof window.navigator.cookieEnabled == "undefined" && !cookieEnabled) {
- document.cookie = "wickettestcookie";
- cookieEnabled = (document.cookie.indexOf("wickettestcookie")!=-1)? true : false;
- }
- document.postback.navigatorCookieEnabled.value = cookieEnabled;
- document.postback.navigatorJavaEnabled.value = window.navigator.javaEnabled();
- document.postback.navigatorLanguage.value = window.navigator.language ? window.navigator.language : window.navigator.userLanguage;
- document.postback.navigatorPlatform.value = window.navigator.platform;
- document.postback.navigatorUserAgent.value = window.navigator.userAgent;
- if (window.screen) {
- document.postback.screenWidth.value = window.screen.width;
- document.postback.screenHeight.value = window.screen.height;
- document.postback.screenColorDepth.value = window.screen.colorDepth;
- }
- document.postback.utcOffset.value = (new Date().getTimezoneOffset() / -60);
- document.postback.browserWidth.value = window.innerWidth || document.body.offsetWidth;
- document.postback.browserHeight.value = window.innerHeight || document.body.offsetHeight;
- document.postback.submit();
- }
- </script>
</head>
<body onload="javascript:submitform();">
If you see this, it means that both javascript and meta-refresh are not support by
your browser configuration. Please click <a wicket:id="link" href="#">this link</a> to
continue to the original destination.
- <form name="postback" wicket:id="postback" style="position:absolute; left: -10000px;">
- <input type="text" wicket:id="navigatorAppName" value="test" />
- <input type="text" wicket:id="navigatorAppVersion" value="test" />
- <input type="text" wicket:id="navigatorAppCodeName" />
- <input type="text" wicket:id="navigatorCookieEnabled" />
- <input type="text" wicket:id="navigatorJavaEnabled" />
- <input type="text" wicket:id="navigatorLanguage" />
- <input type="text" wicket:id="navigatorPlatform" />
- <input type="text" wicket:id="navigatorUserAgent" />
- <input type="text" wicket:id="screenWidth" />
- <input type="text" wicket:id="screenHeight" />
- <input type="text" wicket:id="screenColorDepth" />
- <input type="text" wicket:id="utcOffset" />
- <input type="text" wicket:id="browserWidth" />
- <input type="text" wicket:id="browserHeight" />
- </form>
+ <div wicket:id="postback"></div>
</body>
</html>
Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoPage.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoPage.java?view=diff&rev=548335&r1=548334&r2=548335
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoPage.java (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoPage.java Mon Jun 18 05:01:12 2007
@@ -19,16 +19,12 @@
import java.io.Serializable;
import org.apache.wicket.AttributeModifier;
-import org.apache.wicket.IClusterable;
import org.apache.wicket.PageParameters;
import org.apache.wicket.RequestCycle;
import org.apache.wicket.Response;
import org.apache.wicket.markup.html.WebComponent;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.form.TextField;
-import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.protocol.http.ClientProperties;
import org.apache.wicket.protocol.http.WebRequestCycle;
@@ -62,428 +58,6 @@
*/
public class BrowserInfoPage extends WebPage
{
- /**
- * Holds properties of the client.
- */
- public static class ClientPropertiesBean implements IClusterable
- {
- private static final long serialVersionUID = 1L;
-
- private String navigatorAppCodeName;
- private String navigatorAppName;
- private String navigatorAppVersion;
- private Boolean navigatorCookieEnabled = Boolean.FALSE;
- private Boolean navigatorJavaEnabled = Boolean.FALSE;
- private String navigatorLanguage;
- private String navigatorPlatform;
- private String navigatorUserAgent;
- private String screenColorDepth;
- private String screenHeight;
- private String screenWidth;
- private String utcOffset;
- private String browserWidth;
- private String browserHeight;
-
- /**
- * Gets browserHeight.
- *
- * @return browserHeight
- */
- public String getBrowserHeight()
- {
- return browserHeight;
- }
-
- /**
- * Gets browserWidth.
- *
- * @return browserWidth
- */
- public String getBrowserWidth()
- {
- return browserWidth;
- }
-
- /**
- * Gets navigatorAppCodeName.
- *
- * @return navigatorAppCodeName
- */
- public String getNavigatorAppCodeName()
- {
- return navigatorAppCodeName;
- }
-
- /**
- * Gets navigatorAppName.
- *
- * @return navigatorAppName
- */
- public String getNavigatorAppName()
- {
- return navigatorAppName;
- }
-
- /**
- * Gets navigatorAppVersion.
- *
- * @return navigatorAppVersion
- */
- public String getNavigatorAppVersion()
- {
- return navigatorAppVersion;
- }
-
- /**
- * Gets navigatorCookieEnabled.
- *
- * @return navigatorCookieEnabled
- */
- public Boolean getNavigatorCookieEnabled()
- {
- return navigatorCookieEnabled;
- }
-
- /**
- * Gets navigatorJavaEnabled.
- *
- * @return navigatorJavaEnabled
- */
- public Boolean getNavigatorJavaEnabled()
- {
- return navigatorJavaEnabled;
- }
-
- /**
- * Gets navigatorLanguage.
- *
- * @return navigatorLanguage
- */
- public String getNavigatorLanguage()
- {
- return navigatorLanguage;
- }
-
- /**
- * Gets navigatorPlatform.
- *
- * @return navigatorPlatform
- */
- public String getNavigatorPlatform()
- {
- return navigatorPlatform;
- }
-
- /**
- * Gets navigatorUserAgent.
- *
- * @return navigatorUserAgent
- */
- public String getNavigatorUserAgent()
- {
- return navigatorUserAgent;
- }
-
- /**
- * Gets screenColorDepth.
- *
- * @return screenColorDepth
- */
- public String getScreenColorDepth()
- {
- return screenColorDepth;
- }
-
- /**
- * Gets screenHeight.
- *
- * @return screenHeight
- */
- public String getScreenHeight()
- {
- return screenHeight;
- }
-
- /**
- * Gets screenWidth.
- *
- * @return screenWidth
- */
- public String getScreenWidth()
- {
- return screenWidth;
- }
-
- /**
- * Gets utcOffset.
- *
- * @return utcOffset
- */
- public String getUtcOffset()
- {
- return utcOffset;
- }
-
- /**
- * Merge this with the given properties object.
- *
- * @param properties
- * the properties object to merge with
- */
- public void merge(ClientProperties properties)
- {
- properties.setNavigatorAppName(navigatorAppName);
- properties.setNavigatorAppVersion(navigatorAppVersion);
- properties.setNavigatorAppCodeName(navigatorAppCodeName);
- properties.setCookiesEnabled((navigatorCookieEnabled != null) ? navigatorCookieEnabled
- .booleanValue() : false);
- properties.setJavaEnabled((navigatorJavaEnabled != null) ? navigatorJavaEnabled
- .booleanValue() : false);
- properties.setNavigatorLanguage(navigatorLanguage);
- properties.setNavigatorPlatform(navigatorPlatform);
- properties.setNavigatorUserAgent(navigatorUserAgent);
- properties.setScreenWidth(getInt(screenWidth));
- properties.setScreenHeight(getInt(screenHeight));
- properties.setBrowserWidth(getInt(browserWidth));
- properties.setBrowserHeight(getInt(browserHeight));
- properties.setScreenColorDepth(getInt(screenColorDepth));
- properties.setUtcOffset(utcOffset);
- }
-
- /**
- * Sets browserHeight.
- *
- * @param browserHeight
- * browserHeight
- */
- public void setBrowserHeight(String browserHeight)
- {
- this.browserHeight = browserHeight;
- }
-
- /**
- * Sets browserWidth.
- *
- * @param browserWidth
- * browserWidth
- */
- public void setBrowserWidth(String browserWidth)
- {
- this.browserWidth = browserWidth;
- }
-
- /**
- * Sets navigatorAppCodeName.
- *
- * @param navigatorAppCodeName
- * navigatorAppCodeName
- */
- public void setNavigatorAppCodeName(String navigatorAppCodeName)
- {
- this.navigatorAppCodeName = navigatorAppCodeName;
- }
-
- /**
- * Sets navigatorAppName.
- *
- * @param navigatorAppName
- * navigatorAppName
- */
- public void setNavigatorAppName(String navigatorAppName)
- {
- this.navigatorAppName = navigatorAppName;
- }
-
- /**
- * Sets navigatorAppVersion.
- *
- * @param navigatorAppVersion
- * navigatorAppVersion
- */
- public void setNavigatorAppVersion(String navigatorAppVersion)
- {
- this.navigatorAppVersion = navigatorAppVersion;
- }
-
- /**
- * Sets navigatorCookieEnabled.
- *
- * @param navigatorCookieEnabled
- * navigatorCookieEnabled
- */
- public void setNavigatorCookieEnabled(Boolean navigatorCookieEnabled)
- {
- this.navigatorCookieEnabled = navigatorCookieEnabled;
- }
-
- /**
- * Sets navigatorJavaEnabled.
- *
- * @param navigatorJavaEnabled
- * navigatorJavaEnabled
- */
- public void setNavigatorJavaEnabled(Boolean navigatorJavaEnabled)
- {
- this.navigatorJavaEnabled = navigatorJavaEnabled;
- }
-
- /**
- * Sets navigatorLanguage.
- *
- * @param navigatorLanguage
- * navigatorLanguage
- */
- public void setNavigatorLanguage(String navigatorLanguage)
- {
- this.navigatorLanguage = navigatorLanguage;
- }
-
- /**
- * Sets navigatorPlatform.
- *
- * @param navigatorPlatform
- * navigatorPlatform
- */
- public void setNavigatorPlatform(String navigatorPlatform)
- {
- this.navigatorPlatform = navigatorPlatform;
- }
-
- /**
- * Sets navigatorUserAgent.
- *
- * @param navigatorUserAgent
- * navigatorUserAgent
- */
- public void setNavigatorUserAgent(String navigatorUserAgent)
- {
- this.navigatorUserAgent = navigatorUserAgent;
- }
-
- /**
- * Sets screenColorDepth.
- *
- * @param screenColorDepth
- * screenColorDepth
- */
- public void setScreenColorDepth(String screenColorDepth)
- {
- this.screenColorDepth = screenColorDepth;
- }
-
- /**
- * Sets screenHeight.
- *
- * @param screenHeight
- * screenHeight
- */
- public void setScreenHeight(String screenHeight)
- {
- this.screenHeight = screenHeight;
- }
-
- /**
- * Sets screenWidth.
- *
- * @param screenWidth
- * screenWidth
- */
- public void setScreenWidth(String screenWidth)
- {
- this.screenWidth = screenWidth;
- }
-
- /**
- * Sets utcOffset.
- *
- * @param utcOffset
- * utcOffset
- */
- public void setUtcOffset(String utcOffset)
- {
- this.utcOffset = utcOffset;
- }
-
- private int getInt(String value)
- {
- int intValue = -1;
- try
- {
- intValue = Integer.parseInt(value);
- }
- catch (NumberFormatException e)
- {
- // Do nothing
- }
- return intValue;
- }
- }
-
- /**
- * Form for posting JavaScript properties.
- */
- private final class PostBackForm extends Form
- {
- private static final long serialVersionUID = 1L;
-
- /**
- * Construct.
- *
- * @param id
- * component id
- */
- public PostBackForm(String id)
- {
- super(id, new CompoundPropertyModel(new ClientPropertiesBean()));
-
- add(new TextField("navigatorAppName"));
- add(new TextField("navigatorAppVersion"));
- add(new TextField("navigatorAppCodeName"));
- add(new TextField("navigatorCookieEnabled"));
- add(new TextField("navigatorJavaEnabled"));
- add(new TextField("navigatorLanguage"));
- add(new TextField("navigatorPlatform"));
- add(new TextField("navigatorUserAgent"));
- add(new TextField("screenWidth"));
- add(new TextField("screenHeight"));
- add(new TextField("screenColorDepth"));
- add(new TextField("utcOffset"));
- add(new TextField("browserWidth"));
- add(new TextField("browserHeight"));
- }
-
- /**
- * @see org.apache.wicket.markup.html.form.Form#onSubmit()
- */
- protected void onSubmit()
- {
- ClientPropertiesBean propertiesBean = (ClientPropertiesBean)getModelObject();
-
- WebRequestCycle requestCycle = (WebRequestCycle)getRequestCycle();
- WebSession session = (WebSession)getSession();
- ClientInfo clientInfo = session.getClientInfo();
-
- if (clientInfo == null)
- {
- clientInfo = new WebClientInfo(requestCycle);
- getSession().setClientInfo(clientInfo);
- }
-
- if (clientInfo instanceof WebClientInfo)
- {
- WebClientInfo info = (WebClientInfo)clientInfo;
- ClientProperties properties = info.getProperties();
- propertiesBean.merge(properties);
- }
- else
- {
- warnNotUsingWebClientInfo(clientInfo);
- }
-
- continueToPrevious();
- }
- }
-
/** log. */
private static final Logger log = LoggerFactory.getLogger(BrowserInfoPage.class);
@@ -571,21 +145,18 @@
WebMarkupContainer link = new WebMarkupContainer("link");
link.add(new AttributeModifier("href", true, new Model((Serializable)url)));
add(link);
- add(new PostBackForm("postback"));
- }
+ add(new BrowserInfoForm("postback")
+ {
+ private static final long serialVersionUID = 1L;
- /**
- * Log a warning that for in order to use this page, you should really be
- * using {@link WebClientInfo}.
- *
- * @param clientInfo
- * the actual client info object
- */
- private void warnNotUsingWebClientInfo(ClientInfo clientInfo)
- {
- log.warn("using " + getClass().getName() + " makes no sense if you are not using "
- + WebClientInfo.class.getName() + " (you are using "
- + clientInfo.getClass().getName() + " instead)");
+ /**
+ * @see org.apache.wicket.markup.html.pages.BrowserInfoForm#afterSubmit()
+ */
+ protected void afterSubmit()
+ {
+ continueToPrevious();
+ }
+ });
}
/**
@@ -603,6 +174,20 @@
response.reset();
response.redirect(requestCycle.getRequest().getRelativePathPrefixToWicketHandler()
+ continueTo);
+ }
+
+ /**
+ * Log a warning that for in order to use this page, you should really be
+ * using {@link WebClientInfo}.
+ *
+ * @param clientInfo
+ * the actual client info object
+ */
+ void warnNotUsingWebClientInfo(ClientInfo clientInfo)
+ {
+ log.warn("using " + getClass().getName() + " makes no sense if you are not using "
+ + WebClientInfo.class.getName() + " (you are using "
+ + clientInfo.getClass().getName() + " instead)");
}
/**