Package org.springframework.mobile.device

Examples of org.springframework.mobile.device.Device


  @Override
  protected String getDeviceViewNameInternal(String viewName) {
    RequestAttributes attrs = RequestContextHolder.getRequestAttributes();
    Assert.isInstanceOf(ServletRequestAttributes.class, attrs);
    HttpServletRequest request = ((ServletRequestAttributes) attrs).getRequest();
    Device device = DeviceUtils.getCurrentDevice(request);
    SitePreference sitePreference = SitePreferenceUtils.getCurrentSitePreference(request);
    String resolvedViewName = viewName;
    if (ResolverUtils.isNormal(device, sitePreference)) {
      resolvedViewName = getNormalPrefix() + viewName + getNormalSuffix();
    } else if (ResolverUtils.isMobile(device, sitePreference)) {
View Full Code Here


    this.tabletIsMobile = tabletIsMobile == null ? false : tabletIsMobile;
  }

  public boolean handleSiteSwitch(HttpServletRequest request, HttpServletResponse response) throws IOException {
    SitePreference sitePreference = sitePreferenceHandler.handleSitePreference(request, response);
    Device device = DeviceUtils.getRequiredCurrentDevice(request);
    if (mobileSiteUrlFactory != null && mobileSiteUrlFactory.isRequestForSite(request)) {
      if (ResolverUtils.isTablet(device, sitePreference)) {
        if (tabletSiteUrlFactory != null) {
          response.sendRedirect(response.encodeRedirectURL(tabletSiteUrlFactory.createSiteUrl(request)));
          return false;
View Full Code Here

     */
    @Override
    public boolean preHandle(javax.servlet.http.HttpServletRequest request,
            HttpServletResponse response, Object handler) throws Exception {
        final String mobil = "detectedDevice";
        final Device device = deviceResolver.resolveDevice(request);
        final UserAgentStringParser parser = UADetectorServiceFactory.getResourceModuleParser();
        final UserAgent agent = parser.parse(request.getHeader("User-Agent"));
        log.trace("user agent --->" + agent.toString());
        request.setAttribute("so", agent.getOperatingSystem().getFamily());
        request.setAttribute("bo_vendor", agent.getProducer());
        request.setAttribute("agent_type", agent.getTypeName());
        request.setAttribute("agent_name", agent.getName());
        request.setAttribute("agent_family", agent.getFamily());
        request.setAttribute("agent_pro_url", agent.getProducerUrl());
        request.setAttribute("bo_vendor_ver", agent.getVersionNumber().getMajor());
        final Boolean enabledMobileDevice = EnMePlaceHolderConfigurer
                .getBooleanProperty("application.mobile.enabled");
        final Boolean forceMobileDevice = EnMePlaceHolderConfigurer
                .getBooleanProperty("application.mobile.only");
        log.trace(" enabledMobileDevice => "+enabledMobileDevice);
        log.trace(" forceMobileDevice => "+forceMobileDevice);
        // if is mobile device and if mobile supoort is enabled
        if (enabledMobileDevice && device.isMobile()) {
            //force to use mobile view.
            request.setAttribute(mobil, device.isMobile());
            log.trace(" forceMobileDevice => 1");
        // force to be a mobile device
        } else if (forceMobileDevice) {
            request.setAttribute(mobil, Boolean.TRUE);
            log.trace(" forceMobileDevice => 2");
        // if is a tablet and is not forced to be mobile
        } else if (!forceMobileDevice && device.isTablet()) {
            request.setAttribute(mobil, Boolean.TRUE);
            log.trace(" forceMobileDevice => 3");
        // if is normal (NO MOBILE AND TABLE) and is not force to be a mobile device
        } else if (!forceMobileDevice && device.isNormal()) {
            request.setAttribute(mobil, Boolean.FALSE);
            log.trace(" forceMobileDevice => 4");
        // another options, display always NON mobile site
        } else {
            request.setAttribute(mobil, Boolean.FALSE);
View Full Code Here

TOP

Related Classes of org.springframework.mobile.device.Device

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.