Exemplo n.º 1
0
 private static String initPoweredBy() {
   return String.format(
       "%s%nOmniFaces %s%nPrimeFaces %s%n%s",
       Faces.getImplInfo(),
       Faces.class.getPackage().getSpecificationVersion(),
       "5.3", // PrimeFaces Constants.VERSION is since 4.0 moved to
              // RequestContext#getApplicationContext(), however the access point has changed from
              // application based to request based.
       Faces.getServerInfo());
 }
Exemplo n.º 2
0
 @Override
 public String getRequestPath() {
   String mapping = Faces.getMapping();
   String path = ResourceHandler.RESOURCE_IDENTIFIER + "/" + getResourceName();
   return Faces.getRequestContextPath()
       + (Faces.isPrefixMapping(mapping) ? (mapping + path) : (path + mapping))
       + "?ln="
       + CombinedResourceHandler.LIBRARY_NAME
       + "&v="
       + (info.getLastModified() / 60000); // To force browser refresh whenever a resource changes.
 }
 public void deletePartnership() {
   if (selectedPartnership != null) {
     if (partnershipManager.deletePartnership(selectedPartnership)) {
       init();
     } else {
       Messages.addError("partnershipDelete", bundle.getString("partnership.dialog.delete.error"));
       Faces.getContext().validationFailed();
     }
   } else {
     Messages.addError("partnershipDelete", bundle.getString("partnership.dialog.delete.error"));
     Faces.getContext().validationFailed();
   }
 }
Exemplo n.º 4
0
 @PostConstruct
 private void init() {
   try {
     classId = Integer.valueOf(Faces.getRequestParameter("classId"));
     classNo = getClassNo();
   } catch (Exception e) {
     try {
       Faces.redirect("/backend/index");
     } catch (Exception f) {
       // F**k you!
     }
   }
 }
 public void editPartnership() {
   if (selectedPartnership != null) {
     if (partnershipManager.updatePartnership(selectedPartnership) == true) {
       init();
     } else {
       Messages.addError("partnershipUpdate", bundle.getString("partnership.dialog.update.error"));
       Faces.getContext().validationFailed();
     }
   } else {
     Messages.addError(
         "partnershipUpdate", bundle.getString("partnership.dialog.update.error.notselected"));
     Faces.getContext().validationFailed();
   }
 }
Exemplo n.º 6
0
  private static void fillMenu(Page menu) {
    Set<String> resourcePaths = Faces.getResourcePaths(SHOWCASE_PATH);
    Set<String> groupPaths = new TreeSet<>(resourcePaths);

    for (String groupPath : groupPaths) {
      String groupName = groupPath.split("/")[2];
      TreeModel<Page> group = menu.addChildNode(new Page(groupName));
      Set<String> pagePaths = new TreeSet<>(Faces.getResourcePaths(groupPath));

      for (String pagePath : pagePaths) {
        String viewId = ResourcePaths.stripPrefixPath(SHOWCASE_PATH, pagePath.split("\\.")[0]);
        String title = viewId.split("/")[2];
        group.addChildNode(new Page(pagePath, viewId, title));
      }
    }
  }
Exemplo n.º 7
0
 /**
  * Constructs a new combined resource based on the given resource name. This constructor is only
  * used by {@link CombinedResourceHandler#createResource(String, String)}.
  *
  * @param name The resource name of the combined resource.
  */
 public CombinedResource(String name) {
   String[] resourcePathParts = name.split("\\.", 2)[0].split("/");
   String resourceId = resourcePathParts[resourcePathParts.length - 1];
   info = CombinedResourceInfo.get(resourceId);
   setResourceName(name);
   setLibraryName(CombinedResourceHandler.LIBRARY_NAME);
   setContentType(Faces.getMimeType(name));
 }
Exemplo n.º 8
0
 @Override
 public URL getURL() {
   try {
     // Yes, this returns a HTTP URL, not a classpath URL. There's no other way anyway.
     return new URL(Faces.getRequestDomainURL() + getRequestPath());
   } catch (MalformedURLException e) {
     // This exception should never occur.
     throw new RuntimeException(e);
   }
 }
 public void deleteAllPartnerships() {
   boolean error = false;
   init();
   for (PartnershipDVO partnershipDVO : partnershipList) {
     if (false == partnershipManager.deletePartnership(partnershipDVO)) {
       error = true;
     }
   }
   init();
   if (error) {
     Faces.getContext().validationFailed();
   }
 }
Exemplo n.º 10
0
  public void autenticar() {
    try {
      UsuarioDAO usuarioDAO = new UsuarioDAO();
      // usuarioLogado recebe o resultado do método autenticar que está no UsuarioDAO
      usuarioLogado = usuarioDAO.autenticar(usuario.getPessoa().getCpf(), usuario.getSenha());

      if (usuarioLogado == null) {
        Messages.addGlobalError("CPF e/ou senha incorretos");
        return;
      }

      Faces.redirect("./pages/usuario.xhtml");
    } catch (IOException erro) {
      erro.printStackTrace();
      Messages.addGlobalError(erro.getMessage());
    }
  }
Exemplo n.º 11
0
 /**
  * This listener force the navigation to the edit or view page of the target @{link FaqAnswer}.
  */
 public void onFaqAnswerRowSelect(SelectEvent event) {
   Faces.navigate(context().isReadOnly() ? viewFaqAnswer() : editFaqAnswer());
 }
Exemplo n.º 12
0
 /**
  * Gets the resource message.
  *
  * @param key the key
  * @return the resource message
  */
 public String getResourceMessage(String key) {
   ResourceBundle bundle = Faces.getResourceBundle("msg");
   return bundle.getString(key);
 }
Exemplo n.º 13
0
 /** Reset components. */
 public void resetComponents() {
   this.resetComponents(Faces.getViewRoot().getChildren());
 }
Exemplo n.º 14
0
 public void logout() throws IOException {
   SecurityUtils.getSubject().logout();
   Faces.invalidateSession();
   Messages.addFlashGlobalInfo("You have successfully Sing out", (Object) null);
   Faces.redirect(LOGIN_URL);
 }