public void selStagePropChange(ActionEvent e) {
    String selPropertyID = null, selStageName = null, selValue = null;
    FacesContext context = FacesContext.getCurrentInstance();
    Object o1 = context.getExternalContext().getRequestParameterMap().get("selPropID");
    if (o1 != null) selPropertyID = (String) o1;
    Object o2 = context.getExternalContext().getRequestParameterMap().get("selPropStageName");
    if (o2 != null) selStageName = (String) o2;

    Object source = e.getComponent();
    if (source instanceof HtmlAjaxCommandButton) {
      HtmlAjaxCommandButton sel = (HtmlAjaxCommandButton) source;
      selValue = (String) sel.getValue();
    }

    if (selPropertyID == null || selStageName == null || selValue == null) return;

    // all required parameters received - now store the updates
    HashMap<String, String> selection;
    if (!stageProps.containsKey(selPropertyID)) {
      selection = new HashMap<String, String>();
    } else {
      selection = stageProps.get(selPropertyID);
    }
    selection.put(selStageName, selValue);
    stageProps.put(selPropertyID, selection);
  }
  protected void encodeRowExpansion(FacesContext context, DataTable table) throws IOException {
    ResponseWriter writer = context.getResponseWriter();
    Map<String, String> params = context.getExternalContext().getRequestParameterMap();
    int expandedRowIndex =
        Integer.parseInt(params.get(table.getClientId(context) + "_expandedRowIndex"));
    String rowIndexVar = table.getRowIndexVar();

    table.setRowIndex(expandedRowIndex);

    if (rowIndexVar != null) {
      context.getExternalContext().getRequestMap().put(rowIndexVar, expandedRowIndex);
    }

    writer.startElement("tr", null);
    writer.writeAttribute("style", "display:none", null);
    writer.writeAttribute(
        "class", DataTable.EXPANDED_ROW_CONTENT_CLASS + " ui-widget-content", null);

    writer.startElement("td", null);
    writer.writeAttribute("colspan", table.getColumnsCount(), null);

    table.getRowExpansion().encodeAll(context);

    writer.endElement("td");

    writer.endElement("tr");

    table.setRowIndex(-1);
  }
  @Override
  public void handle() throws FacesException {
    final Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator();

    while (i.hasNext()) {
      ExceptionQueuedEvent event = i.next();
      ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();

      Throwable t = context.getException();

      final FacesContext fc = FacesContext.getCurrentInstance();
      final Map<String, Object> requestMap = fc.getExternalContext().getRequestMap();

      try {
        System.out.printf(">>> Exception caught: %s", t.getMessage());
        t.printStackTrace();

        requestMap.put("exceptionMessage", t.getMessage());

        ExternalContext extContext = fc.getExternalContext();
        String url = extContext.encodeActionURL(extContext.getRequestContextPath() + "/500.xhtml");
        extContext.redirect(url);
      } catch (Exception e) {
        String errorPageLocation = "/WEB-INF/500.xhtml";
        fc.setViewRoot(fc.getApplication().getViewHandler().createView(fc, errorPageLocation));
        fc.getPartialViewContext().setRenderAll(false);
        fc.renderResponse();
      } finally {
        i.remove();
      }
    }

    getWrapped().handle();
  }
  public static void imprimeRelatorio(String nomeRelatorio, HashMap parametros, List lista) {
    try {
      JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(lista);
      FacesContext facesContext = FacesContext.getCurrentInstance();
      ServletContext servletContext =
          (ServletContext) facesContext.getExternalContext().getContext();
      String path = servletContext.getRealPath("/WEB-INF/relatorios/");
      // parametro jasper report
      parametros.put("SUBREPORT DIR", path + File.separator);
      JasperPrint jasperPrint =
          JasperFillManager.fillReport(
              servletContext.getRealPath("/WEB-INF/relatorios/")
                  + File.separator
                  + nomeRelatorio
                  + ".jasper",
              parametros,
              dataSource);
      byte[] b = JasperExportManager.exportReportToPdf(jasperPrint);

      HttpServletResponse res =
          (HttpServletResponse) facesContext.getExternalContext().getResponse();
      res.setContentType("application/pdf");
      int codigo = (int) (Math.random() * 1000);
      res.setHeader("Content-disposition", "inline);filename-relatorio_" + codigo + ".pdf");
      res.getOutputStream().write(b);
      facesContext.responseComplete();

    } catch (Exception e) {
      UtilMensagens.mensagemErro("Erro ao imprimir: " + UtilErros.getMensagemErro(e));
      e.printStackTrace();
    }
  }
  public String provideIframePanelUri(ActivityInstance ai, View view) {
    String uri = null;

    try {
      FacesContext jsfContext = FacesContext.getCurrentInstance();

      // must prefix root relative URIs with the current context root
      if (isIceFacesPanel(ai)) {
        uri = jsfContext.getExternalContext().getRequestContextPath() + providePanelUri(ai);
      } else {
        // TODO configure servlet mapping
        uri =
            jsfContext.getExternalContext().getRequestContextPath()
                + "/faces"
                + VIEW_ID_NON_IFACE_FACELET_CONTAINER;
      }
    } catch (Exception e) {
      // not in JSF?
      trace.warn("Failed determining context root.", e);
    }

    if (StringUtils.isNotEmpty(uri)) {
      uri += (-1 == uri.indexOf("?")) ? "?" : "&";
      uri +=
          IframePanelConstants.QSTR_VIEW_URL
              + "="
              + new String(Base64.encode(view.getUrl().getBytes()));
    }

    return uri;
  }
  public MantCuentasBean() {

    this.selectedUsuariofac = new Usuariofac();
    this.usuafac = new ArrayList<Usuariofac>();

    faceContext = FacesContext.getCurrentInstance();
    httpServletRequest = (HttpServletRequest) faceContext.getExternalContext().getRequest();
    if (httpServletRequest.getSession().getAttribute("sesionUsuario") != null) {
      System.out.println(
          "este hay " + httpServletRequest.getSession().getAttribute("sesionUsuario").toString());
    } else {
      if (httpServletRequest.getSession().isNew()) {
        try {
          faceContext.getExternalContext().redirect("/TesisProduccion2/index.jsf");
        } catch (Exception e) {
        }
      } else {
        try {
          faceContext.getExternalContext().redirect("/TesisProduccion2/index.jsf");
        } catch (Exception e) {
        }
      }
    }

    listaCursos = new ArrayList<SelectItem>();
    ArrayList<String> facu = this.listarVeterinarias();
    for (int i = 0; i < facu.size(); i++) {
      SelectItem item = new SelectItem();
      item.setValue(facu.get(i));
      item.setLabel(facu.get(i));
      listaCursos.add(item);
    }
  }
