Package org.nextime.ion.backoffice.form

Examples of org.nextime.ion.backoffice.form.EditSectionForm


    } finally {
      Mapping.rollback();
    }

    // get the form
    EditSectionForm sform = (EditSectionForm) form;
    ActionErrors errors = sform.myValidate(request);

    // fill data | first time
    if (sform.getName() == null) {
      try {
        Mapping.begin();
        Section section = Section.getInstance(id);
        Mapping.rollback();

        request.setAttribute("section", section);
        sform.setName(
          (section.getMetaData("name") != null)
            ? section.getMetaData("name") + ""
            : "");
        sform.setTemplate(section.getMetaData("template") + "");
        sform.setStatus(section.getMetaData("status") + "");
        sform.setWorkflow(section.getMetaData("workflow")+"");
        request.setAttribute(
          "types",
          SectionTypes.getSectionsBeans(servlet));
        request.setAttribute(
          "type",
          SectionTypes.getSectionBean(
            servlet,
            section.getMetaData("template") + ""));
        request.setAttribute("workflows", Workflow.listTypes());
      } catch (Exception e) {
        Mapping.rollback();
        throw new ServletException(e);
      }

      // Forward to the view page
      return (mapping.findForward("view"));
    }

    // fill data | template has changed
    if (request.getParameter("ok") == null) {
      try {
        Mapping.begin();
        Section section = Section.getInstance(id);
        Mapping.rollback();

        request.setAttribute("section", section);
        request.setAttribute(
          "types",
          SectionTypes.getSectionsBeans(servlet));
        request.setAttribute(
          "type",
          SectionTypes.getSectionBean(servlet, sform.getTemplate()));
        request.setAttribute("workflows", Workflow.listTypes());
        request.setAttribute(ERROR_KEY, errors);
      } catch (Exception e) {
        Mapping.rollback();
        throw new ServletException(e);
      }

      // Forward to the view page
      return (mapping.findForward("view"));
    }

    // fill data | errors
    if (errors.size() > 0) {
      try {
        Mapping.begin();
        Section section = Section.getInstance(id);
        Mapping.rollback();

        request.setAttribute("section", section);
        request.setAttribute(
          "types",
          SectionTypes.getSectionsBeans(servlet));
        request.setAttribute(
          "type",
          SectionTypes.getSectionBean(servlet, sform.getTemplate()));
        request.setAttribute(ERROR_KEY, errors);
        request.setAttribute("workflows", Workflow.listTypes());
        // copy metadata
        Enumeration names = request.getParameterNames();
        request.setAttribute("copyMeta", "true");
        while (names.hasMoreElements()) {
          String name = names.nextElement() + "";
          if (name.startsWith("META_")) {
            request.setAttribute(name, request.getParameter(name));
          }
        }
      } catch (Exception e) {
        Mapping.rollback();
        throw new ServletException(e);
      }

      // Forward to the view page
      return (mapping.findForward("view"));
    }

    // all it's ok : update section
    try {
      Mapping.begin();

      Section section = Section.getInstance(id);
      section.setMetaData("name", sform.getName());
      section.setMetaData("template", sform.getTemplate());
      section.setMetaData("status", sform.getStatus());
      section.setMetaData("workflow", sform.getWorkflow());
      // update metadata
      Enumeration names = request.getParameterNames();
      while (names.hasMoreElements()) {
        String name = names.nextElement() + "";
        if (name.startsWith("META_")) {
          section.setMetaData(
            name.substring(5),
            request.getParameter(name));
        }
      }
      // update the tree ...
      TreeControlNode node =
        (
          (TreeControl) request.getSession().getAttribute(
            "treeControlTest")).findNode(
          request.getParameter("id"));
      node.setLabel(sform.getName());
      String img = "section.gif";
      if ("offline".equals(section.getMetaData("status"))) {
        img = "section-offline.gif";
      }
      node.setIcon(img);
View Full Code Here

TOP

Related Classes of org.nextime.ion.backoffice.form.EditSectionForm

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.