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:cn.vlabs.umt.ui.servlet.AuthorizationCodeServlet.java

/**
 * ?responseTypetoken//ww  w. j a  va 2 s. c o  m
 * @param request
 * @param response
 * @param oauthRequest
 * @throws IOException 
 * @throws ServletException 
 */
private void responseTypeIsToken(HttpServletRequest request, HttpServletResponse response,
        OAuthAuthzRequestWrap oauthRequest) throws IOException, ServletException {
    String[] scopes = request.getParameterValues("userScopes");
    String redirectURI = oauthRequest.getRedirectURI();
    try {
        String uid = ServiceFactory.getUserService(request).getUserByLoginName(
                getLoginInfo(request, getClientServer().findByClientId(oauthRequest.getClientId())).getName())
                .getId() + "";
        OauthToken token = OauthTokenServlet.createToken(oauthRequest.getClientId(), redirectURI, request,
                tansferScope(scopes), uid);
        StringBuilder sb = new StringBuilder();
        addTokenParam(sb, token, request, oauthRequest.getState());
        if (redirectURI.contains("#")) {
            if (redirectURI.endsWith("#")) {
                redirectURI = redirectURI + sb.toString();
            } else {
                redirectURI = redirectURI + "&" + sb.toString();
            }
        } else {
            redirectURI = redirectURI + "#" + sb.toString();
        }
        getTokenServer().save(token);
        response.sendRedirect(redirectURI);
    } catch (OAuthSystemException e) {
        dealOAuthSystemError(redirectURI, e, request, response);
    }
}

From source file:com.photon.phresco.framework.rest.api.util.FrameworkServiceUtil.java

/**
 * To validate multi select list box//w ww.j av  a2  s  .co m
 * @param parameter
 * @param returnFlag
 * @param lableTxt
 * @return
 */
private static ActionResponse multiSelectValidate(Parameter parameter, String lableTxt,
        HttpServletRequest request, ActionResponse actionResponse) {
    if (request.getParameterValues(parameter.getKey()) == null
            && Boolean.parseBoolean(parameter.getRequired())) {//for multi select list box
        actionResponse.setErrorFound(true);
        actionResponse.setConfigErrorMsg(lableTxt + " " + "is missing");
        actionResponse.setParameterKey(parameter.getKey());
        actionResponse.setStatus(RESPONSE_STATUS_SUCCESS);
        actionResponse.setResponseCode(PHR8C00001);
    }
    return actionResponse;
}

From source file:fr.paris.lutece.plugins.stock.modules.billetterie.web.OfferJspBean.java

/**
 * Returns the confirmation message to delete an offer
 *
 * @param request The Http request/*from ww  w .  j a  v a  2 s.c o  m*/
 * @return the html code message
 */
public String getMasseDeleteOffer(HttpServletRequest request) {
    ArrayList<Integer> offersIdToDelete = new ArrayList<Integer>();
    String[] parameterValues = request.getParameterValues(PARAMETER_OFFERS_ID);

    // if no case checked
    if (parameterValues == null) {
        return AdminMessageService.getMessageUrl(request, MESSAGE_DELETE_MASSE_OFFER_NO_OFFER_CHECK,
                AdminMessage.TYPE_STOP);
    }

    try {
        for (String id : parameterValues) {
            offersIdToDelete.add(Integer.parseInt(id));
        }
    } catch (NumberFormatException e) {
        LOGGER.debug(e);

        return AdminMessageService.getMessageUrl(request, StockConstants.MESSAGE_ERROR_OCCUR,
                AdminMessage.TYPE_STOP);
    }

    boolean masse = offersIdToDelete.size() > 1;

    String strJspBack = JSP_MANAGE_OFFERS;

    Map<String, Object> urlParam = new HashMap<String, Object>();
    String error = errorWithDeleteOffer(request, urlParam, offersIdToDelete);

    if (error != null) {
        return error;
    }

    return AdminMessageService.getMessageUrl(request,
            masse ? MESSAGE_CONFIRMATION_MASSE_DELETE_OFFER : MESSAGE_CONFIRMATION_DELETE_OFFER, null,
            MESSAGE_TITLE_CONFIRMATION_MASSE_DELETE_OFFER,
            masse ? JSP_DO_MASSE_DELETE_OFFER : JSP_DO_DELETE_OFFER, BilletterieConstants.TARGET_SELF,
            AdminMessage.TYPE_CONFIRMATION, urlParam, strJspBack);
}