Example #7
0
  public EditarTecnicoETMB() {

    logger.setLevel(Level.ALL);
    logger.entering(this.getClass().getName(), "EditarTecnicoETMB");
    /**/
    this.ediciones = new ArrayList();
    this.traslados = new ArrayList();
    this.facesContext1 = FacesContext.getCurrentInstance();
    this.httpServletRequest1 = (HttpServletRequest) facesContext1.getExternalContext().getRequest();

    this.facesContext = FacesContext.getCurrentInstance();
    this.httpServletRequest = (HttpServletRequest) facesContext.getExternalContext().getRequest();

    if (httpServletRequest1.getSession().getAttribute("nueF") != null) {
      this.nue = (int) httpServletRequest1.getSession().getAttribute("nueF");
      logger.log(Level.FINEST, "Nue recibido {0}", this.nue);
    }

    if (httpServletRequest.getSession().getAttribute("cuentaUsuario") != null) {
      this.usuarioS = (String) httpServletRequest.getSession().getAttribute("cuentaUsuario");
      logger.log(Level.FINEST, "Cuenta Usuario recibido {0}", this.usuarioS);
    }

    logger.exiting(this.getClass().getName(), "EditarTecnicoETMB");
  }
Example #8
0
  public String logout() {
    boolean isShib2Authentication =
        OxTrustConstants.APPLICATION_AUTHORIZATION_NAME_SHIBBOLETH2.equals(
            Contexts.getSessionContext().get(OxTrustConstants.APPLICATION_AUTHORIZATION_TYPE));

    if (isShib2Authentication) {
      // After this redirect we should invalidate this session
      try {
        HttpServletResponse userResponse =
            (HttpServletResponse) facesContext.getExternalContext().getResponse();
        HttpServletRequest userRequest =
            (HttpServletRequest) facesContext.getExternalContext().getRequest();

        String redirectUrl =
            String.format("%s%s", applicationConfiguration.getIdpUrl(), "/idp/logout.jsp");
        String url =
            String.format(
                "%s://%s/Shibboleth.sso/Logout?return=%s",
                userRequest.getScheme(), userRequest.getServerName(), redirectUrl);

        userResponse.sendRedirect(url);
        facesContext.responseComplete();
      } catch (IOException ex) {
        log.error("Failed to redirect to SSO logout page", ex);
      }
    }

    return isShib2Authentication
        ? OxTrustConstants.RESULT_LOGOUT_SSO
        : OxTrustConstants.RESULT_LOGOUT;
  }
  public void executeReport() throws IOException {
    FacesContext facesContext = FacesContext.getCurrentInstance();

    HttpServletResponse response =
        (HttpServletResponse) facesContext.getExternalContext().getResponse();

    InputStream reportStream =
        facesContext.getExternalContext().getResourceAsStream("caminho_arquivo.jasper");

    response.setContentType("application/pdf");

    response.setHeader("Content-disposition", "inline;filename=relatorio.pdf");

    try {
      ServletOutputStream servletOutputStream = response.getOutputStream();

      JRBeanCollectionDataSource datasource = new JRBeanCollectionDataSource(arrayList);

      JasperRunManager.runReportToPdfStream(
          reportStream, servletOutputStream, parameters, datasource);

      servletOutputStream.flush();
      servletOutputStream.close();
    } catch (JRException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      facesContext.responseComplete();
    }
  }
