Java源码示例:org.apache.struts.action.DynaActionForm

示例1
/**
 * {@inheritDoc}
 */
public ActionForward execute(ActionMapping mapping,
        ActionForm formIn,
        HttpServletRequest request,
        HttpServletResponse response) {
    DynaActionForm form = (DynaActionForm) formIn;

    if (isSubmitted(form)) {
        ActionErrors errors = RhnValidationHelper.validateDynaActionForm(this, form);
        if (errors.isEmpty()) {
            return getStrutsDelegate().forwardParams(mapping.findForward("submit"),
                    request.getParameterMap());
        }
        getStrutsDelegate().saveMessages(request, errors);
    }
    setupDatePicker(request, form);
    setupListHelper(request);
    return getStrutsDelegate().forwardParams(
        mapping.findForward(RhnHelper.DEFAULT_FORWARD),
        request.getParameterMap());
}
 
示例2
public ActionForward createBibliographicReference(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    final DynaActionForm dynaActionForm = (DynaActionForm) form;
    final String title = dynaActionForm.getString("title");
    final String authors = dynaActionForm.getString("authors");
    final String reference = dynaActionForm.getString("reference");
    final String year = dynaActionForm.getString("year");
    final String optional = dynaActionForm.getString("optional");

    final ExecutionCourse executionCourse = (ExecutionCourse) request.getAttribute("executionCourse");

    CreateBibliographicReference.runCreateBibliographicReference(executionCourse.getExternalId(), title, authors, reference,
            year, Boolean.valueOf(optional));

    return forward(request, "/teacher/executionCourse/bibliographicReference.jsp");
}
 
示例3
public void initForm(DynaActionForm monitorForm) {
	MonitorManager mm = MonitorManager.getInstance();

	monitorForm.set("monitorManager",mm);
	List destinations=new ArrayList();
	for (int i=0;i<mm.getMonitors().size();i++) {
		Monitor m=mm.getMonitor(i);
		Set d=m.getDestinationSet();
		for (Iterator it=d.iterator();it.hasNext();) {
			destinations.add(i+","+it.next());				
		}
	}
	String[] selDest=new String[destinations.size()];
	selDest=(String[])destinations.toArray(selDest);
	monitorForm.set("selDestinations",selDest);
	monitorForm.set("enabled",new Boolean(mm.isEnabled()));
	monitorForm.set("eventTypes",EventTypeEnum.getEnumList());
	monitorForm.set("severities",SeverityEnum.getEnumList());
}
 
示例4
/**
 * Creates a date picker object with the given name and prepopulates the date
 * with values from the given request's parameters. Prepopulates the form with
 * these values as well.
 * Your dyna action picker must either be a struts datePickerForm, or
 * possess all of datePickerForm's fields.
 * @param request The request from which to get initial form field values.
 * @param form The datePickerForm
 * @param name The prefix for the date picker form fields, usually "date"
 * @param yearDirection One of DatePicker's year range static variables.
 * @return The created and prepopulated date picker object
 * @see com.redhat.rhn.common.util.DatePicker
 */
public DatePicker prepopulateDatePicker(HttpServletRequest request, DynaActionForm form,
        String name, int yearDirection) {
    //Create the date picker.
    DatePicker p = getDatePicker(name, yearDirection);

    //prepopulate the date for this picker
    p.readMap(request.getParameterMap());

    //prepopulate the form for this picker
    p.writeToForm(form);
    if (!StringUtils.isEmpty(request.getParameter(DatePicker.USE_DATE))) {
        Boolean preset = Boolean.valueOf(request.getParameter(DatePicker.USE_DATE));
        form.set(DatePicker.USE_DATE, preset);
    }
    else if (form.getMap().containsKey(DatePicker.USE_DATE)) {
        form.set(DatePicker.USE_DATE, Boolean.FALSE);
    }
    request.setAttribute(name, p);
    //give back the date picker
    return p;
}
 
示例5
protected boolean validateFirstSelections(DynaActionForm form,
        RequestContext ctx) {
    String cobblerId = ListTagHelper.getRadioSelection(ListHelper.LIST,
            ctx.getRequest());
    if (StringUtils.isBlank(cobblerId)) {
        cobblerId = ctx.getParam(RequestContext.COBBLER_ID, true);
    }

    boolean retval = false;
    form.set(RequestContext.COBBLER_ID, cobblerId);
    ctx.getRequest().setAttribute(RequestContext.COBBLER_ID, cobblerId);
    if (form.get("scheduleAsap") != null) {
        retval = true;
    }
    else if (form.get(RequestContext.COBBLER_ID) != null) {
        return true;
    }
    return retval;
}
 
