public Object getAsObject(
      FacesContext facesContext, UIComponent component, String submittedValue) {
    if (submittedValue.trim().equals("")) {
      return null;
    } else {
      try {
        int number = Integer.parseInt(submittedValue);
        TableBeanItem tabBean = TableBeanItem.findBean("tableBeanItem");
        ArrayList<Office> listOffice = (ArrayList<Office>) tabBean.getAvaliableOffice();

        for (Office o : listOffice) {
          if (o.getId() == number) {
            return o;
          }
        }

      } catch (NumberFormatException exception) {
        throw new ConverterException(
            new FacesMessage(
                FacesMessage.SEVERITY_ERROR, "Conversion Error", "Not a valid Office"));
      }
    }

    return null;
  }
  public void filterItemByMap() throws DataAccessException {

    TableBeanItem tabBeanItem_pc = findBean("tableBeanItem");
    List<Item> m = new ArrayList<Item>();
    tabBeanItem_pc.setTableList(m);

    TableBeanItem tabBeanItem = findBean("tableBeanItem");
    ArrayList<Object> arrayParams = new ArrayList<Object>();
    arrayParams.add(selectedOffice);
    arrayParams.add(selectedMap);
    tabBeanItem.populateTable(arrayParams);
  }
  public String filterInventory() throws DataAccessException {

    TableBeanItem tabBeanItem = findBean("tableBeanItem");
    ArrayList<Object> arrayParams = new ArrayList<Object>();
    tabBeanItem.populateTable(arrayParams);
    tabBeanItem.setSelectedOffice(0);
    tabBeanItem.setSelectedMap(0);

    String redirect =
        ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest())
            .getRequestURI();

    log.info(redirect);
    if (redirect.contains("/Inventory/pages/report/inventory.xhtml")) return "";
    else return "inventory";
  }