Example #10
0
  public ListLogPage() throws Exception {
    FacesContext ctx = FacesContext.getCurrentInstance();
    if (ctx.getExternalContext().getRequestParameterMap().get("host") != null) {
      host = (String) ctx.getExternalContext().getRequestParameterMap().get("host");
    }

    init();
  }
  public static void resetSessionScopedBean(String value) {

    FacesContext fc = FacesContext.getCurrentInstance();

    if (fc.getExternalContext().getSessionMap().containsKey(value)) {
      fc.getExternalContext().getSessionMap().remove(value);
    }
  }
Example #12
0
 public void logout() throws IOException {
   FacesContext context = FacesContext.getCurrentInstance();
   ExternalContext externalContext = context.getExternalContext();
   ServletContext servletContext = (ServletContext) context.getExternalContext().getContext();
   faceContext = FacesContext.getCurrentInstance();
   httpServletRequest = (HttpServletRequest) faceContext.getExternalContext().getRequest();
   String redirectPath = "/faces/ositran/logueo.xhtml";
   externalContext.redirect(servletContext.getContextPath() + redirectPath);
 }
 public void clearVerifiableComponentsIfNecessary(FacesContext context) {
   // JSFC-2524
   Boolean isClear =
       ((Boolean) context.getExternalContext().getRequestMap().get(CLEAR_VERIFIABLE_COMPONENTS));
   if (isClear != null && isClear) {
     verifiableComponents = null;
     context.getExternalContext().getRequestMap().put(CLEAR_VERIFIABLE_COMPONENTS, Boolean.FALSE);
   }
 }
  /** Set the cookie */
  protected void setCookieValueIfEnabled(String value) {
    FacesContext ctx = FacesContext.getCurrentInstance();
    if (isCookieEnabled() && ctx != null) {
      HttpServletRequest request = (HttpServletRequest) ctx.getExternalContext().getRequest();
      HttpServletResponse response = (HttpServletResponse) ctx.getExternalContext().getResponse();

      response.addHeader("SET-COOKIE", constructCookieHeader(value, request.isSecure()));
    }
  }
