Package org.apache.struts.validator

Examples of org.apache.struts.validator.DynaValidatorForm


    HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException, CommunicationException,NamingException
  {
    String dataSource = Settings.getInstance().getSiteInfo(CVUtility.getHostName(super.getServlet().getServletContext())).getDataSource();

    DynaValidatorForm dynaForm = (DynaValidatorForm) form;
    String saveandclose = (String) request.getParameter("saveandclose");
    String saveandnew = (String) request.getParameter("saveandnew");
    String save = (String) request.getParameter("save");

    if (save != null)
    {
      saveandnew = "";
    }

    String addItem = (String) dynaForm.get("additem");
    String returnStatus = "failure";
    HttpSession session = request.getSession(true);
    userobject = (UserObject) session.getAttribute("userobject");
    currentTZ = userobject.getUserPref().getTimeZone();

    int indvID = 0;

    if (userobject != null)
    {
      indvID = userobject.getIndividualID();
    }

    if ((saveandclose != null))
    {
      if (saveForm(indvID, dynaForm, request, response))
      {
        returnStatus = "success";
      }

      request.setAttribute("closeWindow", "true");
      request.setAttribute("refreshWindow", "true");
    }
    else if ((saveandnew != null))
    {
      if (saveForm(indvID, dynaForm, request, response))
      {
        returnStatus = "successNew";
      }

      //clearForm(dynaForm , mapping);
      //Clears the DynaActionForm
      if (save == null)
      {
        dynaForm.reset(mapping, request);
      }

      request.setAttribute("refreshWindow", "true");
    }
    else if (addItem != null)
View Full Code Here


      remote.setDataSource(dataSource);
      TimeSheetVO timeSheetVO = null;
      if (timeSheetId != 0)
        timeSheetVO = remote.getTimeSheet(timeSheetId);

      DynaValidatorForm dynaForm = (DynaValidatorForm)form;
      dynaForm.reset(mapping, request);
      if (timeSheetVO.getReportingTo() != null)
      {
        dynaForm.set("reportingTo", timeSheetVO.getReportingTo());
      }
      if (timeSheetVO.getReportingToId() > 0)
      {
        int reportingToId = timeSheetVO.getReportingToId();
        Integer iReportingToId = new Integer(reportingToId);
        String sReportingToId = iReportingToId.toString();
        dynaForm.set("reportingToId", sReportingToId);
      }
      if (timeSheetVO.getOwnerName() != null)
      {
        dynaForm.set("employee", timeSheetVO.getOwnerName());
      }
      if (timeSheetVO.getOwner() > 0)
      {
        int employeeId = timeSheetVO.getOwner();
        Integer iemployeeId = new Integer(employeeId);
        String semployeeId = iemployeeId.toString();
        dynaForm.set("employeeId", semployeeId);
      }
      if (timeSheetVO.getDescription() != null)
      {
        dynaForm.set("description", timeSheetVO.getDescription());
      }
      if (timeSheetVO.getStatus() >= 0)
      {
        Long lStatus = new Long(timeSheetVO.getStatus());
        if (lStatus.intValue() == 1)
          request.setAttribute("DISABLED", "TRUE");
        dynaForm.set("status1", lStatus);
      }
      if (timeSheetVO.getNotes() != null)
      {
        dynaForm.set("notes", timeSheetVO.getNotes());
      }
      if (timeSheetVO.getCreatedDate() != null)
      {
        java.sql.Timestamp createdDate = timeSheetVO.getCreatedDate();
        String sCreatedDate = createdDate.toString();
        //dynaForm.set("createdDate",sCreatedDate);
      }
      if (timeSheetVO.getModifiedDate() != null)
      {
        //java.sql.Date modifiedDate = timeSheetVO.getModifiedDate();
        java.sql.Timestamp modifiedDate = timeSheetVO.getModifiedDate();
        String sModifiedDate = modifiedDate.toString();
        //dynaForm.set("modifiedDate",sModifiedDate);
      }
      if (timeSheetVO.getFromDate() != null)
      {
        java.sql.Date fromDate = timeSheetVO.getFromDate();
        String sfromDate = fromDate.toString();
        Vector fromDateSplitUp = getDate(sfromDate);
        dynaForm.set("fromyear", (String)fromDateSplitUp.get(0));
        dynaForm.set("frommonth", (String)fromDateSplitUp.get(1));
        dynaForm.set("fromday", (String)fromDateSplitUp.get(2));
      }
      if (timeSheetVO.getToDate() != null)
      {
        java.sql.Date toDate = timeSheetVO.getToDate();
        String stoDate = toDate.toString();
        //String[] sTokenizedDate = getDate(stoDate);
        Vector toDateSplitUp = getDate(stoDate);
        dynaForm.set("toyear", (String)toDateSplitUp.get(0));
        dynaForm.set("tomonth", (String)toDateSplitUp.get(1));
        dynaForm.set("today", (String)toDateSplitUp.get(2));
      }
    dynaForm.set("timesheetID",timeSheetId+"");

      DisplayList displaylist = (DisplayList)timeSheetVO.getTimeSlipList();

      //Setting the timesliplist attribute
      session.setAttribute("timesliplist", displaylist);
View Full Code Here

  private static Logger logger = Logger.getLogger(MergeSearchResults.class);

  public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, CommunicationException, NamingException
  {
    String dataSource = Settings.getInstance().getSiteInfo(CVUtility.getHostName(super.getServlet().getServletContext())).getDataSource();
    DynaValidatorForm mergeSearchForm = (DynaValidatorForm)form;
    SearchCriteriaVO searchCriteria = this.populateSearchCriteria(mergeSearchForm);
    // Well lets get the groupings already.
    MergeSearchResultVO searchResult = null;
   
    MergeHome mergeHome = (MergeHome)CVUtility.getHomeObject("com.centraview.administration.merge.MergeHome", "Merge");
View Full Code Here

    // remove the searchresults from the session, and the Details Forms
    session.removeAttribute("mergeSearchResult");
    session.removeAttribute("mergeEntityDetails");
    session.removeAttribute("mergeIndividualDetails");
   
    DynaValidatorForm mergeSearchForm = (DynaValidatorForm)form;
    // clean up always unless "useSessionForm" is set.
    if (request.getParameter("useSessionForm") == null)
    {
      mergeSearchForm.initialize(mapping);
    session.removeAttribute("mergedIndividual");
    session.removeAttribute("mergedEntity");
    session.removeAttribute("mergeIdArray");
    session.removeAttribute("mergeResult");    
    }
   
    String dataSource = Settings.getInstance().getSiteInfo(CVUtility.getHostName(super.getServlet().getServletContext())).getDataSource();

    // Set up the collections for the drop downs, and stick them on the request.
    ArrayList mergeType = new ArrayList();
    mergeType.add(new DDNameValue("1", "Entities"));
    mergeType.add(new DDNameValue("2", "Individuals"));

    // The search domain list conists of a 0 value for all records
    // And listid values for the marketing lists.
    ArrayList searchDomain = new ArrayList();
    searchDomain.add(new DDNameValue("0", "All Records"));

    // get marketing lists from the EJB
    ArrayList marketingLists = null;
  ContactFacadeHome contactFacadeHome = (ContactFacadeHome)CVUtility.getHomeObject("com.centraview.contact.contactfacade.ContactFacadeHome", "ContactFacade");
    try
    {
      ContactFacade remoteContactFacade = contactFacadeHome.create();
      remoteContactFacade.setDataSource(dataSource);
      marketingLists = (ArrayList)remoteContactFacade.getAllMarketingList();
    } catch (Exception e) {
    logger.error("[Exception] MergeSearch.Execute Handler ", e);
        throw new ServletException(e);
    }
    // this should never be null worst case it should be an empty arraylist.
    for(int i = 0; i < marketingLists.size(); i++)
    {
      HashMap currentList = (HashMap)marketingLists.get(i);
      searchDomain.add(new DDNameValue(((Number)currentList.get("listid")).toString(), (String)currentList.get("title")));
    }

    // Get the searchCriteria from the EJB, needs to come from EJB layer for
    // custom fields, otherwise we could just instantiate it.
    SearchCriteriaVO searchCriteria = null;
  MergeHome mergeHome = (MergeHome)CVUtility.getHomeObject("com.centraview.administration.merge.MergeHome", "Merge");
    try
    {
      Merge remoteMerge = mergeHome.create();
      remoteMerge.setDataSource(dataSource);
      searchCriteria = remoteMerge.getSearchCriteriaVO();
    }
    catch (Exception e)
    {
    logger.error("[Exception] MergeSearch.Execute Handler ", e);
        throw new ServletException(e);
    }
   
    // Check the request parameter to see what type of field list we need to show.
    // Default to entities = 1.  (Individuals = 2)
    String mergeTypeParam = request.getParameter("mergeType");
    String selectedMergeType = mergeTypeParam != null ? mergeTypeParam : "1";
    ArrayList rawFieldList = null;
    if (selectedMergeType.equals("1"))
    {
      rawFieldList = searchCriteria.getEntityFieldList();
    } else {
      rawFieldList = searchCriteria.getIndividualFieldList();
    } // end if(selectedMergeType.equals("1"))
    // Set the mergeType on the form-bean
    mergeSearchForm.set("mergeType", selectedMergeType);
    // We are now prepared to DDNameValue-up the fieldList
    ArrayList fieldList = new ArrayList();
    for (int i = 0; i < rawFieldList.size(); i++)
    {
      MergeField field = (MergeField)rawFieldList.get(i);
      fieldList.add(new DDNameValue(Integer.toString(i),field.getDescription()));
    } // end while fieldIterator.hasNext()
   
    ArrayList rawSearchType = SearchCriteriaVO.getSearchType();
    // DDNameValue it UP!
    ArrayList searchType = new ArrayList();
    for (int i = 0; i < rawSearchType.size(); i++)
    {
      searchType.add(new DDNameValue(Integer.toString(i), (String)rawSearchType.get(i)));
    }
   
    // We have to grow the Array of SearchCriteriaLines on the formbean
    // based on the property bean property addRow
    SearchCriteriaLine [] currentLine = (SearchCriteriaLine[])mergeSearchForm.get("criteriaLine");
    // see if addrow was set to true.
    String addrow = (String)mergeSearchForm.get("addRow");
    if (addrow.equals("true")) // the Add Row button was clicked.
    {
      SearchCriteriaLine [] tmpCriteria = new SearchCriteriaLine[currentLine.length + 1];
      for (int i =0; i  < tmpCriteria.length; i++)
      {
        tmpCriteria[i] = new SearchCriteriaLine();
      } // end for(...) populating tmpCriteria Array
      System.arraycopy(currentLine, 0, tmpCriteria, 0, currentLine.length);
      mergeSearchForm.set("criteriaLine",tmpCriteria);
      mergeSearchForm.set("addRow", "false");
    } // end if(addrow.equals("true")

    // We have all the collections we need, now throw them on the request
    // Then the struts JSP tags should be able to handle them.
    mergeSearchForm.set("mergeTypeCollection", mergeType);
    mergeSearchForm.set("searchDomainCollection", searchDomain);
    mergeSearchForm.set("fieldListCollection", fieldList);
    mergeSearchForm.set("searchTypeCollection", searchType);
   
    // the merge_c.jsp includes different body sections based on the following attribute.
    request.setAttribute("body","mergesearch");

    return (mapping.findForward(".view.administration.merge_search"));
View Full Code Here

            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        ActionMessages errors = new ActionMessages();

        DynaValidatorForm dynaForm = (DynaValidatorForm) form;


        Long funcionarioId = (Long) request.getSession().getAttribute(Constants.PA_FUNCIONARIO);
       
      FuncionarioCtrl funcionarioCtrl = new FuncionarioCtrl(getDaoFactory());
     
      Funcionario funcionario = (Funcionario) funcionarioCtrl.get(funcionarioId);   
     

        if (funcionario != null) {
            return mapping.findForward("success");
        }

        String login = dynaForm.getString("login");
        String senha = dynaForm.getString("senha");

        if ((login == null) || (login.trim().length() <= 0)) {
            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
                    "login.error"));
            saveErrors(request, errors);
View Full Code Here

            throws Exception {

        ActionErrors errors = new ActionErrors();
        try {

            DynaValidatorForm dynaForm = (DynaValidatorForm) form;

            String id = dynaForm.getString("id");
            String nome = dynaForm.getString("nome");
            String login = dynaForm.getString("login");
            String senha = dynaForm.getString("senha");

            AdminFuncionario adminFuncionario = new AdminFuncionario(
                    getDaoFactory());

            adminFuncionario.save(id, nome, login, senha);
View Full Code Here

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        DynaValidatorForm dynaForm = (DynaValidatorForm) form;

        String login = dynaForm.getString("login");
        String senhaAntiga = dynaForm.getString("senhaAntiga");
        String senhaNova = dynaForm.getString("senhaNova");
        String senhaNovaConfirmacao = dynaForm
                .getString("senhaNovaConfirmacao");

        ActionMessages errors = new ActionMessages();

        if (senhaNova == null || senhaNova.trim().length() < 6) {
View Full Code Here

    }

    public ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        DynaValidatorForm roomSearchForm = (DynaValidatorForm) form;

        // date
        Calendar searchDate = Calendar.getInstance();
        Integer day = new Integer((String) roomSearchForm.get("day"));
        Integer month = new Integer((String) roomSearchForm.get("month"));
        Integer year = new Integer((String) roomSearchForm.get("year"));
        request.setAttribute("day", day.toString());
        request.setAttribute("month", month.toString());
        request.setAttribute("year", year.toString());
        searchDate.set(Calendar.YEAR, year.intValue());
        searchDate.set(Calendar.MONTH, month.intValue() - 1);
        searchDate.set(Calendar.DAY_OF_MONTH, day.intValue());
        if (searchDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
            ActionError actionError = new ActionError("error.sunday");
            ActionErrors actionErrors = new ActionErrors();
            actionErrors.add("error.sunday", actionError);
            saveErrors(request, actionErrors);
            return prepare(mapping, form, request, response);
        }

        // exam start time
        Calendar searchStartTime = Calendar.getInstance();
        Integer startHour = new Integer((String) roomSearchForm.get("beginningHour"));
        Integer startMinute = new Integer((String) roomSearchForm.get("beginningMinute"));
        request.setAttribute("beginningHour", startHour.toString());
        request.setAttribute("beginningMinute", startMinute.toString());
        searchStartTime.set(Calendar.HOUR_OF_DAY, startHour.intValue());
        searchStartTime.set(Calendar.MINUTE, startMinute.intValue());
        searchStartTime.set(Calendar.SECOND, 0);

        // exam end time
        Calendar searchEndTime = Calendar.getInstance();
        Integer endHour = new Integer((String) roomSearchForm.get("endHour"));
        Integer endMinute = new Integer((String) roomSearchForm.get("endMinute"));
        request.setAttribute("endHour", endHour.toString());
        request.setAttribute("endMinute", endMinute.toString());
        searchEndTime.set(Calendar.HOUR_OF_DAY, endHour.intValue());
        searchEndTime.set(Calendar.MINUTE, endMinute.intValue());
        searchEndTime.set(Calendar.SECOND, 0);

        if (searchStartTime.after(searchEndTime)) {
            ActionError actionError = new ActionError("error.timeSwitched");
            ActionErrors actionErrors = new ActionErrors();
            actionErrors.add("error.timeSwitched", actionError);
            saveErrors(request, actionErrors);
            return prepare(mapping, form, request, response);
        }

        int dayOfWeekInt = searchDate.get(Calendar.DAY_OF_WEEK);
        DiaSemana dayOfWeek = new DiaSemana(dayOfWeekInt);

        List<InfoRoom> availableInfoRoom = null;
        availableInfoRoom =
                SpaceUtils.allocatableSpace(YearMonthDay.fromCalendarFields(searchDate),
                        YearMonthDay.fromCalendarFields(searchDate), HourMinuteSecond.fromCalendarFields(searchStartTime),
                        HourMinuteSecond.fromCalendarFields(searchEndTime), dayOfWeek, null, null, false);
        String sdate = roomSearchForm.get("day") + "/" + roomSearchForm.get("month") + "/" + roomSearchForm.get("year");
        String startTime = roomSearchForm.get("beginningHour") + ":" + roomSearchForm.get("beginningMinute");
        String endTime = roomSearchForm.get("endHour") + ":" + roomSearchForm.get("endMinute");
        request.setAttribute(PresentationConstants.DATE, sdate);
        request.setAttribute(PresentationConstants.START_TIME, startTime);
        request.setAttribute(PresentationConstants.END_TIME, endTime);

        Integer exam = null;
        Integer normal = null;
        List<InfoRoom> newAvailableInfoRoom = new ArrayList<InfoRoom>();
        if (availableInfoRoom != null && !availableInfoRoom.isEmpty()) {
            try {
                exam = new Integer((String) roomSearchForm.get("exam"));
            } catch (NumberFormatException ex) {
                // the user didn't speciefy a exam minimum capacity
            }
            try {
                normal = new Integer((String) roomSearchForm.get("normal"));
            } catch (NumberFormatException ex) {
                // the user didn't speciefy a normal minimum capacity
            }
            if (normal != null || exam != null) {
                Iterator<InfoRoom> iter = availableInfoRoom.iterator();
View Full Code Here

        return mapping.findForward("showRooms");
    }

    public ActionForward sort(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        DynaValidatorForm roomSearchForm = (DynaValidatorForm) form;

        String[] availableRoomsId = (String[]) roomSearchForm.get("availableRoomsId");
        String sortParameter = request.getParameter("sortParameter");
        List<InfoRoom> availableRooms = new ArrayList<InfoRoom>();
        for (String element : availableRoomsId) {
            final Space room = FenixFramework.getDomainObject(element);
            availableRooms.add(InfoRoom.newInfoFromDomain(room));
        }
        if ((sortParameter != null) && (sortParameter.length() != 0)) {
            if (sortParameter.equals("name")) {
                Collections.sort(availableRooms, new BeanComparator("nome"));
            } else if (sortParameter.equals("type")) {
                Collections.sort(availableRooms, new BeanComparator("tipo"));
            } else if (sortParameter.equals("building")) {
                Collections.sort(availableRooms, new BeanComparator("edificio"));
            } else if (sortParameter.equals("floor")) {
                Collections.sort(availableRooms, new BeanComparator("piso"));
            } else if (sortParameter.equals("normal")) {
                Collections.sort(availableRooms, new ReverseComparator(new BeanComparator("capacidadeNormal")));
            } else if (sortParameter.equals("exam")) {
                Collections.sort(availableRooms, new ReverseComparator(new BeanComparator("capacidadeExame")));
            }
        } else {
            Collections.sort(availableRooms, new BeanComparator("nome"));
        }

        String sdate = roomSearchForm.get("day") + "/" + roomSearchForm.get("month") + "/" + roomSearchForm.get("year");
        String startTime = roomSearchForm.get("beginningHour") + ":" + roomSearchForm.get("beginningMinute");
        String endTime = roomSearchForm.get("endHour") + ":" + roomSearchForm.get("endMinute");
        request.setAttribute(PresentationConstants.DATE, sdate);
        request.setAttribute(PresentationConstants.START_TIME, startTime);
        request.setAttribute(PresentationConstants.END_TIME, endTime);
        request.setAttribute(PresentationConstants.AVAILABLE_ROOMS, availableRooms);
        request.setAttribute(PresentationConstants.AVAILABLE_ROOMS_ID, availableRoomsId);
View Full Code Here

    }

    public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        DynaValidatorForm classForm = (DynaValidatorForm) form;
        String className = (String) classForm.get("className");

        InfoCurricularYear infoCurricularYear = (InfoCurricularYear) request.getAttribute(PresentationConstants.CURRICULAR_YEAR);
        InfoExecutionDegree infoExecutionDegree =
                (InfoExecutionDegree) request.getAttribute(PresentationConstants.EXECUTION_DEGREE);
        AcademicInterval academicInterval =
View Full Code Here

TOP

Related Classes of org.apache.struts.validator.DynaValidatorForm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.