Exemplo n.º 1
0
  private int getFlatSize() {
    FacesContext context = FacesContext.getCurrentInstance();
    UIViewRoot root = context.getViewRoot();

    UIData outerData = (UIData) root.findComponent(list.getOuterDataName()),
        innerData = (UIData) root.findComponent(list.getInnerDataName());

    int size = outerData.getRowCount() * innerData.getRowCount();
    return size;
  }
Exemplo n.º 2
0
  private int getFlatIndex() {
    FacesContext context = FacesContext.getCurrentInstance();
    UIViewRoot root = context.getViewRoot();

    UIData outerData = (UIData) root.findComponent(list.getOuterDataName()),
        innerData = (UIData) root.findComponent(list.getInnerDataName());

    int outerIndex = outerData.getRowIndex(),
        innerIndex = innerData.getRowIndex(),
        innerRowCount = innerData.getRowCount(),
        index = innerRowCount * outerIndex + innerIndex;

    return index;
  }
  public void inserir() {
    EntityManager manager = this.getManager();
    FornecedorDao fncDao = new FornecedorDaoJpa(manager);
    fncDao.save(fornecedor);
    this.mensagens.info();

    FacesContext facesContext = FacesContext.getCurrentInstance();
    UIViewRoot uiViewRoot = facesContext.getViewRoot();
    limparComponente.cleanSubmittedValues(uiViewRoot.findComponent("form:painel"));
    /*return "/cadastro/fornecedor.xhtml";*/
  }
Exemplo n.º 4
0
  public void renderTabs(ValueChangeEvent e) {

    FacesContext fc = FacesContext.getCurrentInstance();
    UIViewRoot uiViewRoot = fc.getViewRoot();
    TipoUsuario tipo = (TipoUsuario) e.getNewValue();
    System.out.println("Valor de idRol: " + tipo);
    System.out.println("Inicio de IF");
    RequestContext context = RequestContext.getCurrentInstance();
    //  context.execute("alert('Prueba')");
    if (tipo.getNombre().equalsIgnoreCase("estudiante")) {

      Panel panelPersonales = (Panel) uiViewRoot.findComponent("formUsuario:idDatosPersonales");
      panelPersonales.setRendered(true);
      Panel panelDatosFamilia = (Panel) uiViewRoot.findComponent("formUsuario:idDatosFamilia");
      panelDatosFamilia.setRendered(true);
      Panel panelMedicos = (Panel) uiViewRoot.findComponent("formUsuario:idDatosMedicos");
      panelMedicos.setRendered(true);
      Panel panelEconomicos = (Panel) uiViewRoot.findComponent("formUsuario:idDatosEconomicos");
      panelEconomicos.setRendered(true);
      Panel panelProfesional = (Panel) uiViewRoot.findComponent("formUsuario:idDatosProfesional");
      panelProfesional.setRendered(false);
    } else {

      if (tipo.getNombre().equalsIgnoreCase("Secretaria")
          || (tipo.getNombre().equalsIgnoreCase("Docente"))) {
        // context.execute("alert('PruebaAcord Tab 2')");
        Panel panelPersonales = (Panel) uiViewRoot.findComponent("formUsuario:idDatosPersonales");
        panelPersonales.setRendered(true);
        Panel panelDatosFamilia = (Panel) uiViewRoot.findComponent("formUsuario:idDatosFamilia");
        panelDatosFamilia.setRendered(false);
        Panel panelMedicos = (Panel) uiViewRoot.findComponent("formUsuario:idDatosMedicos");
        panelMedicos.setRendered(false);
        Panel panelEconomicos = (Panel) uiViewRoot.findComponent("formUsuario:idDatosEconomicos");
        panelEconomicos.setRendered(false);
        Panel panelProfesional = (Panel) uiViewRoot.findComponent("formUsuario:idDatosProfesional");
        panelProfesional.setRendered(true);
      }
    }
  }
 public void specialAccessAction(ActionEvent evt) {
   resetSelectedLists();
   if (!saveModuleDates()) return;
   FacesContext ctx = FacesContext.getCurrentInstance();
   UIViewRoot root = ctx.getViewRoot();
   UIData table = (UIData) root.findComponent("listauthmodulesform").findComponent("table");
   ModuleDateBean mdbean = (ModuleDateBean) table.getRowData();
   Integer selModId = mdbean.getModuleId();
   try {
     ctx.getExternalContext().redirect("list_special_access.jsf?editmodid=" + selModId.toString());
   } catch (Exception e) {
     return;
   }
 }
  public void haberListener(ValueChangeEvent valueChangueEvent) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    UIViewRoot uiViewRoot = facesContext.getViewRoot();
    actualizarValores();
    BigDecimal nuevoValor = (BigDecimal) valueChangueEvent.getNewValue();
    BigDecimal viejoValor = (BigDecimal) valueChangueEvent.getOldValue();

    if (nuevoValor.compareTo(viejoValor) > 0) {
      totalHaber = totalHaber.add(nuevoValor);
    } else {
      totalHaber = totalHaber.subtract(nuevoValor);
    }

    Column ciudadInputText =
        (Column) uiViewRoot.findComponent("AsientoCreateForm:dtAsientos:haberfooter");
    ciudadInputText.setFooterText("$" + totalHaber + "");
  }
