public boolean getRenderedForMobile() {
   if (renderedForMobile == null) {
     ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
     String userAgent = externalContext.getRequestHeaderMap().get("User-Agent");
     final boolean androidOperaMiniTest =
         userAgent.toLowerCase().contains("android")
             && (userAgent.toLowerCase().contains("opera mini")
                 || userAgent.toLowerCase().contains("like gecko"));
     renderedForMobile = androidOperaMiniTest;
     logger.trace("==>>renderedForMobile=" + renderedForMobile);
   }
   return renderedForMobile.booleanValue();
 }
Ejemplo n.º 2
0
  @PostConstruct
  public void init() {
    serviceDAO = new ServiceDAO();
    ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
    // originalURL = (String)
    // externalContext.getRequestMap().get(RequestDispatcher.FORWARD_REQUEST_URI);

    originalURL = (String) externalContext.getRequestHeaderMap().get("referer");

    if (originalURL == null) {
      originalURL = externalContext.getRequestContextPath() + "/index.jsf";
    } else {
      String originalQuery =
          (String) externalContext.getRequestMap().get(RequestDispatcher.FORWARD_QUERY_STRING);

      if (originalQuery != null) {
        originalURL += "?" + originalQuery;
      }
    }

    // log.debug("originalURL==>" + originalURL);
  }