Example usage for javax.servlet.http HttpServletRequest getParameterValues

List of usage examples for javax.servlet.http HttpServletRequest getParameterValues

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getParameterValues.

Prototype

public String[] getParameterValues(String name);

Source Link

Document

Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.

Usage

From source file:br.mdarte.exemplo.academico.web.geral.consultarCurso.ConsultaCursoUCFormImpl.java

/**
 * Override to provide population of current form with request parameters when validation fails.
 *
 * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
 *//*from  w w  w.  j a  v a 2s  .  com*/
public org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping,
        javax.servlet.http.HttpServletRequest request) {
    final org.apache.struts.action.ActionErrors errors = super.validate(mapping, request);
    if (errors != null && !errors.isEmpty()) {
        Object formObj = org.andromda.presentation.bpm4struts.PageSessionObjectUtil.getPageForm(request,
                "ConsultaCursoUC");

        if (formObj != null) {
            try {
                formObj.getClass()
                        .getMethod("resetCheckBoxes",
                                new Class[] { org.apache.struts.action.ActionMapping.class,
                                        javax.servlet.http.HttpServletRequest.class })
                        .invoke(formObj, new Object[] { null, null });
            } catch (Exception e2) {
                // ignoring
            }

            final java.util.Map parameters = new java.util.HashMap();
            for (final java.util.Enumeration names = request.getParameterNames(); names.hasMoreElements();) {
                final String name = String.valueOf(names.nextElement());
                parameters.put(name, request.getParameterValues(name));
            }
            try {
                org.apache.commons.beanutils.BeanUtils.populate(formObj, parameters);
            } catch (java.lang.Exception populateException) {
                // ignore if we have an exception here (we just don't populate).
            }
        }
    }
    return errors;
}

From source file:br.mdarte.exemplo.academico.web.geral.consultarEstudante.ResultadoConsultaDetalhaEstudanteFormImpl.java

/**
 * Override to provide population of current form with request parameters when validation fails.
 *
 * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
 *//*from w w  w  .  ja  v  a  2 s  .  co m*/
public org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping,
        javax.servlet.http.HttpServletRequest request) {
    final org.apache.struts.action.ActionErrors errors = super.validate(mapping, request);
    if (errors != null && !errors.isEmpty()) {
        Object formObj = org.andromda.presentation.bpm4struts.PageSessionObjectUtil.getPageForm(request,
                "ConsultaEstudanteUC.ResultadoConsulta");

        if (formObj != null) {
            try {
                formObj.getClass()
                        .getMethod("resetCheckBoxes",
                                new Class[] { org.apache.struts.action.ActionMapping.class,
                                        javax.servlet.http.HttpServletRequest.class })
                        .invoke(formObj, new Object[] { null, null });
            } catch (Exception e2) {
                // ignoring
            }

            final java.util.Map parameters = new java.util.HashMap();
            for (final java.util.Enumeration names = request.getParameterNames(); names.hasMoreElements();) {
                final String name = String.valueOf(names.nextElement());
                parameters.put(name, request.getParameterValues(name));
            }
            try {
                org.apache.commons.beanutils.BeanUtils.populate(formObj, parameters);
            } catch (java.lang.Exception populateException) {
                // ignore if we have an exception here (we just don't populate).
            }
        }
    }
    return errors;
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.teacher.SummariesManagementDA.java

public ActionForward prepareCreateComplexSummary(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) {

    Professorship loggedProfessorship = (Professorship) request.getAttribute("loggedTeacherProfessorship");
    ExecutionCourse executionCourse = (ExecutionCourse) request.getAttribute("executionCourse");
    DynaActionForm dynaActionForm = (DynaActionForm) form;
    String[] selectedLessons = request.getParameterValues("selectedLessonAndDate");

    if (selectedLessons == null || selectedLessons.length == 0) {
        return goToInsertComplexSummaryAgain(request, mapping, response, form);
    } else if (selectedLessons != null && selectedLessons.length != 0) {

        boolean uniqueType = true;
        ShiftType shiftType = null;//w ww  . ja v  a  2  s .co  m
        List<NextPossibleSummaryLessonsAndDatesBean> nextPossibleLessonsDates = new ArrayList<NextPossibleSummaryLessonsAndDatesBean>();

        for (String lessonRepresentation : selectedLessons) {

            NextPossibleSummaryLessonsAndDatesBean nextLesson = NextPossibleSummaryLessonsAndDatesBean
                    .getNewInstance(lessonRepresentation);
            if (nextLesson.getLesson().getShift().getCourseLoadsSet().size() == 1) {
                nextLesson.setLessonType(
                        nextLesson.getLesson().getShift().getCourseLoadsSet().iterator().next().getType());
            }

            nextPossibleLessonsDates.add(nextLesson);

            ShiftType lessonType = null;
            if (nextLesson.getLesson().getShift().getCourseLoadsSet().size() == 1) {
                lessonType = nextLesson.getLesson().getShift().getCourseLoadsSet().iterator().next().getType();
                if (shiftType == null) {
                    shiftType = lessonType;
                } else if (!shiftType.equals(lessonType)) {
                    request.setAttribute("notShowLessonPlanningsAndSummaries", Boolean.TRUE);
                    uniqueType = false;
                }
            } else {
                request.setAttribute("notShowLessonPlanningsAndSummaries", Boolean.TRUE);
                uniqueType = false;
            }
        }

        SummariesManagementBean bean = new SummariesManagementBean(
                SummariesManagementBean.SummaryType.NORMAL_SUMMARY, executionCourse, loggedProfessorship,
                nextPossibleLessonsDates);
        bean.setTaught(true);

        if (uniqueType) {
            bean.setLessonType(shiftType);
        }

        request.setAttribute("summariesManagementBean", bean);
        dynaActionForm.set("teacher", loggedProfessorship.getExternalId().toString());
        return mapping.findForward("prepareInsertComplexSummary");
    }

    return prepareShowSummaries(mapping, form, request, response);
}

From source file:br.mdarte.exemplo.academico.web.geral.detalharEstudante.DetalhandoEstudanteEditaEstudanteFormImpl.java

/**
 * Override to provide population of current form with request parameters when validation fails.
 *
 * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
 *///from  w  w  w  .j a va 2 s  . c  o  m
public org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping,
        javax.servlet.http.HttpServletRequest request) {
    final org.apache.struts.action.ActionErrors errors = super.validate(mapping, request);
    if (errors != null && !errors.isEmpty()) {
        Object formObj = org.andromda.presentation.bpm4struts.PageSessionObjectUtil.getPageForm(request,
                "DetalhaEstudanteUC.DetalhandoEstudante");

        if (formObj != null) {
            try {
                formObj.getClass()
                        .getMethod("resetCheckBoxes",
                                new Class[] { org.apache.struts.action.ActionMapping.class,
                                        javax.servlet.http.HttpServletRequest.class })
                        .invoke(formObj, new Object[] { null, null });
            } catch (Exception e2) {
                // ignoring
            }

            final java.util.Map parameters = new java.util.HashMap();
            for (final java.util.Enumeration names = request.getParameterNames(); names.hasMoreElements();) {
                final String name = String.valueOf(names.nextElement());
                parameters.put(name, request.getParameterValues(name));
            }
            try {
                org.apache.commons.beanutils.BeanUtils.populate(formObj, parameters);
            } catch (java.lang.Exception populateException) {
                // ignore if we have an exception here (we just don't populate).
            }
        }
    }
    return errors;
}

