Package org.apache.struts.action

Examples of org.apache.struts.action.DynaActionForm

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

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

      // get the file ID from the form bean
      Integer formFileID = (Integer)fileForm.get("fileID");
      // create an int to hold the file ID value
      int fileID = 0;

      // now, check the file ID on the form...
      if (formFileID == null)
        // if file 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"));
        // if file ID is set on the form properly, then set
        // the int representation for use in the code below
        fileID = formFileID.intValue();
      CvFileFacade fileFacade = new CvFileFacade();
      CvFileVO fileVO = fileFacade.getFile(individualID, fileID, dataSource);

      fileForm.set("title", fileVO.getTitle());
      fileForm.set("fileName", fileVO.getName());
      fileForm.set("description", fileVO.getDescription());
      if (fileVO.getAuthorVO() != null)
        fileForm.set("author", fileVO.getAuthorVO().getFirstName() + " " + fileVO.getAuthorVO().getLastName());
        fileForm.set("author", "");

      fileForm.set("created", fileVO.getCreatedOn());
      fileForm.set("modified", fileVO.getModifiedOn());
      fileForm.set("version", fileVO.getVersion());

      System.out.println("\n\n\nfileForm = [" + fileForm + "]\n\n\n");

    }catch(Exception e){
      System.out.println("[Exception][CV ViewFileHandler] Exception thrown in execute(): " + e);
View Full Code Here

    ActionErrors allErrors = new ActionErrors();
    String forward = "showRulesList";
    // "deleteRuleForm", defined in struts-config-email.xml
    DynaActionForm ruleForm = (DynaActionForm)form;

    Integer accountID = (Integer)ruleForm.get("accountID");

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

      String ruleIDs = (String)ruleForm.get("ruleIDs");
      String status = (String)ruleForm.get("status");
      String[] rulesList = ruleIDs.split(",");
      for (int i = 0; i<rulesList.length; i++)
View Full Code Here

    try {
      HttpSession session = request.getSession();
      UserObject userObject = (UserObject)session.getAttribute("userobject");
      int individualId = userObject.getIndividualID();
      String dataSource = Settings.getInstance().getSiteInfo(CVUtility.getHostName(super.getServlet().getServletContext())).getDataSource();
      DynaActionForm adhocReportForm = (DynaActionForm)actionForm;

      SelectVO selects = new SelectVO();
      ReportFacade remote = getReportFacade();
      // Get the table list from the reportFacade
      // The table list is an ArrayList of TheTable objects, which contain
      // an ID an table name and the Display name.
      selects = remote.getAdHocPageData(moduleId);

      // createNew is a string attribute that tells this handler if it should clear
      // the form.
      String createNew = (String)adhocReportForm.get("createNew");
      if (createNew.equals("true")) {
      // make sure the right moduleId is on the form.
      adhocReportForm.set("moduleId", new Integer(moduleId));

      AdvancedSearch remoteAdvancedSearch = null;
      try {
        AdvancedSearchHome advancedSearchHome = (AdvancedSearchHome)CVUtility.getHomeObject("com.centraview.advancedsearch.AdvancedSearchHome", "AdvancedSearch");
        remoteAdvancedSearch = advancedSearchHome.create();
      } catch (Exception e) {
        System.out.println("[Exception][SearchForm.execute] Exception Thrown getting EJB connection: " + e);
        throw new ServletException(e);
      // because we can get reposted get the current criteria from the form.
      // As we may be manipulating the searchCriteria, adding rows, and such.
      SearchCriteriaVO[] searchCriteria = (SearchCriteriaVO[])adhocReportForm.get("searchCriteria");

      // Build dem drop downs
      // if necessary.
      HashMap allFields = (HashMap)adhocReportForm.get("allFields");
      ArrayList tableList = (ArrayList)adhocReportForm.get("tableList");
      ArrayList conditionList = (ArrayList)adhocReportForm.get("conditionList");
      if (conditionList == null || conditionList.isEmpty()) {
        // This will get us the possible search conditions.
        HashMap conditionMap = SearchVO.getConditionOptions();
        // Build an ArrayList of LabelValueBeans
        conditionList = AdvancedSearchUtil.buildSelectOptionList(conditionMap);
        // stick it on the form
        adhocReportForm.set("conditionList", conditionList);
      if (tableList == null || tableList.isEmpty()) {
        HashMap tableMap = remoteAdvancedSearch.getSearchTablesForModule(individualId, moduleId);
        // Build an ArrayList of LabelValueBeans
        tableList = AdvancedSearchUtil.buildSelectOptionList(tableMap);
        adhocReportForm.set("tableList", tableList);

        // if we had to add get the tableList we more than likely
        // have to build the allFields map, so its probably worth the zillion
        // cpu cycles we will have to waste.

        // Get all the appropriate field lists and stick them on the formbean
        // The fieldList (ArrayList of LabelValueBean) will be stored in a
        // HashMap with the key being the (Number)tableId
        TreeSet keySet = new TreeSet(tableMap.keySet());
        Iterator keyIterator = keySet.iterator();
        allFields = new HashMap();
        while (keyIterator.hasNext()) {
          Number key = (Number);
          // iterate the tables and get all the field lists
          // stick them in a hashmap of arraylists on the form bean.
          HashMap tableFields = remoteAdvancedSearch.getSearchFieldsForTable(individualId, key.intValue(), moduleId);
          ArrayList tableFieldList = AdvancedSearchUtil.buildSelectOptionList(tableFields);
          allFields.put(key, tableFieldList);
        } // end while(keyIterator.hasNext())
        adhocReportForm.set("allFields", allFields);

      // See if we need to add or remove rows from the search criteria array.
      // and do it.
      String addRow = (String)adhocReportForm.get("addRow");
      if (addRow.equals("true")) {
        searchCriteria = AdvancedSearchUtil.addRow(searchCriteria);
        adhocReportForm.set("addRow", "false");
      String removeRow = (String)adhocReportForm.get("removeRow");
      if (!removeRow.equals("false")) {
        searchCriteria = AdvancedSearchUtil.removeRow(searchCriteria, removeRow);
        adhocReportForm.set("removeRow", "false");
      // now that the criteria is ready stick it on the formbean.
      adhocReportForm.set("searchCriteria", searchCriteria);

      ReportVO reportVO = new ReportVO();
      // This parses the fields from the form bean and builds up an arraylist of
      // ReportContentVOs which represent what is selected.  This is then stuck on the
      // reportVO which is stuck on the request
      reportVO.setSelectedFields(getSelectedFieldsWithNames((String)adhocReportForm.get("contentFields"), (String)adhocReportForm.get("contentOrders"), (String)adhocReportForm.get("contentFieldNames")));
      request.setAttribute("pagedata", reportVO);
      // I think this should probably live on the adhocreportform, rather than worrying
      // about something on the request.  But here it is for now.
      request.setAttribute("reportType", String.valueOf(ReportConstants.ADHOC_REPORT_CODE));
    } catch (Exception e) {
View Full Code Here

      HttpSession session = request.getSession(true);
      UserObject userObject = (UserObject)session.getAttribute("userobject");
      int individualID = userObject.getIndividualID();

      DynaActionForm emailForm = (DynaActionForm)form;

      // figure out composition settings
      UserPrefererences userPref= userObject.getUserPref();
      boolean composeInHTML = false;
      if ((userPref.getContentType()).equals("HTML")) {
        composeInHTML = true;
      emailForm.set("composeInHTML", new Boolean(composeInHTML));

      // Parameter type is to categorized that this compose handler is for particular module
      // and According to selection we will popolate the MailFormbean
      String type = request.getParameter("type");

      // We will collect the to Information from all the Attendees associated to the Event.
      if (type != null && type.equals("EVENT")){
        String eventID = (String) request.getParameter("eventid");
        if(eventID != null && !eventID.equals("")){
          MarketingFacadeHome cfh = (MarketingFacadeHome)CVUtility.getHomeObject("", "MarketingFacade");
          MarketingFacade remote = (MarketingFacade)cfh.create();
          int eventId = Integer.parseInt(eventID);
          String toList = remote.getEventAttendeesForMail(eventId, individualID);
          emailForm.set("to", toList);
          emailForm.set("subject", "EVENT");
        }// end of if(eventID != null && !eventID.equals(""))
      }// end of if (type != null && type.equals("EVENT"))

    catch (Exception e)
View Full Code Here

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

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

    // Populate the Attachments In-Case. If we face any problem while sending email.
    // Populating the ArrayList with the DDNameValue.
    ArrayList attachments = new ArrayList();
    ArrayList attachmentFileIDs = new ArrayList();
    String[] tempAttachmentMap = (String[])emailForm.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));
            attachmentFileIDs.add(new Integer(fileID));

    //Setting the Attachments to form.
    emailForm.set("attachmentList", attachments);

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

      // get the form input and validate

      // create a MailMessageVO
      MailMessageVO messageVO = new MailMessageVO();

      Integer accountID = (Integer)emailForm.get("accountID");
      if (accountID == null || accountID.intValue() <= 0) {
        accountID = new Integer(remote.getDefaultAccountID(individualID));
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.pleaseSelect", "From: (email account)"));

      MailAccountVO accountVO = remote.getMailAccountVO(accountID.intValue());
      if (accountVO == null) {
        accountVO = new MailAccountVO();
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "Could not retreive account information. Please select an account."));

      MailUtils mailUtils = new MailUtils();

      InternetAddress fromAddress = new InternetAddress(accountVO.getEmailAddress(), mailUtils.stripInvalidCharsFromName(accountVO.getIndividualName()));


      String subject = (String)emailForm.get("subject");
      if (subject == null || subject.equals("")) {
        messageVO.setSubject("[No Subject] ");

      String body = (String)emailForm.get("body");
      if (body == null) {
        body = "";

      Boolean composeInHTML = (Boolean)emailForm.get("composeInHTML");
      if (composeInHTML.booleanValue()) {

      ArrayList toList = this.parseAddresses((String)emailForm.get("to"));
      if (toList.size() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "To:"));

      ArrayList ccList = this.parseAddresses((String)emailForm.get("cc"));

      ArrayList bccList = this.parseAddresses((String)emailForm.get("bcc"));

      // TODO: figure out what headers to set when sending mail

      messageVO.setReceivedDate(new java.util.Date());

      // Handle attachments - the attachment handler puts a ArrayList
      // This ArrayList contains the list of attached fileIDs.
      // So we'll get that ArrayList, iterate through it, creating a
      // CvFileVO object for each attachment, then add that file VO
      // to the messageVO object which will take care of the rest in
      // the EJB layer. Note that in the future, we'll want to make
      // this better by not saving the attachment list on the session.
      // So if you intend to modify this code, please consult the rest
      // of the team to see if it makes sense to make that change now.
      // Also, if you make a change here, you must make sure the
      // attachment handling code in ForwardHandler reflects your changes.
      if (attachmentFileIDs != null && attachmentFileIDs.size() > 0) {
        CvFileFacade fileRemote  = new CvFileFacade();
        for (int i = 0; i < attachmentFileIDs.size(); i++) {
          int fileID = ((Integer) attachmentFileIDs.get(i)).intValue();
          // get the CvFileVO from the EJB layer
          CvFileVO fileVO = fileRemote.getFile(individualID, fileID, dataSource);
          if (fileVO != null) {
            // add this attachment to the messageVO
        }   // end while (attachIter.hasNext())
      }   // end if (attachmentMap != null && attachmentMap.size() > 0)

      if (! allErrors.isEmpty()) {
        // we encountered error above and built a list of messages,
        // so save the errors to be shown to the users, and quit
        saveErrors(request, allErrors);

      try {
        // send the message
        boolean messageSent = remote.sendMessage(accountVO, messageVO);

        if (messageSent) {
          // check to see if we just successfully delivered a saved draft
          // message. If so, then we need to delete the saved draft from
          // the database.
          Integer savedDraftID = (Integer)emailForm.get("savedDraftID");
          if (savedDraftID.intValue() > 0) {
            remote.deleteMessage(savedDraftID.intValue(), individualID);
      }catch(SendFailedException sfe){
View Full Code Here

public class NewContactMethodHandler extends org.apache.struts.action.Action
  public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws RuntimeException, Exception
    DynaActionForm dynaForm = (DynaActionForm)form;
    dynaForm.set("operation", "add");
    return mapping.findForward(".view.contacts.new_contact_method");
View Full Code Here

    ActionErrors allErrors = new ActionErrors();
    //String forward = "showRuleDetails";
    String forward = "showRulesList";

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

    Integer accountID = (Integer)ruleForm.get("accountID");

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

      Integer ruleID = (Integer)ruleForm.get("ruleID");
      if (ruleID == null || ruleID.intValue() <= 0)
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Rule ID"));

      RuleVO oldRuleVO = remote.getRule(ruleID.intValue());
      RuleVO newRuleVO = 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"));

      // 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"));

      // 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);

      // moveMessage - if true, then folderID is required. Default to false.
      // HACK!!!! Because we're using checkboxes on a DynaActionForm that we
      // are sticking onto the session, we needed to do the following hack:
      // I created a hidden HTML input field on the JSP. It is initially set
      // to the value of "moveMessage" from the database. When the user checks
      // or unchecks the checkbox, then the hidden field is either set to true
      // or false (respectively). Therefore, in this handler we only care about
      // the value of the HIDDEN field, and don't even bother to check the value
      // of the "moveMessage" property of the form bean. This same hack is
      // also used for "markMessageRead and" "deleteMessage"
      String moveMessageParam = (String)request.getParameter("moveMessageHidden");
      boolean moveMessage = false;
      if (moveMessageParam != null && moveMessageParam.equals("true"))
        moveMessage = true;

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

      // markMessageRead - Default to false. NOTE THE HACK (explained above)!!!
      String markMessageReadParam = (String)request.getParameter("markMessageReadHidden");
      boolean markMessageRead = false;
      if (markMessageReadParam != null && markMessageReadParam.equals("true"))
        markMessageRead = true;

      // deleteMessage - Default to false. NOTE THE HACK (explained above)!!!
      String deleteMessageParam = (String)request.getParameter("deleteMessageHidden");
      boolean deleteMessage = false;
      if (deleteMessageParam != null && deleteMessageParam.equals("true"))
        deleteMessage = true;

      // At least one of moveMessage OR deleteMessage OR markMessageRead MUST be selected
      if (deleteMessage == false && moveMessage == false && markMessageRead == 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,"));
        Iterator iter = searchCriteria.iterator();
View Full Code Here

    try {
      HttpSession session = request.getSession();
      UserObject userObject = (UserObject) session.getAttribute("userobject");
      int individualID = userObject.getIndividualID();
      DynaActionForm dynaForm = (DynaActionForm)form;
      ThreadVO tVO = new ThreadVO();
      SupportFacadeHome sfh = (SupportFacadeHome)CVUtility.getHomeObject("", "SupportFacade");
      SupportFacade remote = (SupportFacade) sfh.create();
      remote.addThread(individualID, tVO);
      String closeornew = (String) request.getParameter("closeornew");
      String saveandclose = null;
      String saveandnew = null;
      if (closeornew.equals("close")) {
        saveandclose = "saveandclose";
      }else if (closeornew.equals("new")){
        saveandnew = "saveandnew";
        dynaForm.set("title", "");
        dynaForm.set("threaddetail", "");
        return mapping.findForward("");
      if (saveandclose != null) {
        request.setAttribute("closeWindow", "true");
View Full Code Here

    ActionErrors allErrors = new ActionErrors();
    String forward = "emailList";

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

      // check for a valid email account
      MailHome home = (MailHome)CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
      Mail mailRemote = (Mail)home.create();

      int numberAccounts = mailRemote.getNumberOfAccountsForUser(individualID);

      if (numberAccounts < 1)
        // if the user has less than 1 mail account
        // set up, then show them the door

      int currentAccountID = 0;
      MailFolderVO folderVO = new MailFolderVO();
      Integer folderID = (Integer)emailListForm.get("folderID");
      if (folderID == null || folderID.intValue() <= 0 )
        // if "folderID" is not specified, then get the user's
        // default folder, which should be Inbox for their
        // default account
        // get the user's default account (we already know they have at least one)
        int defaultAccountID = mailRemote.getDefaultAccountID(individualID);
        folderVO = mailRemote.getPrimaryEmailFolder(defaultAccountID);
        folderVO = mailRemote.getEmailFolder(folderID.intValue());
      folderID = new Integer(folderVO.getFolderID());
      String folderName = folderVO.getFolderName();
      currentAccountID = folderVO.getEmailAccountID();

      HashMap folderList = mailRemote.getFolderList(currentAccountID);

      // now, set the folderID back to the form bean, so we
      // can access it in the JSPs via Struts beans
      emailListForm.set("folderID", folderID);

      MailAccountVO accountVO = mailRemote.getMailAccountVO(currentAccountID);
      emailListForm.set("accountID", new Integer(currentAccountID));
      emailListForm.set("accountType", (String)accountVO.getAccountType());

      emailListForm.set("folderList", folderList);
      emailListForm.set("folderType", folderVO.getFolderType());

      // now, we need to set some stuff up for the folder bar which
      // shows where the user is located within the folder hierarchy
      ArrayList folderPathList = mailRemote.getFolderFullPath(folderID.intValue());
      emailListForm.set("folderPathList", folderPathList);

      ListPreference listPrefs = userObject.getListPreference("Email");

      // TODO: make sure searchString is taken care of
      String searchString = request.getParameter("searchTextBox");
View Full Code Here

      HttpSession session = request.getSession();
      UserObject userObject = (UserObject) session.getAttribute("userobject");
      int individualID = userObject.getIndividualID();
      DynaActionForm faqForm = (DynaActionForm) form;
      String[] qids = request.getParameterValues("rowId");
      SupportFacadeHome sfh = (SupportFacadeHome) CVUtility.getHomeObject("",
      SupportFacade remote = (SupportFacade) sfh.create();
View Full Code Here


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