Package org.nextime.ion.backoffice.form

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


    // check if user is correctly logged
    checkUser(request);

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

    // user need cancel
    if (request.getParameter("cancel") != null) {
      // Forward to the next page
      return (mapping.findForward("cancel"));
    }

    // retrieve id
    String id = request.getSession().getAttribute("userLogin")+"";     

    // fill data | first time
    if (sform.getName() == null) {
      try {   
        Mapping.begin();
        User user = User.getInstance(id);       
        Mapping.rollback();
       
        sform.setEmail((String)user.getMetaData("email"));
        sform.setName((String)user.getMetaData("name"));
        sform.setGroups(user.getGroupsIds());
        sform.setPassword(user.getPassword());       
       
      } 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 {
        request.setAttribute(ERROR_KEY, errors);
               
      } catch (Exception e) {
        Mapping.rollback();
        throw new ServletException(e);
      }

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

    // all it's ok : update user
    try {
      Mapping.begin();
      User user = User.getInstance(id);
      user.setMetaData("name", sform.getName());
      user.setMetaData("email", sform.getEmail());
      user.setPassword(sform.getPassword());     
      Mapping.commit();
     
    } catch (Exception e) {
      Mapping.rollback();
      throw new ServletException(e);
View Full Code Here


      Mapping.rollback();
    }


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

    // user need cancel
    if (request.getParameter("cancel") != null) {
      // Forward to the next page
      return (mapping.findForward("cancel"));
    }

    // retrieve id
    String id =
      (request.getAttribute("id") != null)
        ? request.getAttribute("id").toString()
        : request.getParameter("id").toString();

    // fill data | first time
    if (sform.getName() == null) {
      try {   
        Mapping.begin();
        User user = User.getInstance(id);
        Vector groups = Group.listAll();
        Mapping.rollback();
       
        sform.setEmail((String)user.getMetaData("email"));
        sform.setName((String)user.getMetaData("name"));
        sform.setGroups(user.getGroupsIds());
        sform.setPassword(user.getPassword());
        request.setAttribute("groups", groups);
       
      } 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();       
        Vector groups = Group.listAll();
        Mapping.rollback();
       
        request.setAttribute("groups", groups);
        request.setAttribute(ERROR_KEY, errors);
               
      } catch (Exception e) {
        Mapping.rollback();
        throw new ServletException(e);
      }

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

    // all it's ok : update user
    try {
      Mapping.begin();
      User user = User.getInstance(id);
      user.setMetaData("name", sform.getName());
      user.setMetaData("email", sform.getEmail());
      user.setPassword(sform.getPassword());
      user.resetGroups();
      for( int i=0; i<sform.getGroups().length; i++ ) {
        Group group = Group.getInstance(sform.getGroups()[i]);
        user.addGroup(group);
      }
      Mapping.commit();
     
    } catch (Exception e) {
View Full Code Here

TOP

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

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.