示例6
/**
 *
 * @param request coming in
 * @param form to validate against
 * @param oid ID of Org we're operating on
 * @param currOrg Org object for oid
 * @return if it passed
 */
private boolean validateForm(HttpServletRequest request, DynaActionForm form,
                Long oid, Org currOrg) {
    boolean retval = true;

    String orgName = form.getString("orgName");
    RequestContext requestContext = new RequestContext(request);

    if (currOrg.getName().equals(orgName)) {
        getStrutsDelegate().saveMessage("message.org_name_not_updated",
                new String[] {"orgName"}, request);
        retval = false;
    }
    else {
        try {
            OrgManager.checkOrgName(orgName);
        }
        catch (ValidatorException ve) {
            getStrutsDelegate().saveMessages(request, ve.getResult());
            retval = false;
        }
    }
    return retval;
}
 
示例7
/**
 * Enables the selected set of systems for configuration management
 * @param mapping struts ActionMapping
 * @param formIn struts ActionForm
 * @param request HttpServletRequest
 * @param response HttpServletResponse
 * @return forward to the summary page.
 */
public ActionForward enable(ActionMapping mapping,
        ActionForm formIn,
        HttpServletRequest request,
        HttpServletResponse response) {
    User user = new RequestContext(request).getCurrentUser();
    RhnSetDecl set = RhnSetDecl.SYSTEMS;

    //get the earliest schedule for package install actions.
    DynaActionForm form = (DynaActionForm) formIn;
    Date earliest = getStrutsDelegate().readDatePicker(form, "date",
            DatePicker.YEAR_RANGE_POSITIVE);
    try {
        ConfigurationManager.getInstance().enableSystems(set, user, earliest);
    }
    catch (MultipleChannelsWithPackageException e) {
        ValidatorError verrors = new ValidatorError("config.multiple.channels");
        ActionErrors errors = RhnValidationHelper.validatorErrorToActionErrors(verrors);
        getStrutsDelegate().saveMessages(request, errors);
        return mapping.findForward("default");
    }

    return mapping.findForward("summary");
}
 
示例8
public ActionForward add(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    InfoShift infoShift = (InfoShift) request.getAttribute(PresentationConstants.SHIFT);

    DynaActionForm addClassesForm = (DynaActionForm) form;
    String[] selectedClasses = (String[]) addClassesForm.get("selectedItems");

    List classOIDs = new ArrayList();
    for (String selectedClasse : selectedClasses) {
        classOIDs.add(selectedClasse);
    }

    try {
        AddSchoolClassesToShift.run(infoShift, classOIDs);
    } catch (FenixServiceException ex) {
        // No probem, the user refreshed the page after adding classes
        request.setAttribute("selectMultipleItemsForm", null);
        return mapping.getInputForward();
    }

    request.setAttribute("selectMultipleItemsForm", null);

    return mapping.findForward("BackToEditShift");
}
 
示例9
private void loadVirtualizationTypes(KickstartWizardHelper cmd, DynaActionForm form,
        RequestContext context) {

    List<KickstartVirtualizationType> types = cmd.getVirtualizationTypes();
    form.set(VIRTUALIZATION_TYPES_PARAM, types);

    if (isCreateMode(context.getRequest())) {
        form.set(VIRTUALIZATION_TYPE_LABEL_PARAM,
                KickstartVirtualizationType.NONE);
    }
    else {
        KickstartRawData data = getKsData(context);
        form.set(VIRTUALIZATION_TYPE_LABEL_PARAM, data.getKickstartDefaults().
                getVirtualizationType().getLabel());
    }
}
 
示例10
/**
 * Sets up the rangling widget.
 * @param context the request context of the current request
 * @param form the dynaform  related to the current request.
 * @param set the rhnset holding the channel ids.
 */