Example #15
0
  public void replacePropertyResolver(ActionEvent action) {
    FacesContext context = FacesContext.getCurrentInstance();
    Application app = context.getApplication();

    // see if we need to take action-
    if (null
        == context.getExternalContext().getSessionMap().get("systest.replacePropertyResolver")) {
      final PropertyResolver oldProp = app.getPropertyResolver();
      PropertyResolver newProp =
          new PropertyResolver() {
            public Object getValue(Object base, Object property)
                throws EvaluationException, PropertyNotFoundException {
              return oldProp.getValue(base, property);
            }

            public Object getValue(Object base, int index)
                throws EvaluationException, PropertyNotFoundException {
              return oldProp.getValue(base, index);
            }

            public void setValue(Object base, Object property, Object value)
                throws EvaluationException, PropertyNotFoundException {
              TestBean.this.setValueChangeMessage("setValue() called");
              oldProp.setValue(base, property, value);
            }

            public void setValue(Object base, int index, Object value)
                throws EvaluationException, PropertyNotFoundException {
              TestBean.this.setValueChangeMessage("setValue() called");
              oldProp.setValue(base, index, value);
            }

            public boolean isReadOnly(Object base, Object property)
                throws EvaluationException, PropertyNotFoundException {
              return oldProp.isReadOnly(base, property);
            }

            public boolean isReadOnly(Object base, int index)
                throws EvaluationException, PropertyNotFoundException {
              return oldProp.isReadOnly(base, index);
            }

            public Class getType(Object base, Object property)
                throws EvaluationException, PropertyNotFoundException {
              return oldProp.getType(base, property);
            }

            public Class getType(Object base, int index)
                throws EvaluationException, PropertyNotFoundException {
              return oldProp.getType(base, index);
            }
          };
      app.setPropertyResolver(newProp);
      context.getExternalContext().getSessionMap().put("systest.replacePropertyResolver", oldProp);
    }
  }
  public static Optional<String> getLocalePrefixForLocateResource(final FacesContext facesContext) {
    String localePrefix = null;
    boolean isResourceRequest =
        facesContext.getApplication().getResourceHandler().isResourceRequest(facesContext);

    if (isResourceRequest) {
      localePrefix =
          facesContext
              .getExternalContext()
              .getRequestParameterMap()
              .get(OsgiResource.REQUEST_PARAM_LOCALE);

      if (localePrefix != null) {
        if (!ResourceValidationUtils.isValidLocalePrefix(localePrefix)) {
          return Optional.empty();
        }
        return Optional.of(localePrefix);
      }
    }

    String bundleName = facesContext.getApplication().getMessageBundle();

    if (null != bundleName) {
      Locale locale = null;

      if (isResourceRequest || facesContext.getViewRoot() == null) {
        locale = facesContext.getApplication().getViewHandler().calculateLocale(facesContext);
      } else {
        locale = facesContext.getViewRoot().getLocale();
      }

      try {
        // load resource via ServletContext because due to Classloader
        ServletContext servletContext =
            (ServletContext) facesContext.getExternalContext().getContext();
        PropertyResourceBundle resourceBundle = null;
        try {
          URL resourceUrl =
              servletContext.getResource(
                  '/' + bundleName.replace('.', '/') + '_' + locale + ".properties");
          if (resourceUrl != null) {
            resourceBundle = new PropertyResourceBundle(resourceUrl.openStream());
          }
        } catch (Exception e) {
          e.printStackTrace();
        }
        if (resourceBundle != null) {
          localePrefix = resourceBundle.getString(ResourceHandler.LOCALE_PREFIX);
        }
      } catch (MissingResourceException e) {
        // Ignore it and return null
      }
    }
    return Optional.ofNullable(localePrefix);
  }
  @Override
  public void encodeEnd(FacesContext context, UIComponent uiComponent) throws IOException {

    DeviceResource comp = (DeviceResource) uiComponent;

    boolean ios6orHigher = false;
    boolean desktop = false;
    boolean isSimulated = false;

    ClientDescriptor client =
        ClientDescriptor.getInstance(
            (HttpServletRequest) context.getExternalContext().getRequest());
    ios6orHigher = client.isIOS6() || client.isIOS7();
    if (!ios6orHigher) {
      desktop = client.isDesktopBrowser();
    }
    if (desktop) {
      isSimulated = client.isSimulator();
    }

    String contextRoot = context.getExternalContext().getRequestContextPath();

    ResponseWriter writer = context.getResponseWriter();

    writer.write(String.format(LINK_FAV_ICON, contextRoot));
    writer.write(String.format(LINK_SHORTCUT_ICON, contextRoot));
    if (!desktop) {
      if (client.isIOS7()) {
        writer.write(META_VIEWPORT_IOS7);
      } else {
        writer.write(META_VIEWPORT);
      }

      if (ios6orHigher) {
        writer.write(META_IOS_WEBAPPCAPABLE);
        writer.write(META_IOS_APPSTATUSBAR);
        if (isNeedAppBanner(context, comp, client)) {
          String smartAppMeta =
              String.format(META_IOS_SMARTAPPBANNER, IOS_APP_ID, this.getRegisterBridgetItURL());
          writer.write(smartAppMeta);
          context.getAttributes().put(Constants.IOS_SMART_APP_BANNER_KEY, Boolean.TRUE);
        }
      }
    }

    if (client.isAndroid2OS()) {
      writeOverthrow(context);
    }
    Theme theme = (Theme) context.getExternalContext().getSessionMap().get(MOBI_THEME_KEY);

    if (isSimulated) {
      writeSimulatorResources(context, comp, theme);
    }
    encodeMarkers(writer, theme, client);
  }
 private Map<String, Collection<FacesMessage>> getMessageCache(FacesContext context) {
   if (context.getExternalContext().getSessionMap().get(sessionToken) != null) {
     return (Map<String, Collection<FacesMessage>>)
         context.getExternalContext().getSessionMap().get(sessionToken);
   } else {
     Map<String, Collection<FacesMessage>> messageCache =
         Collections.synchronizedMap(new HashMap<String, Collection<FacesMessage>>());
     context.getExternalContext().getSessionMap().put(sessionToken, messageCache);
     return messageCache;
   }
 }
