Package org.apache.struts.action

Examples of org.apache.struts.action.DynaActionForm


    try
    {
      HttpSession session = request.getSession();
      UserObject userObject = (UserObject) session.getAttribute("userobject");
      int individualID = userObject.getIndividualID();
      DynaActionForm qForm = (DynaActionForm) form;
      QuestionVO QVO = null;

      if (request.getParameter(Constants.TYPEOFOPERATION).equals(SupportConstantKeys.EDIT)) {
        SupportFacadeHome sfh = (SupportFacadeHome) CVUtility.getHomeObject("com.centraview.support.supportfacade.SupportFacadeHome",
            "SupportFacade");
        SupportFacade remote = (SupportFacade) sfh.create();
        remote.setDataSource(dataSource);
        QVO = remote.getQuestion(individualID, Integer.parseInt(request.getParameter("rowId")));
        qForm.set("title", QVO.getQuestion());
        qForm.set("answer", QVO.getAnswer());
        qForm.set("faqid", new Integer(QVO.getFaqId()).toString());
        FORWARD_final = FORWARD_editfaq;
      } else {
        qForm.set("faqid", request.getParameter("faqid"));
        FORWARD_final = FORWARD_newfaq;
      }
    }
    catch (Exception e) {
      System.out.println("[Exception] DisplayQuestionHandler.execute: " + e.toString());
View Full Code Here


   */
  public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
  {
    HttpSession session = request.getSession(true);
    String nextURL = "showadhocreportresult";
    DynaActionForm adHocReportForm = (DynaActionForm)actionForm;

    UserObject userobject = (UserObject)session.getAttribute("userobject");
    int userId = userobject.getIndividualID();
    int reportId = 0;
    int moduleId = getModuleId(request);
View Full Code Here

  public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
  {
    try {
      final String dataSource = Settings.getInstance().getSiteInfo(CVUtility.getHostName(super.getServlet().getServletContext())).getDataSource();
      // Collect the Template information from the Form
      DynaActionForm dynaform = (DynaActionForm) form;
      String ptData = (String) dynaform.get("templateData");
      String subject = (String) dynaform.get("templatesubject");
      String templatefrom = (String) dynaform.get("templatefrom");
      String templatereplyto = (String) dynaform.get("templatereplyto");
      String mergeType = (String) dynaform.get("mergetype");
      // list of Individual's ID
      HashMap individualIds = (HashMap) dynaform.get("toIndividuals");
      ArrayList templateList = new ArrayList();
      ArrayList emailList = new ArrayList();
      Vector fieldList = new Vector();
      fieldList.add("IndividualID");
      fieldList.add("EntityID");
      fieldList.add("Company");
      fieldList.add("FirstName");
      fieldList.add("MiddleInitial");
      fieldList.add("LastName");
      fieldList.add("Title");
      fieldList.add("PrimaryAddress");
      fieldList.add("Street1");
      fieldList.add("Street2");
      fieldList.add("City");
      fieldList.add("State");
      fieldList.add("Zip");
      fieldList.add("Country");
      fieldList.add("Website");
      fieldList.add("ExternalID");
      fieldList.add("Source");
      fieldList.add("Fax");
      fieldList.add("Home");
      fieldList.add("Main");
      fieldList.add("Mobile");
      fieldList.add("Other");
      fieldList.add("Pager");
      fieldList.add("Work");
      fieldList.add("Email");

      if (mergeType.equals("EMAIL")) {
        // Populating the ArrayList with the DDNameValue.
        ArrayList attachments = new ArrayList();
        String[] tempAttachmentMap = (String[]) dynaform.get("attachments");
        if (tempAttachmentMap != null && tempAttachmentMap.length > 0) {
          for (int i = 0; i < tempAttachmentMap.length; i++) {
            String fileKeyName = tempAttachmentMap[i];
            if (fileKeyName != null) {
              int indexOfHash = fileKeyName.indexOf("#");
              if (indexOfHash != -1) {
                int lenString = fileKeyName.length();
                String fileID = fileKeyName.substring(0, indexOfHash);
                String fileName = fileKeyName.substring(indexOfHash + 1, lenString);
                attachments.add(new DDNameValue(fileID + "#" + fileName, fileName));
              }
            }
          }// end of for(int i = 0; i < tempAttachmentMap.length; i++)
        }// end of if (tempAttachmentMap != null && tempAttachmentMap.size() >
          // 0)
        dynaform.set("attachmentList", attachments);
      }
      if (individualIds != null && individualIds.size() != 0) {
        Set key = individualIds.keySet();
        Iterator iterator = key.iterator();
        while (iterator.hasNext()) {
          String keyValue = (String) iterator.next();
          String tempData = ptData;
          int individualId = 0;
          try {
            individualId = Integer.parseInt(keyValue);
          } catch (NumberFormatException e) {
            logger.error("[execute] There was no valid individual Id.", e);
          }
          if (individualId != 0) {
            // calling the IndividualValues with passing the individual it will
            // populate the bean file PrintTemplateField and return the
            // information.
            PrintTemplateField printTemplate = IndividualValues(individualId, dataSource);
            // Before doing any text manipulation, lets check if we are type
            // email, and this
            // Individual has no email address then we can just bail on this
            // individual now.
            if (mergeType.equals("EMAIL") && printTemplate.getEmail().equals("")) {
              // punt on this one and try the next one.
              continue;
            }
            // call the method from PrintTemplateField and replace all the
            // occurance of fieldList from Template Body.
            Class printTemplateClass = printTemplate.getClass();
            for (int j = 0; j < fieldList.size(); j++) {
              String methodName = fieldList.elementAt(j).toString();
              String getmethod = "get" + methodName;
              Method method = printTemplateClass.getMethod(getmethod, null);
              Object methodValue = method.invoke(printTemplate, null);
              String valueString = "";
              if (valueString != null) {
                valueString = (String) methodValue;
              }
              if (valueString != null && valueString.equals("null")) {
                valueString = "";
              }
              String findString = "&lt;" + methodName + "/&gt;";
              tempData = tempData.replaceAll(findString, valueString);
              tempData = tempData.replaceAll("<" + methodName + "/>", valueString);
              tempData = tempData.replaceAll("&lt;" + methodName + "/&gt;", valueString);
            }// end of for (int j = 0; j < fieldList.size(); j++)
            // get the Email Information for the Individual and Store it into
            // emailList if necessary.
            String name = "";
            String address = "";
            try {
              if (mergeType.equals("EMAIL")) {
                address = printTemplate.getEmail();
                name = printTemplate.getFirstName() + " " + printTemplate.getLastName();
                InternetAddress internetAddress = new InternetAddress(address, name);
                emailList.add(internetAddress.toString());
              }
              // templateList is sample template with update information of the
              // Individual.
              templateList.add(tempData);
            } catch (UnsupportedEncodingException e) {
              // If the creation of an InternetAddress fails then skip adding
              // this record in.
              logger.error("[execute] invalid email address, skipping: " + name + ", " + address, e);
            }
          }// end of if (individualId != 0)
        } // end of while (iterator.hasNext())
      } // end of if (individualIds != null && individualIds.size() != 0)
      dynaform.set("toPrint", templateList);
      dynaform.set("emailList", emailList);
      dynaform.set("templatesubject", subject);
      dynaform.set("templatefrom", templatefrom);
      dynaform.set("templatereplyto", templatereplyto);
      FORWARD_final = FORWARD_ptpreview;
    } catch (Exception e) {
      logger.error("[execute] Exception thrown.", e);
      FORWARD_final = GLOBAL_FORWARD_failure;
    }
View Full Code Here

    ActionErrors allErrors = new ActionErrors();
    String forward = "mailList";
    String errorForward = "errorOccurred";

    // "markReadForm", defined in struts-config-email.xml
    DynaActionForm emailForm = (DynaActionForm)form;
    Integer folderID = (Integer)emailForm.get("folderID");

    MailHome home = (MailHome)CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
    try
    {
      Mail remote = (Mail)home.create();
      remote.setDataSource(dataSource);

      String rowId[] = request.getParameterValues("rowId");
      String status = (String)emailForm.get("status");

      if (status != null && status.equals("read"))
      {
        for (int i = 0; i<rowId.length; i++)
        {
View Full Code Here

      UserObject userobject = (UserObject)session.getAttribute("userobject");
      String timeZone = userobject.getUserPref().getTimeZone();
      int userId = userobject.getIndividualID();
      int reportId = getTheId("reportId", request);
      int moduleId = getModuleId(request);
      DynaActionForm reportForm = (DynaActionForm)actionForm;
      String createNew = (String)reportForm.get("createNew");
      if (createNew.equals("true"))
      {
        reportForm.initialize(actionMapping);
        reportForm.set("moduleId", new Integer(moduleId));
      }
      ReportVO reportVO = null;
      ReportFacade remote = getReportFacade();
      String action = request.getParameter("action");
      String showFields = (String)((DynaActionForm)actionForm).get("showFields");
      if (action == null) // means we are probably coming here from the list view.
                          // or have resubmitted to manipulate search criteria.
      {
        reportVO = remote.getStandardReport(userId, reportId);
        moduleId = reportVO.getModuleId();
        // See if we should add a row.
        SearchCriteriaVO[] searchCriteria = (SearchCriteriaVO[])reportForm.get("searchCriteria");
        String addRow = (String)reportForm.get("addRow");
        String removeRow = (String)reportForm.get("removeRow");
        if (addRow.equals("true"))
        {
          searchCriteria = AdvancedSearchUtil.addRow(searchCriteria);
          reportForm.set("addRow", "false");
          reportForm.set("searchCriteria", searchCriteria);
        } else if (!removeRow.equals("false")) {
          searchCriteria = AdvancedSearchUtil.removeRow(searchCriteria, removeRow);
          reportForm.set("removeRow", "false");
          reportForm.set("searchCriteria", searchCriteria);
        } else if (!showFields.equals("true")) {
          // showfield probably means we have changed some fields on the form, and we need to parse
          // the form and update the VO that we got from the database to reflect those changes.
          reportForm = (DynaActionForm)getStandardReportFormFromReportVO(reportVO, actionForm, request);
        }
        moduleId = reportVO.getModuleId();
        request.setAttribute("pagedata", reportVO);
      } else if (action.equals("save")) {
        reportVO = getStandardReportVOFromForm(timeZone, actionForm);
        remote.updateStandardReport(userId, reportVO, false);
        // save is save and close (although there is nothing we can update)
        nextURL = "showstandardreportlist";
      } else if (action.equals("run") || action.equals("export") || action.equals("print")) {
        if (action.equals("run"))
        {
          reportVO = getStandardReportVOFromForm(timeZone, actionForm);
          remote.updateStandardReport(userId, reportVO, false);
          reportForm.set("createNew", "true");
          nextURL = "showstandardreportresult";
        } else if (action.equals("export")) {
          reportForm.set("createNew", "true");
          nextURL = "csvstandardreportresult";
        } else if (action.equals("print")) {
          reportForm.set("createNew", "true");
          nextURL = "printstandardreportresult";
        }
        // Extract the SearchVO from the form
        SearchVO search = this.getSearchVOFromForm(actionForm, request);
        if (action.equals("run")){
View Full Code Here

      ticketRemote.setDataSource(dataSource);

      //TODO: We need to remove this hard-coded value
      ThreadVO tVO = ticketRemote.getThread(individualID, 1);

      DynaActionForm dynaForm = (DynaActionForm) form;
      dynaForm.set("title", tVO.getTitle());
      dynaForm.set("detail", tVO.getDetail());

      //dynaForm.set("ticketnumber",new Integer(tVO.getId()).toString());
      request.setAttribute("threadform", dynaForm);
      TicketForm ticketForm = new TicketForm();
View Full Code Here

    int entityID = userObject.getEntityId();    // entityID of the logged-in user's entity
   
    ActionErrors allErrors = new ActionErrors();

    // "customerKbForm", defined in cv-struts-config.xml
    DynaActionForm kbForm = (DynaActionForm)form;

    try
    {
      // get the kb ID from the form bean
      Integer formKbID = (Integer)kbForm.get("kbID");
      // create an int to hold the kb ID value
      int kbID = 0;

      // now, check the kb ID on the form...
      if (formKbID == null)
      {
        // if kb ID is not set on the form, then there is
        // no point in continuing forward. Show the user an
        // error and quit.
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Knowledgebase ID"));
        return(mapping.findForward(forward));
      }else{
        // if kb ID is set on the form properly, then set
        // the int representation for use in the code below
        kbID = formKbID.intValue();
      }
     
      SupportFacadeHome supportFacade = (SupportFacadeHome)CVUtility.getHomeObject("com.centraview.support.supportfacade.SupportFacadeHome", "SupportFacade");
      SupportFacade remote = (SupportFacade)supportFacade.create();
      remote.setDataSource(dataSource);

      KnowledgeVO kbVO = remote.getKB(individualID, kbID);
     
      kbForm.set("title", kbVO.getTitle());
      kbForm.set("detail", kbVO.getDetail());

System.out.println("\n\n\nkbForm = [" + kbForm + "]\n\n\n");     


    }catch(Exception e){
View Full Code Here

    ActionErrors allErrors = new ActionErrors();
    String forward = "showRulesList";
    String errorForward = "errorOccurred";

    // "ruleForm", defined in struts-config-email.xml
    DynaActionForm ruleForm = (DynaActionForm)form;

    Integer accountID = new Integer(0);

    try {
      MailHome home = (MailHome)CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
      Mail remote = (Mail)home.create();
      remote.setDataSource(dataSource);

      RuleVO ruleVO = new RuleVO();

      // name - required field
      String ruleName = (String)ruleForm.get("name");
      if (ruleName == null || ruleName.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Name"));
      }else{
        ruleVO.setRuleName(ruleName);
      }

      // description - required field
      String description = (String)ruleForm.get("description");
      if (description == null || description.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Description"));
      }else{
        ruleVO.setDescription(description);
      }

      // enabled - required field, but default to true if it's not given (shouldn't ever happen)
      Boolean enabled = (Boolean)ruleForm.get("enabled");
      if (enabled == null) {
        enabled = new Boolean(true);
      }else{
        ruleVO.setEnabled(enabled.booleanValue());
      }

      // accountID - required field. But user can't fix the error if it's not supplied :-(
      accountID = (Integer)ruleForm.get("accountID");
      if (accountID == null || accountID.intValue() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Account ID"));
      }else{
        ruleVO.setAccountID(accountID.intValue());
      }

      // moveMessage - if true, then folderID is required. Default to false.
      Boolean moveMessage = (Boolean)ruleForm.get("moveMessage");
      if (moveMessage == null) {
        moveMessage = new Boolean(false);
      }else{
        ruleVO.setMoveMessage(moveMessage.booleanValue());
      }

      // folderID = required only if moveMessage == true
      Integer folderID = (Integer)ruleForm.get("folderID");
      if (moveMessage.booleanValue() == true) {
        if (folderID == null || folderID.intValue() <= 0) {
          allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "You must choose a destination when moving a message."));
        }else{
          ruleVO.setFolderID(folderID.intValue());
        }
      }

      // markMessageRead - Default to false.
      Boolean markMessageRead = (Boolean)ruleForm.get("markMessageRead");
      if (markMessageRead == null) {
        markMessageRead = new Boolean(false);
      }else{
        ruleVO.setMarkMessageRead(markMessageRead.booleanValue());
      }

      // deleteMessage - Default to false.
      Boolean deleteMessage = (Boolean)ruleForm.get("deleteMessage");
      if (deleteMessage == null) {
        deleteMessage = new Boolean(false);
      }else{
        ruleVO.setDeleteMessage(deleteMessage.booleanValue());
      }

      // At least one of moveMessage OR deleteMessage OR markMessageRead MUST be selected
      if (deleteMessage.booleanValue() == false && moveMessage.booleanValue() == false && markMessageRead.booleanValue() == false) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "You must select at least one Action."));
      }

      // search criteria - get the List of SearchCriteriaVO's from the form
      // and check to see if there is at least ONE valid criteria. If not,
      // throw an error.
      List searchCriteria = Arrays.asList((SearchCriteriaVO[])ruleForm.get("searchCriteria"));
      if (searchCriteria == null || searchCriteria.isEmpty()) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "You must supply at least one Criteria,"));
      }else{
        Iterator iter = searchCriteria.iterator();
        int count = 1;
View Full Code Here

   
    ActionErrors allErrors = new ActionErrors();
    String forward = "mailList";
    String errorForward = "errorOccurred";
   
    DynaActionForm emailForm = (DynaActionForm)form;
    Integer folderID = (Integer)emailForm.get("folderID");
   
    MailHome home = (MailHome)CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
    try
    {
     
      Mail remote = (Mail)home.create();
      remote.setDataSource(dataSource);
     
      String rowId[] = request.getParameterValues("rowId");
      Integer newFolderID = (Integer)emailForm.get("newFolderID");
     
      for (int i = 0; i < rowId.length; i++) {
        if (rowId[i] != null && !rowId[i].equals("")) {
          Integer messageID = Integer.valueOf(rowId[i]);
          remote.moveMessageToFolder(individualID, messageID.intValue(), newFolderID.intValue());
View Full Code Here

    int entityID = userObject.getEntityId();    // logged in user

    ActionErrors allErrors = new ActionErrors();

    // "customerProfileForm", defined in cv-struts-config.xml
    DynaActionForm profileForm = (DynaActionForm)form;

    // get the customer profile from the database
    ContactFacadeHome cfh = (ContactFacadeHome)CVUtility.getHomeObject("com.centraview.contact.contactfacade.ContactFacadeHome","ContactFacade");
   
    try {
      ContactFacade remote = (ContactFacade)cfh.create();
      remote.setDataSource(dataSource);
     
      // get the Entity record of the logged-in user's Entity
      EntityVO entityVO = (EntityVO)remote.getEntity(entityID);
     
      if (entityVO == null) {
        // let the user know something bad happened
        allErrors.add("error.general.databaseError", new ActionMessage("error.general.databaseError"));
        entityVO = new EntityVO();
      }
     
      IndividualVO primaryContactVO = entityVO.getIndividualVO();
      if (primaryContactVO == null) {
        // avoid null pointers
        primaryContactVO = new IndividualVO();
      }
     
      AddressVO primaryAddress = entityVO.getPrimaryAddress();
      if (primaryAddress == null) {
        // avoid null pointers
        primaryAddress = new AddressVO();
      }
     
      // now, populate the form bean with the data
      profileForm.set("entityName", entityVO.getName());
      profileForm.set("firstName", primaryContactVO.getFirstName());
      profileForm.set("middleName", primaryContactVO.getMiddleName());
      profileForm.set("lastName", primaryContactVO.getLastName());
      profileForm.set("title", primaryContactVO.getTitle());
      profileForm.set("street1", primaryAddress.getStreet1());
      profileForm.set("street2", primaryAddress.getStreet2());
      profileForm.set("city", primaryAddress.getCity());
      profileForm.set("zipCode", primaryAddress.getZip());
      profileForm.set("website", primaryAddress.getWebsite());
     
      GlobalMasterLists gml = GlobalMasterLists.getGlobalMasterLists(dataSource);
      Vector stateList = (Vector)gml.get("States");
      profileForm.set("state", primaryAddress.getStateName());
      Vector countryList = (Vector)gml.get("Country");
      profileForm.set("country", primaryAddress.getCountryName());
     
      Collection mocList = entityVO.getMOC();
      Iterator iterator = mocList.iterator();
      int count = 1;
      while (iterator.hasNext()) {
        MethodOfContactVO moc = (MethodOfContactVO)iterator.next();
        if (moc.getMocType() == 1 && moc.getIsPrimary().equalsIgnoreCase("YES")) {
          // this is for email
          profileForm.set("email", moc.getContent());
        } else if (count < 4 && moc.getMocType() != 1) {
          profileForm.set("mocType" + count, new Integer(moc.getMocType()).toString());
          String mocContent = moc.getContent();
          String mocContentValue = "";
          String mocContentExt = "";
          if (mocContent.indexOf("EXT") != -1) {
            String tempContent = mocContent;
            mocContentValue = tempContent.substring(0,tempContent.indexOf("EXT"));
            mocContentExt = tempContent.substring(tempContent.indexOf("EXT")+3,tempContent.length())  ;
          }else{
            mocContentValue = mocContent;
          }
          profileForm.set("mocContent" + count, mocContentValue );
          profileForm.set("mocExt" + count, mocContentExt );
          count++;
        }
      }
     
      if (! allErrors.isEmpty()) {
View Full Code Here

TOP

Related Classes of org.apache.struts.action.DynaActionForm

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.