protected void setupWidget(RequestContext context,
                                 DynaActionForm form,
                                 RhnSet set) {
    User user = context.getCurrentUser();
    LinkedHashSet labelValues = new LinkedHashSet();
    populateWidgetLabels(labelValues, context);
    for (Iterator itr = set.getElements().iterator(); itr.hasNext();) {
        Long ccid = ((RhnSetElement) itr.next()).getElement();
        ConfigChannel channel = ConfigurationManager.getInstance()
                                    .lookupConfigChannel(user, ccid);
        String optionstr = channel.getName() + " (" + channel.getLabel() + ")";
        labelValues.add(lv(optionstr, channel.getId().toString()));
    }

    //set the form variables for the widget to read.
    form.set(POSSIBLE_CHANNELS, labelValues);
    if (!labelValues.isEmpty()) {
        if (form.get(SELECTED_CHANNEL) == null) {
            String selected = ((LabelValueBean)labelValues.iterator().next())
                                                    .getValue();
            form.set(SELECTED_CHANNEL, selected);
        }
    }
}
 
示例11
private void setupFormValues(HttpServletRequest request,
        DynaActionForm daForm) {

    RequestContext requestContext = new RequestContext(request);
    Long sid = requestContext.getParamAsLong(IssSlave.SID);

    if (sid == null) { // Creating new
        daForm.set(IssSlave.ID, IssSlave.NEW_SLAVE_ID);
        daForm.set(IssSlave.ENABLED, true);
        daForm.set(IssSlave.ALLOWED_ALL_ORGS, true);
    }
    else {
        IssSlave slave = IssFactory.lookupSlaveById(sid);

        daForm.set(IssSlave.ID, sid);
        daForm.set(IssSlave.SLAVE, slave.getSlave());
        daForm.set(IssSlave.ENABLED, "Y".equals(slave.getEnabled()));
        daForm.set(IssSlave.ALLOWED_ALL_ORGS, "Y".equals(slave.getAllowAllOrgs()));

        request.setAttribute(IssSlave.SID, sid);
    }
}
 
示例12
public void testExecute() throws Exception {
    user.getOrg().addRole(RoleFactory.SAT_ADMIN);
    user.addPermanentRole(RoleFactory.SAT_ADMIN);
    addRequestParameter("oid", user.getOrg().getId().toString());
    setRequestPathInfo("/admin/multiorg/OrgDetails");
    actionPerform();
    DynaActionForm form = (DynaActionForm) getActionForm();
    assertNotNull(form.get("orgName"));
    assertNotNull(form.get("id"));
    assertNotNull(form.get("users"));
    assertNotNull(form.get("systems"));
    assertNotNull(form.get("actkeys"));
    assertNotNull(form.get("ksprofiles"));
    assertNotNull(form.get("groups"));
    assertNotNull(form.get("cfgchannels"));

}
 
示例13
public void StoreFormData(String query, String result, DynaActionForm executeJdbcQueryExecuteForm) {
	List jmsRealms = JmsRealmFactory.getInstance().getRegisteredRealmNamesAsList();
	if (jmsRealms.size() == 0)
		jmsRealms.add("no realms defined");
	executeJdbcQueryExecuteForm.set("jmsRealms", jmsRealms);
	List queryTypes = new ArrayList();
	queryTypes.add("select");
	queryTypes.add("other");
	executeJdbcQueryExecuteForm.set("queryTypes", queryTypes);

	List resultTypes = new ArrayList();
	resultTypes.add("csv");
	resultTypes.add("xml");
	executeJdbcQueryExecuteForm.set("resultTypes", resultTypes);
	if (null != query)
		executeJdbcQueryExecuteForm.set("query", query);
	if (null != result) {
		executeJdbcQueryExecuteForm.set("result", result);

	}
}
 
示例14
private void setupNetworkInfo(DynaActionForm form, RequestContext context,
        KickstartScheduleCommand cmd) {
    Server server = cmd.getServer();
    List<NetworkInterface> nics = getPublicNetworkInterfaces(server);

    if (nics.isEmpty()) {
        return;
    }

    context.getRequest().setAttribute(NETWORK_INTERFACES, nics);

    if (StringUtils.isBlank(form.getString(NETWORK_INTERFACE))) {
        String defaultInterface = ConfigDefaults.get().
                getDefaultKickstartNetworkInterface();
        for (NetworkInterface nic : nics) {
            if (nic.getName().equals(defaultInterface)) {
                form.set(NETWORK_INTERFACE, ConfigDefaults.get().
                        getDefaultKickstartNetworkInterface());
            }
        }
        if (StringUtils.isBlank(form.getString(NETWORK_INTERFACE))) {
            form.set(NETWORK_INTERFACE, server.
                    findPrimaryNetworkInterface().getName());
        }
    }
}
 