Example #19
0
 public void pullStateItem() {
   FacesContext facesContext = context.get();
   if (facesContext != null
       && !facesContext.isPostback()
       && facesContext.getExternalContext().getRequestParameterMap().get("itemIndex") != null) {
     Integer itemIndex =
         Integer.valueOf(
             facesContext.getExternalContext().getRequestParameterMap().get("itemIndex"));
     this.pullStateItem(itemIndex);
   }
 }
Example #20
0
  public void logoutSesionInvalidate() throws IOException {
    faceContext = FacesContext.getCurrentInstance();

    ExternalContext externalContext = faceContext.getExternalContext();
    ServletContext servletContext = (ServletContext) faceContext.getExternalContext().getContext();
    httpServletRequest = (HttpServletRequest) faceContext.getExternalContext().getRequest();
    HttpSession session = httpServletRequest.getSession();
    session.invalidate();
    String redirectPath = "/faces/ositran/logueo.xhtml";
    externalContext.redirect(servletContext.getContextPath() + redirectPath);
  }
Example #21
0
  /** Método que establece la conexión con una base de datos. */
  private void conectar() {
    try {
      FacesContext facesContext = FacesContext.getCurrentInstance();
      String DB_URL = facesContext.getExternalContext().getInitParameter("DB_URL");
      String DB_usuario = facesContext.getExternalContext().getInitParameter("DB_usuario");
      String DB_password = facesContext.getExternalContext().getInitParameter("DB_password");

      Class.forName("org.postgresql.Driver").newInstance();

      conexion = java.sql.DriverManager.getConnection(DB_URL, DB_usuario, DB_password);
    } catch (Exception ex) {
    }
  }