From source file:fr.paris.lutece.plugins.mylutece.modules.database.authentication.web.GroupJspBean.java

/**
 * Process assignation roles for a specified group
 *
 * @param request The Http request//from   www .ja v  a2  s. c  o  m
 * @return Html form
 */
public String doAssignRoleGroup(HttpServletRequest request) {
    String strReturn;

    String strActionCancel = request.getParameter(PARAMETER_CANCEL);

    if (strActionCancel != null) {
        strReturn = JSP_MANAGE_GROUPS;
    } else {
        //get group
        Group group = getGroupFromRequest(request);

        if (group == null) {
            return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_MANAGE_GROUPS,
                    AdminMessage.TYPE_ERROR);
        }

        String[] roleArray = request.getParameterValues(PARAMETER_ROLE_KEY);

        GroupRoleHome.removeRoles(group.getGroupKey(), getPlugin());

        if (roleArray != null) {
            for (int i = 0; i < roleArray.length; i++) {
                GroupRoleHome.addRole(group.getGroupKey(), roleArray[i], getPlugin());
            }
        }

        strReturn = JSP_MANAGE_ROLES_GROUP + QUESTION_MARK + PARAMETER_GROUP_KEY + EQUAL + group.getGroupKey();
    }

    return strReturn;
}

From source file:fr.paris.lutece.portal.web.rbac.RoleManagementJspBean.java

/**
 * Get the permission selection page./*  ww w  .j a v  a  2 s .c  o  m*/
 * 2 methods are provided :
 * <ul>
 * <li>wildcard selection : all permissions for this type are selected.</li>
 * <li>specific selection : the choice is to be made by the user in the list
 * of available permissions.</li>
 * </ul>
 * @param request the http request
 * @return the html code for the permission selection page.
 */
public String getSelectPermissions(HttpServletRequest request) {
    setPageTitleProperty(PROPERTY_SELECT_PERMISSIONS_PAGETITLE);

    String strRoleKey = request.getParameter(PARAMETER_ROLE_KEY);
    String strResourceType = request.getParameter(PARAMETER_RESOURCE_TYPE);
    String strSelectionMethod = request.getParameter(PARAMETER_SELECT_RESOURCES_METHOD);

    String[] strArrayResourceIds = request.getParameterValues(PARAMETER_RESOURCE_ID);

    // load the permission list for permission selection
    ReferenceList listPermissions = ResourceTypeManager.getPermissionsList(strResourceType, getLocale());

    Map<String, Object> model = new HashMap<String, Object>();

    // forward the resource id  list
    model.put(MARK_RESOURCE_ID_LIST, strArrayResourceIds);

    // load the permission list
    model.put(MARK_PERMISSIONS_LIST, listPermissions);

    // forward the role key, the resource type and the resource id selection method
    model.put(MARK_ROLE_KEY, strRoleKey);
    model.put(MARK_RESOURCE_TYPE, strResourceType);
    model.put(MARK_SELECT_RESOURCES_METHOD, strSelectionMethod);

    HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_SELECT_PERMISSIONS, getLocale(), model);

    return getAdminPage(template.getHtml());
}