Exemplo n.º 7
0
 // 编写处理Action事件的方法
 public void processAction(ActionEvent event) {
   // 获取当前的FacesContext对象
   FacesContext context = FacesContext.getCurrentInstance();
   // 获取JSF页面中<f:view.../>元素
   UIViewRoot viewRoot = context.getViewRoot();
   // 通过ID获取<f:view.../>内的<h:form.../>子元素。
   UIComponent comp = viewRoot.findComponent("addForm");
   // 通过ID获取<h:form.../>内的第一个<h:inputText.../>子元素。
   UIInput input = (UIInput) comp.findComponent("name");
   // 通过ID获取<h:form.../>内的第二个<h:inputText.../>子元素。
   HtmlInputText price = (HtmlInputText) comp.findComponent("price");
   if (input.getValue().equals("疯狂Java讲义")) {
     price.setSize(60);
     price.setValue("99.0元");
     price.setStyle("background-color:#9999ff;" + "font-weight:bold");
   }
 }
  /**
   * Get module id to print
   *
   * @return module id to print
   */
  public Integer getPrintModuleId() {
    FacesContext ctx = FacesContext.getCurrentInstance();
    ResourceLoader bundle = new ResourceLoader("org.etudes.tool.melete.bundle.Messages");

    try {
      resetSelectedLists();
      UIViewRoot root = ctx.getViewRoot();
      UIData table = (UIData) root.findComponent("listauthmodulesform").findComponent("table");
      ModuleDateBean mdbean = (ModuleDateBean) table.getRowData();
      printModuleId = mdbean.getModule().getModuleId();
      return printModuleId;
    } catch (Exception me) {
      logger.error(me.toString());
      String msg = bundle.getString("print_module_fail");
      addMessage(ctx, "Error Message", msg, FacesMessage.SEVERITY_ERROR);
    }
    return 0;
  }
 /**
  * Method to expand or collapse individual modules' sections
  *
  * @return list_auth_modules
  */
 public String showHideSections() {
   resetSelectedLists();
   if (getExpandAllFlag() == true) {
     setShowModuleId(-1);
     setExpandAllFlag(false);
   } else {
     FacesContext ctx = FacesContext.getCurrentInstance();
     UIViewRoot root = ctx.getViewRoot();
     UIData table = (UIData) root.findComponent("listauthmodulesform").findComponent("table");
     ModuleDateBean mdbean = (ModuleDateBean) table.getRowData();
     if (getShowModuleId() != mdbean.getModuleId()) {
       setShowModuleId(mdbean.getModuleId());
     } else {
       setShowModuleId(-1);
       setExpandAllFlag(false);
     }
   }
   saveModuleDates();
   return "list_auth_modules";
 }
  /**
   * Make a copy of the selected module
   *
   * @return list_auth_modules
   */
  public String duplicateAction() {
    FacesContext ctx = FacesContext.getCurrentInstance();
    ResourceLoader bundle = new ResourceLoader("org.etudes.tool.melete.bundle.Messages");
    if (!saveModuleDates()) return "list_auth_modules";

    try {
      resetSelectedLists();
      UIViewRoot root = ctx.getViewRoot();
      UIData table = (UIData) root.findComponent("listauthmodulesform").findComponent("table");
      ModuleDateBean mdbean = (ModuleDateBean) table.getRowData();
      logger.debug("calling copy for " + mdbean.getModule().getTitle());
      moduleService.copyModule((ModuleObjService) mdbean.getModule(), courseId, userId);
    } catch (MeleteException me) {
      logger.debug(me.toString());
      String msg = bundle.getString("copy_fail");
      addMessage(ctx, "Error Message", msg, FacesMessage.SEVERITY_ERROR);
    }
    resetValues();
    return "list_auth_modules";
  }