示例15
private ActionMessages processForm(Profile profile, DynaActionForm f) {

        if (log.isDebugEnabled()) {
            log.debug("Processing form.");
        }

        ActionMessages msgs = new ActionMessages();

        int numDeleted = ProfileManager.deleteProfile(profile);
        if (numDeleted > 0) {
            msgs.add(ActionMessages.GLOBAL_MESSAGE,
                    new ActionMessage("deleteconfirm.jsp.profiledeleted",
                            profile.getName()));
        }

        return msgs;
    }
 
示例16
@Override
protected ProvisionVirtualInstanceCommand getScheduleCommand(DynaActionForm form,
        RequestContext ctx, Date scheduleTime, String host) {
    Profile cobblerProfile = getCobblerProfile(ctx);
    User user = ctx.getCurrentUser();
    ProvisionVirtualInstanceCommand cmd;
    KickstartData data = KickstartFactory.
            lookupKickstartDataByCobblerIdAndOrg(user.getOrg(), cobblerProfile.getId());

    if (data != null) {
        cmd =
                new ProvisionVirtualInstanceCommand(
                        (Long) form.get(RequestContext.SID),
                        data,
                        ctx.getCurrentUser(),
                        scheduleTime,
                        host);
    }
    else {
        cmd = ProvisionVirtualInstanceCommand.createCobblerScheduleCommand((Long)
                form.get(RequestContext.SID), cobblerProfile.getName(),
                user, scheduleTime,  host);
    }
    return cmd;
}
 
示例17
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    final DynaActionForm actionForm = (DynaActionForm) form;

    final String degreeCurricularPlanIDString = (String) actionForm.get("degreeCurricularPlanID");
    final String curricularCourseIDString = (String) actionForm.get("curricularCourseID");
    final String oldCurricularCourseIDString = (String) actionForm.get("oldCurricularCourseID");
    if (isValidObjectID(degreeCurricularPlanIDString) && isValidObjectID(curricularCourseIDString)
            && isValidObjectID(oldCurricularCourseIDString)) {

        try {
            CreateCurricularCourseEquivalency.run(degreeCurricularPlanIDString, curricularCourseIDString,
                    oldCurricularCourseIDString);
        } catch (DomainException e) {
            addActionMessage(request, e.getMessage());
        }
    }

    return prepare(mapping, form, request, response);
}
 
示例18
/**
 * Create the init.sls file for channel
 * @param request the incoming request
 * @param channel the channel to be affected
 * @param form the form to be filled in
 */
private void createInitSlsFile(ConfigChannel channel,
                                 HttpServletRequest request, DynaActionForm form) {
    if (channel.isStateChannel()) {
        channel = (ConfigChannel) HibernateFactory.reload(channel);
        ConfigFileData data = new SLSFileData(StringUtil.webToLinux(
                                form.getString(ConfigFileForm.REV_CONTENTS)));
        try {
            RequestContext ctx = new RequestContext(request);
            ConfigFileBuilder.getInstance().create(data, ctx.getCurrentUser(), channel);
        }
        catch (ValidatorException ve) {
            getStrutsDelegate().saveMessages(request, ve.getResult());
        }
        catch (Exception e) {
            LOG.error("Error creating init.sls file ", e);
        }
    }
}
 