From source file:net.duckling.ddl.web.controller.DashboardController.java

@RequestMapping(params = "func=emailNoticeDetail")
public void submitEmailNoticeDetail(HttpServletRequest request, HttpServletResponse response) {
    VWBContext context = getVWBContext(request);
    String[] allNoticeChecked = request.getParameterValues("allNoticeChecked[]");
    String[] allNoticeUnChecked = request.getParameterValues("allNoticeUnChecked[]");
    String[] shareNoticeChecked = request.getParameterValues("shareNoticeChecked[]");
    String[] shareNoticeUnChecked = request.getParameterValues("shareNoticeUnChecked[]");
    boolean needRefresh = needRefresh(allNoticeChecked, allNoticeUnChecked, shareNoticeChecked,
            shareNoticeUnChecked);/* w  w w .  j  ava 2 s  .c o m*/
    isExistThenCreateElseUpdateParam(paramService, ParamConstants.NoticeEmailAllType.TYPE,
            context.getCurrentUID() + "", allNoticeChecked, ParamConstants.NoticeEmailAllType.VALUE_CHECKED);
    isExistThenCreateElseUpdateParam(paramService, ParamConstants.NoticeEmailAllType.TYPE,
            context.getCurrentUID() + "", allNoticeUnChecked,
            ParamConstants.NoticeEmailAllType.VALUE_UN_CHECKED);
    isExistThenCreateElseUpdateParam(paramService, ParamConstants.NoticeEmailShareType.TYPE,
            context.getCurrentUID() + "", shareNoticeChecked,
            ParamConstants.NoticeEmailShareType.VALUE_CHECKED);
    isExistThenCreateElseUpdateParam(paramService, ParamConstants.NoticeEmailShareType.TYPE,
            context.getCurrentUID() + "", shareNoticeUnChecked,
            ParamConstants.NoticeEmailShareType.VALUE_UN_CHECKED);
    JsonUtil.writeJSONObject(response, needRefresh);
}

From source file:com.krawler.spring.calendar.calendarmodule.crmCalendarController.java