From source file:br.mdarte.exemplo.academico.web.geral.manterCurso.MantemCursoUCFormImpl.java

/**
 * Override to provide population of current form with request parameters when validation fails.
 *
 * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
 *///w w w.j av a  2s  .  c o  m
public org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping,
        javax.servlet.http.HttpServletRequest request) {
    final org.apache.struts.action.ActionErrors errors = super.validate(mapping, request);
    if (errors != null && !errors.isEmpty()) {
        Object formObj = org.andromda.presentation.bpm4struts.PageSessionObjectUtil.getPageForm(request,
                "MantemCursoUC");

        if (formObj != null) {
            try {
                formObj.getClass()
                        .getMethod("resetCheckBoxes",
                                new Class[] { org.apache.struts.action.ActionMapping.class,
                                        javax.servlet.http.HttpServletRequest.class })
                        .invoke(formObj, new Object[] { null, null });
            } catch (Exception e2) {
                // ignoring
            }

            final java.util.Map parameters = new java.util.HashMap();
            for (final java.util.Enumeration names = request.getParameterNames(); names.hasMoreElements();) {
                final String name = String.valueOf(names.nextElement());
                parameters.put(name, request.getParameterValues(name));
            }
            try {
                org.apache.commons.beanutils.BeanUtils.populate(formObj, parameters);
            } catch (java.lang.Exception populateException) {
                // ignore if we have an exception here (we just don't populate).
            }
        }
    }
    return errors;
}

From source file:br.mdarte.exemplo.academico.web.geral.detalharCurso.DetalhaCursoUCFormImpl.java

/**
 * Override to provide population of current form with request parameters when validation fails.
 *
 * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
 *///  w ww .  j  a  v  a  2 s.co  m
public org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping,
        javax.servlet.http.HttpServletRequest request) {
    final org.apache.struts.action.ActionErrors errors = super.validate(mapping, request);
    if (errors != null && !errors.isEmpty()) {
        Object formObj = org.andromda.presentation.bpm4struts.PageSessionObjectUtil.getPageForm(request,
                "DetalhaCursoUC");

        if (formObj != null) {
            try {
                formObj.getClass()
                        .getMethod("resetCheckBoxes",
                                new Class[] { org.apache.struts.action.ActionMapping.class,
                                        javax.servlet.http.HttpServletRequest.class })
                        .invoke(formObj, new Object[] { null, null });
            } catch (Exception e2) {
                // ignoring
            }

            final java.util.Map parameters = new java.util.HashMap();
            for (final java.util.Enumeration names = request.getParameterNames(); names.hasMoreElements();) {
                final String name = String.valueOf(names.nextElement());
                parameters.put(name, request.getParameterValues(name));
            }
            try {
                org.apache.commons.beanutils.BeanUtils.populate(formObj, parameters);
            } catch (java.lang.Exception populateException) {
                // ignore if we have an exception here (we just don't populate).
            }
        }
    }
    return errors;
}

From source file:br.mdarte.exemplo.academico.web.geral.manterEstudante.MantemEstudanteUCFormImpl.java

/**
 * Override to provide population of current form with request parameters when validation fails.
 *
 * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
 *///  w w  w .  j  av  a 2 s . c  om
public org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping,
        javax.servlet.http.HttpServletRequest request) {
    final org.apache.struts.action.ActionErrors errors = super.validate(mapping, request);
    if (errors != null && !errors.isEmpty()) {
        Object formObj = org.andromda.presentation.bpm4struts.PageSessionObjectUtil.getPageForm(request,
                "MantemEstudanteUC");

        if (formObj != null) {
            try {
                formObj.getClass()
                        .getMethod("resetCheckBoxes",
                                new Class[] { org.apache.struts.action.ActionMapping.class,
                                        javax.servlet.http.HttpServletRequest.class })
                        .invoke(formObj, new Object[] { null, null });
            } catch (Exception e2) {
                // ignoring
            }

            final java.util.Map parameters = new java.util.HashMap();
            for (final java.util.Enumeration names = request.getParameterNames(); names.hasMoreElements();) {
                final String name = String.valueOf(names.nextElement());
                parameters.put(name, request.getParameterValues(name));
            }
            try {
                org.apache.commons.beanutils.BeanUtils.populate(formObj, parameters);
            } catch (java.lang.Exception populateException) {
                // ignore if we have an exception here (we just don't populate).
            }
        }
    }
    return errors;
}