示例19
public ActionForward removeCoordinators(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws FenixActionException, FenixServiceException {
    DynaActionForm removeCoordinatorsForm = (DynaActionForm) form;
    String[] coordinatorsIds = (String[]) removeCoordinatorsForm.get("coordinatorsIds");
    List<String> coordinators = Arrays.asList(coordinatorsIds);

    String infoExecutionDegreeIdString = request.getParameter("infoExecutionDegreeId");
    request.setAttribute("infoExecutionDegreeId", infoExecutionDegreeIdString);
    try {
        RemoveCoordinators.runRemoveCoordinators(infoExecutionDegreeIdString, coordinators);
    } catch (FenixServiceException e) {
        throw new FenixActionException(e);
    }

    return viewTeam(mapping, form, request, response);
}
 
示例20
private InfoExecutionCourseEditor fillInfoExecutionCourseFromForm(ActionForm actionForm, HttpServletRequest request) {

        InfoExecutionCourseEditor infoExecutionCourse = new InfoExecutionCourseEditor();

        DynaActionForm editExecutionCourseForm = (DynaActionForm) actionForm;

        try {
            infoExecutionCourse.setExternalId((String) editExecutionCourseForm.get("executionCourseId"));
            infoExecutionCourse.setNome((String) editExecutionCourseForm.get("name"));
            infoExecutionCourse.setSigla((String) editExecutionCourseForm.get("code"));
            infoExecutionCourse.setComment((String) editExecutionCourseForm.get("comment"));
            infoExecutionCourse.setAvailableGradeSubmission(Boolean.valueOf(editExecutionCourseForm
                    .getString("availableGradeSubmission")));
            infoExecutionCourse.setEntryPhase(EntryPhase.valueOf(editExecutionCourseForm.getString("entryPhase")));

        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }

        return infoExecutionCourse;
    }
 
示例21
protected String performAction(DynaActionForm monitorForm, String action, int index, int triggerIndex, HttpServletResponse response) {
	MonitorManager mm = MonitorManager.getInstance();

	if (index>=0) {
		Monitor monitor = mm.getMonitor(index);
		monitorForm.set("monitor",monitor);
	}
	
	return null;
}
 
示例22
/** {@inheritDoc} */
public ActionForward execute(ActionMapping actionMapping,
                             ActionForm actionForm,
                             HttpServletRequest request,
                             HttpServletResponse response) throws Exception {

    RequestContext requestContext = new RequestContext(request);
    DynaActionForm f = (DynaActionForm) actionForm;

    ListHelper helper = new ListHelper(this, request);
    helper.setDataSetName(RequestContext.PAGE_LIST);
    helper.execute();

    Map<String, Object> params = new HashMap<String, Object>();
    params.put(RequestContext.MODE,
            requestContext.getRequiredParamAsString(RequestContext.MODE));

    if (request.getParameter("dispatch") != null) {
        String packagesDecl = request.getParameter("packagesDecl");
        if (requestContext.wasDispatched("installconfirm.jsp.confirm")) {
            return executePackageAction(actionMapping, actionForm, request, response);
        }
    }

    // Pre-populate the date picker
    DynaActionForm dynaForm = (DynaActionForm) actionForm;
    DatePicker picker = getStrutsDelegate().prepopulateDatePicker(request, dynaForm,
        "date", DatePicker.YEAR_RANGE_POSITIVE);
    request.setAttribute("date", picker);

    // Pre-populate the Action Chain selector
    ActionChainHelper.prepopulateActionChains(request);

    return actionMapping.findForward(RhnHelper.DEFAULT_FORWARD);
}
 
示例23
public static boolean validate(Object bean, ValidatorAction va, Field field, ActionMessages errors,
        HttpServletRequest request, ServletContext application) {

    try {

        DynaActionForm form = (DynaActionForm) bean;

        String sProperty = field.getProperty();
        Object[] multiBox = (Object[]) form.get(sProperty);

        String feminin = field.getVarValue("femininProperty");
        if ((multiBox != null) && (multiBox.length > 0)) {
            return true;
        }
        if (feminin != null && feminin.equalsIgnoreCase("true")) {
            errors.add(field.getKey(), new ActionError("errors.required.a.checkbox", field.getArg(0).getKey()));
        } else {
            errors.add(field.getKey(), new ActionError("errors.required.checkbox", field.getArg(0).getKey()));
        }

        return false;

    } catch (Exception e) {
        errors.add(field.getKey(), new ActionError("errors.required.undefined.checkbox", field.getArg(0).getKey()));
        return false;
    }

}
 
示例24
private void fillForm(ActionForm form, InfoExecutionCourse infoExecutionCourse, HttpServletRequest request) {

        DynaActionForm executionCourseForm = (DynaActionForm) form;
        executionCourseForm.set("name", infoExecutionCourse.getNome());
        executionCourseForm.set("code", infoExecutionCourse.getSigla());
        executionCourseForm.set("comment", infoExecutionCourse.getComment());
        executionCourseForm.set("entryPhase", infoExecutionCourse.getEntryPhase().getName());
        if (infoExecutionCourse.getAvailableGradeSubmission() != null) {
            executionCourseForm.set("availableGradeSubmission", infoExecutionCourse.getAvailableGradeSubmission().toString());
        }
        request.setAttribute("courseLoadBean", new CourseLoadBean(infoExecutionCourse.getExecutionCourse()));
    }
 
示例25
private void setupEditDefaults(RequestContext ctx, Channel original,
        DynaActionForm form, String cloneType) {
    EditChannelAction.prepDropdowns(ctx, original);
    HttpServletRequest req = ctx.getRequest();

    String channelName = LocalizationService.getInstance().getMessage(
            "frontend.actions.channels.manager.create");
    req.setAttribute(EditChannelAction.CHANNEL_NAME, channelName);
    form.set(EditChannelAction.ORG_SHARING, "private");
    form.set(EditChannelAction.SUBSCRIPTIONS, "all");

    req.setAttribute(EditChannelAction.CLONE_TYPE, cloneType);
    req.setAttribute(EditChannelAction.ORIGINAL_NAME, original.getName());
    req.setAttribute(EditChannelAction.ORIGINAL_ID, original.getId());
    req.setAttribute("submitted", false);

    // can't really localize this...
    String name = "Clone of " + original.getName();
    String label = "clone-" + original.getLabel();
    int i = 2;
    // okay to use in the webui here; label should unique, org notwithstanding
    while (ChannelFactory.lookupByLabel(label) != null) {
        name = "Clone " + i + " of " + original.getName();
        label = "clone-" + i + "-" + original.getLabel();
        i++;
    }

    form.set(EditChannelAction.NAME, name);
    form.set(EditChannelAction.LABEL, label);

    EditChannelAction.setupFormHelper(req, form, original);
}
 
示例26
private boolean validateInput(DynaActionForm form, List fieldNames,
        RequestContext ctx) {
    ActionErrors errs =
            RhnValidationHelper.validateDynaActionForm(this, form, fieldNames);
    boolean retval = errs.size() == 0;

    if (!retval) {
        saveMessages(ctx.getRequest(), errs);
    }
    return retval;
}
 
示例27
/**
 *
 * {@inheritDoc}
 */
protected void processForm(RequestContext rctx, ActionForm form) {
    super.processForm(rctx, form);

    if (form instanceof DynaActionForm) {
        if (!isSubmitted((DynaActionForm) form)) {
            Iterator itr = getSelectedItemsIterator(rctx, form);
            if (itr != null && itr.hasNext()) {
                populateNewSet(rctx, itr);
            }
        }
    }
}
 
示例28
private ActionForward goToInsertComplexSummaryAgain(HttpServletRequest request, ActionMapping mapping,
        HttpServletResponse response, ActionForm form) {

    final IViewState summaryViewState = RenderUtils.getViewState("summariesManagementBeanWithSummary");
    if (summaryViewState != null) {
        SummariesManagementBean summaryBean = (SummariesManagementBean) summaryViewState.getMetaObject().getObject();
        readAndSaveTeacher(summaryBean, (DynaActionForm) form, request, mapping);
        return returnToCreateComplexSummary(mapping, form, request, summaryBean, null);
    }
    return prepareShowSummaries(mapping, form, request, response);
}
 
示例29
/**
 *
 * {@inheritDoc}
 */
protected void setupFormValues(RequestContext ctx, DynaActionForm form,
        BaseKickstartCommand cmdIn) {
    KickstartTroubleshootingCommand cmd = (KickstartTroubleshootingCommand) cmdIn;

    ArrayList bootloaders = getBootLoaders(cmd);
    ctx.getRequest().setAttribute(BOOTLOADER_OPTIONS, bootloaders);

    form.set(BOOTLOADER, cmd.getBootloaderType());
    form.set(KERNEL_PARAMS, cmd.getKernelParams());
    form.set(NONCHROOTPOST, cmd.getNonChrootPost());
    form.set(VERBOSEUP2DATE, cmd.getVerboseUp2date());
}
 
示例30
/** {@inheritDoc} */
public ActionForward execute(ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response) {

    RequestContext rctx = new RequestContext(request);
    DynaActionForm daForm = (DynaActionForm)form;
    StrutsDelegate strutsDelegate = getStrutsDelegate();
    ActionForward forward = null;

    Long nid = Long.parseLong(request.getParameter("nid"));

    User loggedInUser = rctx.getCurrentUser();
    Long sid = Long.parseLong(request.getParameter("sid"));
    Server server = SystemManager.lookupByIdAndUser(sid, loggedInUser);
    Note note = SystemManager.lookupNoteByIdAndSystem(loggedInUser, nid, sid);

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

    if (isSubmitted(daForm)) {
        SystemManager.deleteNote(loggedInUser, sid, nid);
        createSuccessMessage(request, "message.notedeleted", "");
        params.put(RequestContext.SID, request.getParameter(RequestContext.SID));
        forward = strutsDelegate.forwardParams(mapping.findForward("success"),
                params);
    }
    else {
        setupPageAndFormValues(rctx.getRequest(), daForm, server, note);
        forward =  strutsDelegate.forwardParams(
                mapping.findForward(RhnHelper.DEFAULT_FORWARD), params);
    }

    return forward;
}