Example #22
0
  private String calculateViewId(FacesContext context) {
    Map map = context.getExternalContext().getRequestMap();

    String viewId = (String) map.get(RequestDispatcher.INCLUDE_PATH_INFO);

    if (viewId == null) viewId = context.getExternalContext().getRequestPathInfo();

    if (viewId == null) viewId = (String) map.get(RequestDispatcher.INCLUDE_SERVLET_PATH);

    if (viewId == null) viewId = context.getExternalContext().getRequestServletPath();

    return viewId;
  }
  DeltaSpikeFacesContextWrapper(FacesContext wrappedFacesContext, ClientWindow clientWindow) {
    this.wrappedFacesContext = wrappedFacesContext;

    if (ClassDeactivationUtils.isActivated(DeltaSpikeExternalContextWrapper.class)) {
      this.wrappedExternalContext =
          new DeltaSpikeExternalContextWrapper(
              wrappedFacesContext.getExternalContext(), clientWindow);
    } else {
      this.wrappedExternalContext = wrappedFacesContext.getExternalContext();
    }

    setCurrentInstance(this);
  }
  /**
   * Wir führen unseren Code in der "serviceView" - Methode aus, da wir hier Zugriff auf alle
   * notwendigen Variablen wie FacesContext + ApplicationContext haben
   */
  @Override
  protected void serviceView(final FacesContext fc, final FacesController controller) {
    ServletRequest req = (ServletRequest) fc.getExternalContext().getRequest();
    ServletResponse res = (ServletResponse) fc.getExternalContext().getResponse();

    String action = req.getParameter("action");

    if ("invoke".equals(action)) {
      invoke(req, res);
    } else if ("register".equals(action)) {
      registerJobGroups(req, res);
      registerTransponder(req, res);
    }
  }
  /**
   * Return the <code>ModuleConfig</code> for the application module this form is being processed
   * for.
   *
   * @param context The <code>FacesContext</code> for the current request
   * @exception IllegalArgumentException if no <code>ModuleConfig</code> can be found
   */
  public ModuleConfig lookupModuleConfig(FacesContext context) {

    // Look up the application module configuration information we need
    ModuleConfig modConfig =
        (ModuleConfig) context.getExternalContext().getRequestMap().get(Globals.MODULE_KEY);
    if (modConfig == null) {
      modConfig =
          (ModuleConfig) context.getExternalContext().getApplicationMap().get(Globals.MODULE_KEY);
    }
    if (modConfig == null) {
      throw new IllegalArgumentException("Cannot find module configuration");
    }
    return (modConfig);
  }
  /**
   * Redirect to edit section page with selected section id
   *
   * @param evt ActionEvent object
   */
  public void editSection(ActionEvent evt) {
    if (!saveModuleDates()) return;
    resetSelectedLists();
    FacesContext ctx = FacesContext.getCurrentInstance();
    Map params = ctx.getExternalContext().getRequestParameterMap();
    int selModId = Integer.parseInt((String) params.get("editsecmodid"));
    int selSecId = Integer.parseInt((String) params.get("sectionId"));

    try {
      ctx.getExternalContext().redirect("editmodulesections.jsf?sectionId=" + selSecId);
    } catch (Exception e) {
      return;
    }
  }
Example #27
0
 public String logout() throws IOException {
   String tmpUsername = this.username;
   FacesContext context = FacesContext.getCurrentInstance();
   String contextPath = context.getExternalContext().getRequestContextPath();
   context.getExternalContext().redirect(contextPath + "/login.jspx");
   username = null;
   userrole = 4;
   context.responseComplete();
   /*DatabasePolicy.removeEntityPermissionCacheEntry(tmpUsername);*/
   HttpSession session = (HttpSession) context.getExternalContext().getSession(false);
   session.setAttribute("FILTER_SUBJECT", null);
   // Session will be invalidate in the loggedOut.jsp page
   return "logout";
 }
  private static Resource createResource(FacesContext context) {
    if (Hacks.isPrimeFacesDynamicResourceRequest(context)) {
      return null;
    }

    String pathInfo = context.getExternalContext().getRequestPathInfo();
    String resourceName = (pathInfo != null) ? pathInfo.substring(1) : "";

    if (resourceName.isEmpty()) {
      return null;
    }

    String libraryName = context.getExternalContext().getRequestParameterMap().get("ln");
    return context.getApplication().getResourceHandler().createResource(resourceName, libraryName);
  }
  @Transactional
  public void checkout() throws IOException {
    systemUserDAO.save(systemUser);

    Checkout checkout = new Checkout(systemUser, cart);
    checkoutDAO.save(checkout);

    String contextName = facesContext.getExternalContext().getContextName();

    HttpServletResponse response =
        (HttpServletResponse) facesContext.getExternalContext().getResponse();
    response.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
    response.setHeader(
        "Location", "/" + contextName + "/services/payment?uuid=" + checkout.getUuid());
  }
  /**
   * Encode the case when the <code>var</code> attribute is specified. This will render without any
   * HTML markup and put the current message in the request scope as identified by the <code>var
   * </code> attribute. Note: the iteration is by design completely stateless.
   *
   * @param context The involved faces context.
   * @param component The messages component.
   * @param messages The queued faces messages.
   * @throws IOException When an I/O error occurs.
   */
  protected void encodeMessagesRepeater(
      FacesContext context, OmniMessages component, List<FacesMessage> messages)
      throws IOException {
    String var = component.getVar();
    Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
    Object originalVar = requestMap.get(var);

    try {
      for (FacesMessage message : messages) {
        if (message.isRendered() && !component.isRedisplay()) {
          continue;
        }

        requestMap.put(var, message);

        for (UIComponent child : component.getChildren()) {
          child.encodeAll(context);
        }

        message.rendered();
      }
    } finally {
      if (originalVar != null) {
        requestMap.put(var, originalVar);
      } else {
        requestMap.remove(var);
      }
    }
  }