public ModelAndView getAllEvents(HttpServletRequest request, HttpServletResponse response)
        throws ServletException {

    List<CalendarEvent> result = null;
    List<CalendarEvent> modEvents = null;
    TimeZone tz;//from  ww w  . j  a  v a 2 s . c  o  m
    try {
        tz = TimeZone.getTimeZone("GMT" + sessionHandlerImpl.getTimeZoneDifference(request));
    } catch (SessionExpiredException e1) {
        tz = TimeZone.getDefault();
    }
    try {
        List<CalendarEvent> temp;
        if (request.getParameter("calView").equals("1")) {
            String[] cidList = request.getParameterValues("cidList");
            Long viewdt1 = Long.parseLong(request.getParameter("viewdt1"));
            Long viewdt2 = Long.parseLong(request.getParameter("viewdt2"));
            int limit = Integer.parseInt(request.getParameter("limit"));
            int offset = Integer.parseInt(request.getParameter("start"));

            temp = calendarEventService.getEvents(cidList, new Date(viewdt1), new Date(viewdt2), offset, limit);
        } else {
            String[] cid = request.getParameterValues("cid");
            temp = calendarEventService.getEvents(cid);
        }
        if (temp != null) {
            result = new ArrayList<CalendarEvent>();
            for (CalendarEvent e : temp) {
                if (!e.isAllDay() && !(request.getParameter("calView").equals("1"))) {
                    List durations = calendarEventService.breakDuration(e.getDuration(), tz);
                    if (durations.size() > 1)
                        result.addAll(calendarEventService.breakEvent(e, durations));
                    else
                        result.add(e);
                } else {
                    result.add(e);
                }

            }
        }
        StringBuffer usersList = sessionHandlerImpl.getRecursiveUsersList(request);
        if (moduleEventServices != null) {
            HashMap<String, Object> params = null;
            if (request.getParameter("calView").equals("1")) {
                params = new HashMap<String, Object>();
                Long stDate = Long.parseLong(request.getParameter("viewdt1"));
                Long edDate = Long.parseLong(request.getParameter("viewdt2"));
                params.put("from", stDate);
                params.put("to", edDate);
            }

            for (ModuleEventService mes : moduleEventServices) {
                modEvents = mes.getEvents(usersList, params);
                if (modEvents != null) {
                    for (CalendarEvent e : modEvents) {
                        try {
                            if (!e.isAllDay() && !(request.getParameter("calView").equals("1"))) {
                                List durations = calendarEventService.breakDuration(e.getDuration(), tz);
                                if (durations.size() > 1)
                                    result.addAll(calendarEventService.breakEvent(e, durations));
                                else
                                    result.add(e);
                            } else {
                                result.add(e);
                            }
                        } catch (Exception ev) {
                            logger.warn(ev.getMessage());
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        logger.warn(e.getMessage());
    }
    SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    fmt.setTimeZone(tz);
    EventJSONMapper mapper = new EventJSONMapper();
    mapper.setDateFormat(fmt);
    return new ModelAndView(new CalendarView(mapper, "data"), "data", result);
}

From source file:fr.paris.lutece.plugins.document.service.attributes.ListBoxManager.java

/**
 * {@inheritDoc}/* w ww.  j  av  a  2  s  . c  om*/
 */
@Override
public List<AttributeTypeParameter> getValueParameters(HttpServletRequest request, Locale locale) {
    // Button "Add" new parameter
    boolean bAddNewValue = StringUtils.isNotBlank(request.getParameter(PARAMETER_ADD));

    // Button "Delete" parameters
    boolean bDeleteValue = StringUtils.isNotBlank(request.getParameter(PARAMETER_DELETE));
    boolean bByDefault = StringUtils.isNotBlank(request.getParameter(PARAMETER_BY_DEFAULT));
    List<AttributeTypeParameter> listParameters = super.getExtraParameters(locale);

    for (AttributeTypeParameter parameter : listParameters) {
        List<String> listValues = new ArrayList<String>();
        String[] arrayStrValues = request.getParameterValues(parameter.getName());

        if (NAME_VALUE.equals(parameter.getName())) {
            // Define default value
            if (bByDefault) {
                String strValue = request.getParameter(PARAMETER_ITEMS_SELECT);

                if (StringUtils.isNotBlank(strValue)) {
                    listValues.add(strValue);
                }
            } else {
                if ((arrayStrValues != null) && (arrayStrValues.length > 0)) {
                    listValues.addAll(Arrays.asList(arrayStrValues));
                }
            }
        } else if (NAME_ITEMS.equals(parameter.getName())) {
            if ((arrayStrValues != null) && (arrayStrValues.length > 0)) {
                listValues.addAll(Arrays.asList(arrayStrValues));
            }

            // Add new value
            if (bAddNewValue) {
                String strNewValue = request.getParameter(PARAMETER_ITEMS_VALUE);

                if (StringUtils.isNotBlank(strNewValue)) {
                    listValues.add(strNewValue);
                }
            }

            // Remove value
            if (bDeleteValue) {
                String strValue = request.getParameter(PARAMETER_ITEMS_SELECT);

                if (StringUtils.isNotBlank(strValue)) {
                    listValues.remove(strValue);
                    removeParameterValue(listParameters, strValue);
                }
            }
        }

        parameter.setValueList(listValues);
        listValues.clear();
    }

    return listParameters;
}

From source file:com.virtusa.akura.common.controller.ManageSpecialEventsController.java

/**
 * Create or update SpecialEvent details.
 * /*from   w  w  w .j a va2  s  .  c  o  m*/
 * @param request - HttpServletRequest
 * @param model - ModelMap
 * @param specialEvents - SpecialEvents object
 * @param bindingResult - BindingResult
 * @return name of the view which is redirected to.
 * @throws AkuraAppException - if error occurs when save or update a FaithLifeRating instance.
 */
@RequestMapping(value = "/saveOrUpdateSpecialEvent.htm", method = RequestMethod.POST)
public String saveOrUpdateSpecialEvent(@ModelAttribute(MODEL_ATT_SPECIAL_EVENT) SpecialEvents specialEvents,
        BindingResult bindingResult, HttpServletRequest request, ModelMap model) throws AkuraAppException {

    String[] toList = null;

    if (request.getParameterValues(REQUEST_SELECTED_LIST) != null) {
        toList = request.getParameterValues(REQUEST_SELECTED_LIST);
    }

    // Trim the special event name
    specialEvents.setName(specialEvents.getName().trim());

    specialEventsValidator.validate(specialEvents, bindingResult);

    int intSpecialEventId = specialEvents.getSpecialEventsId();
    String strMessage = null;
    SpecialEvents spEvent;
    String finalToList = null;

    if (bindingResult.hasErrors()) {

        if (specialEvents.getSpecialEventsId() != 0) {
            spEvent = commonService.findSpecialEventsById(specialEvents.getSpecialEventsId());
            model.addAttribute(MODEL_ATT_SELECTED_OBJECT, spEvent);
        }

        errorMassage(model, specialEvents);

        if (request.getParameterValues(REQUEST_SELECTED_LIST) != null) {
            toList = request.getParameterValues(REQUEST_SELECTED_LIST);
            finalToList = this.toListToString(specialEvents, toList);

        }
        model.addAttribute(MODEL_ATT_OBJECT_PARTICIPANT, finalToList);
        model.addAttribute(MODEL_ATT_OBJECT_FORM, specialEvents);
        return VIEW_GET_CREATE_SPECIAL_EVENTS;
    } else {
        if (toList == null) {

            if (specialEvents.getSpecialEventsId() != 0) {
                spEvent = commonService.findSpecialEventsById(specialEvents.getSpecialEventsId());
                model.addAttribute(MODEL_ATT_SELECTED_OBJECT, spEvent);
            }

            errorMassage(model, specialEvents);
            if (request.getParameterValues(REQUEST_SELECTED_LIST) != null) {
                toList = request.getParameterValues(REQUEST_SELECTED_LIST);
                finalToList = this.toListToString(specialEvents, toList);

            }
            model.addAttribute(MODEL_ATT_OBJECT_PARTICIPANT, finalToList);
            strMessage = new ErrorMsgLoader().getErrorMessage(AkuraWebConstant.MANDATORY_FIELD_ERROR_CODE);
            model.addAttribute(MODEL_ATT_MESSAGE, strMessage);
            model.addAttribute(MODEL_ATT_OBJECT_FORM, specialEvents);
            return VIEW_GET_CREATE_SPECIAL_EVENTS;

        } else {
            try {

                if (commonService.isExistsSpecialEvents(specialEvents)) {

                    if (intSpecialEventId != 0) {
                        List<String> toListt = new ArrayList<String>();
                        spEvent = commonService.findSpecialEventsById(intSpecialEventId);

                        if (spEvent.getSpecialEventsId() == specialEvents.getSpecialEventsId()
                                && spEvent.getName().equalsIgnoreCase(specialEvents.getName())
                                && (spEvent.getDate().compareTo(specialEvents.getDate())) == 0
                                && spEvent.getParticipantCategory().getParticipantCategoryId() == specialEvents
                                        .getParticipantCategory().getParticipantCategoryId()
                                && spEvent.getDescription().equalsIgnoreCase(specialEvents.getDescription())) {
                            toList = request.getParameterValues(REQUEST_SELECTED_LIST);
                            List<String> toListtt = Arrays.asList(toList);
                            List<SpecialEventsParticipation> participants = commonService
                                    .getParticipantListBySpecialEvent(spEvent);

                            String participantId = null;
                            int partId = 0;
                            for (SpecialEventsParticipation participant : participants) {

                                if (spEvent.getParticipantCategory()
                                        .getParticipantCategoryId() == AkuraConstant.PARAM_INDEX_ONE) {
                                    partId = participant.getClassGrade().getClassGradeId();
                                } else if (spEvent.getParticipantCategory()
                                        .getParticipantCategoryId() == AkuraConstant.PARAM_INDEX_TWO) {
                                    partId = participant.getSportCategory().getSportCategoryId();
                                } else if (spEvent.getParticipantCategory()
                                        .getParticipantCategoryId() == AkuraConstant.PARAM_INDEX_THREE) {
                                    partId = participant.getClubSociety().getClubSocietyId();
                                }
                                participantId = String.valueOf(partId);
                                toListt.add(participantId);
                            }
                            if (toListt.equals(toListtt)) {
                                return VIEW_GET_CREATE_SPECIAL_EVENTS;
                            }
                        }
                        // editing selected object with detail or participation list
                        if (spEvent.getName().equalsIgnoreCase(specialEvents.getName())
                                && (spEvent.getDate().compareTo(specialEvents.getDate())) == 0) {

                            // deleting all specilEvents participation list related to given                             
                            List<SpecialEventsParticipation> participants = commonService
                                    .getParticipantListBySpecialEvent(spEvent);
                            commonService.deleteAllSpecialEventsParticipation(participants);
                            commonService.editSpecialEvents(specialEvents);
                            createSpecialEventsParticipant(toList, spEvent);
                            return VIEW_POST_CREAT_SPECIAL_EVENTS;

                        } else {

                            spEvent = commonService.findSpecialEventsById(specialEvents.getSpecialEventsId());
                            if (request.getParameterValues(REQUEST_SELECTED_LIST) != null) {
                                toList = request.getParameterValues(REQUEST_SELECTED_LIST);
                                finalToList = this.toListToString(specialEvents, toList);

                            }
                            model.addAttribute(MODEL_ATT_OBJECT_PARTICIPANT, finalToList);
                            model.addAttribute(MODEL_ATT_SELECTED_OBJECT, spEvent);
                            model.addAttribute(SHOW_EDIT_SECTION, SHOW_EDIT_SECTION);
                            model.addAttribute(MODEL_ATT_SELECTED_OBJECT_ID, intSpecialEventId);
                            bindingResult.rejectValue("specialEventsId",
                                    AkuraWebConstant.ALREADY_EXIST_ERROR_CODE);
                            return VIEW_GET_CREATE_SPECIAL_EVENTS;
                        }
                    } else {
                        model.addAttribute(MODEL_ATT_SELECTED_OBJECT_ID, intSpecialEventId);
                        errorMassage(model, specialEvents);
                        if (request.getParameterValues(REQUEST_SELECTED_LIST) != null) {
                            toList = request.getParameterValues(REQUEST_SELECTED_LIST);
                            finalToList = this.toListToString(specialEvents, toList);
                        }
                        model.addAttribute(MODEL_ATT_OBJECT_PARTICIPANT, finalToList);
                        model.addAttribute(SHOW_EDIT_SECTION, SHOW_EDIT_SECTION);
                        bindingResult.rejectValue("specialEventsId", AkuraWebConstant.ALREADY_EXIST_ERROR_CODE);
                        return VIEW_GET_CREATE_SPECIAL_EVENTS;
                    }
                } else {

                    if (intSpecialEventId == 0) {
                        spEvent = commonService.addSpecialEvents(specialEvents);
                        createSpecialEventsParticipant(toList, spEvent);

                    } else {
                        spEvent = commonService.findSpecialEventsById(intSpecialEventId);
                        SpecialEvents speEvent = commonService.findSpecialEventsById(intSpecialEventId);
                        // deleting all specilEvents participation list related to given specialEvent
                        List<SpecialEventsParticipation> participants = commonService
                                .getParticipantListBySpecialEvent(speEvent);
                        commonService.deleteAllSpecialEventsParticipation(participants);
                        commonService.editSpecialEvents(specialEvents);
                        createSpecialEventsParticipant(toList, speEvent);
                    }
                }
            } catch (AkuraAppException e) {
                if (e.getCause() instanceof DataIntegrityViolationException) {
                    strMessage = new ErrorMsgLoader().getErrorMessage(REF_UI_SPECIAL_EVENT_EDIT);
                    errorMassage(model, specialEvents);
                    // SpecialEvents newSpecialEvents = new SpecialEvents();
                    if (request.getParameterValues(REQUEST_SELECTED_LIST) != null) {
                        toList = request.getParameterValues(REQUEST_SELECTED_LIST);
                        finalToList = this.toListToString(specialEvents, toList);
                    }
                    model.addAttribute(MODEL_ATT_OBJECT_PARTICIPANT, finalToList);
                    model.addAttribute(MODEL_ATT_SELECTED_OBJECT_ID, intSpecialEventId);
                    model.addAttribute(SHOW_EDIT_SECTION, SHOW_EDIT_SECTION);
                    model.addAttribute(MODEL_ATT_MESSAGE, strMessage);
                    // model.addAttribute("specialEvents", newSpecialEvents);
                    return VIEW_GET_CREATE_SPECIAL_EVENTS;
                } else {
                    throw e;
                }
            }
        }
    }
    return VIEW_POST_CREAT_SPECIAL_EVENTS;
}

From source file:alpha.portal.webapp.controller.UserSearchController.java

/**
 * On submit./*from  w  w  w  . ja va 2  s .co  m*/
 * 
 * @param request
 *            the request
 * @param response
 *            the response
 * @param model
 *            the model
 * @return the model
 * @throws Exception
 *             the exception
 */
@RequestMapping(method = RequestMethod.POST)
public Model onSubmit(final HttpServletRequest request, final HttpServletResponse response, final Model model)
        throws Exception {
    final String userName = request.getParameter("lastName");
    final String caseId = request.getParameter("case");

    if (request.getParameter("cancel") != null) {
        response.sendRedirect("caseform?caseId=" + caseId);
        return model;
    }

    if (userName != null) {
        final List<User> users = this.userManager.getAll();
        final List<User> res = new LinkedList<User>();
        for (final User u : users) {
            if (u.getLastName().toLowerCase().contains(userName.toLowerCase())) {
                res.add(u);
            }
        }
        model.addAttribute("users", res);
    }

    final String[] userIds = request.getParameterValues("sel[]");

    if (ArrayUtils.isNotEmpty(userIds) && StringUtils.isNotEmpty(caseId)) {
        AlphaCase aCase = this.caseManager.get(caseId);

        for (final String userId : userIds) {
            final User participant = this.userManager.getUser(userId);

            aCase.addParticipant(participant);
        }
        aCase = this.caseManager.save(aCase);
        response.sendRedirect("caseform?caseId=" + caseId);
    }

    return model;
}

From source file:fr.paris.lutece.plugins.workflow.modules.evaluation.web.EvaluationTaskComponent.java

/**
 * Synthesis criteria data//  w ww  . j  a v a  2 s.com
 * @param config the config
 * @param request request
 * @param task the task
 * @return error url
 */
private String getSynthesisCriteriaData(TaskEvaluationConfig config, HttpServletRequest request, ITask task) {
    List<SynthesisCriteria> listSynthesisCriteria = new ArrayList<SynthesisCriteria>();
    String[] tabCriterias = request.getParameterValues(PARAMETER_SYNTHESIS_CRITERIAS);

    for (int nIndex = 0; nIndex < _nNbCritere; nIndex++) {
        String strIdCriteria = request
                .getParameter(PARAMETER_ID_SYNTHESIS_CRITERIA + "_" + tabCriterias[nIndex]);

        if (StringUtils.isBlank(strIdCriteria)) {
            throw new AppException("Criteria id not found");
        }

        int nIdCriteria;

        try {
            nIdCriteria = Integer.parseInt(strIdCriteria);
        } catch (NumberFormatException nfe) {
            throw new AppException("Criteria id not found : " + nfe.getMessage(), nfe);
        }

        String strCriteriaTitle = request
                .getParameter(PARAMETER_SYNTHESIS_CRITERIA_TITLE + "_" + tabCriterias[nIndex]);

        if (StringUtils.isBlank(strCriteriaTitle)) {
            continue;
        }

        String strMandatoryCriteria = request
                .getParameter(PARAMETER_SYNTHESIS_MANDATORY_CRITERIA + "_" + tabCriterias[nIndex]);

        String strType = request.getParameter(PARAMETER_TYPE + "_" + tabCriterias[nIndex]);

        Object[] tabCriteriaNum = { nIndex + 1 };

        if (((strCriteriaTitle == null) || strCriteriaTitle.trim().equals(WorkflowUtils.EMPTY_STRING))) {
            return AdminMessageService.getMessageUrl(request, MESSAGE_MANDATORY_CRITERIA_TITLE, tabCriteriaNum,
                    AdminMessage.TYPE_STOP);
        }

        if (StringUtils.isBlank(strType)) {
            return AdminMessageService.getMessageUrl(request, MESSAGE_MANDATORY_CRITERIA_TYPE, tabCriteriaNum,
                    AdminMessage.TYPE_STOP);
        }

        Type type;

        try {
            type = Type.valueOf(strType);
        } catch (Exception e) {
            throw new AppException("Can't convert to enum for type " + strType + " " + e.getMessage(), e);
        }

        List<Pair> listValues = new ArrayList<Pair>();
        String[] tabValues = request
                .getParameterValues(tabCriterias[nIndex] + "_" + PARAMETER_FROM_ID_SYNTHESIS_CRITERIAS);

        for (String strFormValueId : tabValues) {
            String strTitle = request.getParameter(
                    tabCriterias[nIndex] + "_" + PARAMETER_SYNTHESIS_CRITERIA_TITLE + "_" + strFormValueId);

            if (StringUtils.isBlank(strTitle)) {
                continue;
            }

            String strValue = request.getParameter(
                    tabCriterias[nIndex] + "_" + PARAMETER_SYNTHESIS_CRITERIA_VALUE + "_" + strFormValueId);

            Pair pair = new Pair();

            pair.setTitle(strTitle);
            pair.setValue(strValue);

            listValues.add(pair);
        }

        SynthesisCriteria criteria = new SynthesisCriteria();
        criteria.setIdCriteria(nIdCriteria);
        criteria.setIdTask(task.getId());
        criteria.setMandatory(strMandatoryCriteria != null);
        criteria.setTitle(strCriteriaTitle);
        criteria.setAvailableValues(listValues);
        criteria.setType(type);
        listSynthesisCriteria.add(criteria);
    }

    config.setListSynthesisCriteria(listSynthesisCriteria);

    return null;
}

From source file:presentation.webgui.vitroappservlet.StyleCreator.java

protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    HttpSession session = request.getSession();

    this.mode = request.getParameter("nssfMode");

    this.givenGenCapability = request.getParameter("nssfCapability");
    this.givenDefaultColor = request.getParameter("nssfGlobalColor");
    this.givenDefaultIconfile = request.getParameter("nssfDefaultIconfile");
    this.givenDefaultPrefabfile = request.getParameter("nssfDefaultPrefabfile");

    this.givenSpecialValuesBox = request.getParameterValues("nssfSpecialValuesBox[]");
    this.givenSpecialValueColor = request.getParameterValues("nssfSpecialValueColor[]");
    this.givenSpecialValueIconfile = request.getParameterValues("nssfSpecialValueIconfile[]");
    this.givenSpecialValuePrefabfile = request.getParameterValues("nssfSpecialValuePrefabfile[]");

    this.givenRangeFromBox = request.getParameterValues("nssfRangeFromBox[]");
    this.givenRangeToBox = request.getParameterValues("nssfRangeToBox[]");
    this.givenRangeColor = request.getParameterValues("nssfRangeColor[]");
    this.givenRangeIconfile = request.getParameterValues("nssfRangeIconfile[]");
    this.givenRangePrefabfile = request.getParameterValues("nssfRangePrefabfile[]");

    // default mode is preview mode!
    if (this.mode == null || this.mode.equals("")) {
        this.mode = StyleCreator.modePreview; // by default we assume preview mode
    }/*from w  ww .j av a2 s  .  c o m*/

    if (this.mode.equals(StyleCreator.modePreview)) {
        previewStyleLegend(response);
    } else if (this.mode.equals(StyleCreator.modeSubmitStyle)) {
        submitStyle(response);
    } else {
        response.setContentType("text/html");
        PrintWriter outPrintWriter = response.getWriter();
        outPrintWriter.print("<b>Error</b>: no valid mode was specified! (" + this.mode + ")");
        outPrintWriter.flush();
        outPrintWriter.close();
    }
}