Java Code Examples for org.apache.wicket.ajax.AjaxRequestTarget#getPage()
The following examples show how to use
org.apache.wicket.ajax.AjaxRequestTarget#getPage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewGradeLogAction.java From sakai with Educational Community License v2.0 | 6 votes |
@Override public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) { final String assignmentId = params.get("assignmentId").asText(); final String studentUuid = params.get("studentId").asText(); final Map<String, Object> model = new HashMap<>(); model.put("assignmentId", Long.valueOf(assignmentId)); model.put("studentUuid", studentUuid); final GradebookPage gradebookPage = (GradebookPage) target.getPage(); final GbModalWindow window = gradebookPage.getGradeLogWindow(); window.setAssignmentToReturnFocusTo(assignmentId); window.setStudentToReturnFocusTo(studentUuid); window.setContent(new GradeLogPanel(window.getContentId(), Model.ofMap(model), window)); window.show(target); return new EmptyOkResponse(); }
Example 2
Source File: SetScoreForUngradedAction.java From sakai with Educational Community License v2.0 | 6 votes |
@Override public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) { final String assignmentId = params.get("assignmentId").asText(); final GradebookPage gradebookPage = (GradebookPage) target.getPage(); final GbModalWindow window = gradebookPage.getUpdateUngradedItemsWindow(); final UpdateUngradedItemsPanel panel = new UpdateUngradedItemsPanel( window.getContentId(), Model.of(Long.valueOf(assignmentId)), window); window.setTitle(gradebookPage.getString("heading.updateungradeditems")); window.setAssignmentToReturnFocusTo(assignmentId); window.setContent(panel); window.showUnloadConfirmation(false); window.show(target); panel.setOutputMarkupId(true); target.appendJavaScript("new GradebookUpdateUngraded($(\"#" + panel.getMarkupId() + "\"));"); return new EmptyOkResponse(); }
Example 3
Source File: ToggleCourseGradePoints.java From sakai with Educational Community License v2.0 | 6 votes |
@Override public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) { final GradebookPage gradebookPage = (GradebookPage) target.getPage(); // get current settings final GradebookUiSettings settings = gradebookPage.getUiSettings(); final Boolean currentSetting = settings.getShowPoints(); // toggle it final Boolean nextSetting = !currentSetting; // set it settings.setShowPoints(nextSetting); // save settings gradebookPage.setUiSettings(settings); // refresh the page target.appendJavaScript("location.reload();"); return new EmptyOkResponse(); }
Example 4
Source File: EditAssignmentAction.java From sakai with Educational Community License v2.0 | 6 votes |
@Override public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) { final String assignmentId = params.get("assignmentId").asText(); final GradebookPage gradebookPage = (GradebookPage) target.getPage(); final GbModalWindow window = gradebookPage.getAddOrEditGradeItemWindow(); window.setTitle(gradebookPage.getString("heading.editgradeitem")); window.setAssignmentToReturnFocusTo(assignmentId); window.setContent(new AddOrEditGradeItemPanel(window.getContentId(), window, Model.of(Long.valueOf(assignmentId)))); window.showUnloadConfirmation(false); window.show(target); return new EmptyOkResponse(); }
Example 5
Source File: ViewRubricGradeAction.java From sakai with Educational Community License v2.0 | 6 votes |
@Override public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) { final String assignmentId = params.get("assignmentId").asText(); final String studentUuid = params.get("studentId").asText(); final Map<String, Object> model = new HashMap<>(); model.put("assignmentId", Long.valueOf(assignmentId)); model.put("studentUuid", studentUuid); final GradebookPage gradebookPage = (GradebookPage) target.getPage(); final GbModalWindow window = gradebookPage.getRubricGradeWindow(); window.setAssignmentToReturnFocusTo(assignmentId); window.setStudentToReturnFocusTo(studentUuid); window.setContent(new RubricGradePanel(window.getContentId(), Model.ofMap(model), window)); window.show(target); return new EmptyOkResponse(); }
Example 6
Source File: DeleteAssignmentAction.java From sakai with Educational Community License v2.0 | 6 votes |
@Override public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) { final String assignmentId = params.get("assignmentId").asText(); final GradebookPage gradebookPage = (GradebookPage) target.getPage(); final GbModalWindow window = gradebookPage.getDeleteItemWindow(); window.setTitle(gradebookPage.getString("delete.label")); window.setAssignmentToReturnFocusTo(assignmentId); window.setContent(new DeleteItemPanel( window.getContentId(), Model.of(Long.valueOf(assignmentId)), window)); window.showUnloadConfirmation(false); window.show(target); return new EmptyOkResponse(); }
Example 7
Source File: SetStudentNameOrderAction.java From sakai with Educational Community License v2.0 | 6 votes |
@Override public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) { final String orderParam = params.get("orderby").asText(); final GbStudentNameSortOrder nameSortOrder = GbStudentNameSortOrder.valueOf(orderParam.toUpperCase()); final GradebookPage gradebookPage = (GradebookPage) target.getPage(); final GradebookUiSettings settings = gradebookPage.getUiSettings(); settings.setNameSortOrder(nameSortOrder); // save settings gradebookPage.setUiSettings(settings); // refresh the page target.appendJavaScript("location.reload();"); return new EmptyOkResponse(); }
Example 8
Source File: SetStudentNameOrderAction.java From sakai with Educational Community License v2.0 | 6 votes |
@Override public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) { final String orderParam = params.get("orderby").asText(); final GbStudentNameSortOrder nameSortOrder = GbStudentNameSortOrder.valueOf(orderParam.toUpperCase()); final GradebookPage gradebookPage = (GradebookPage) target.getPage(); final GradebookUiSettings settings = gradebookPage.getUiSettings(); settings.setNameSortOrder(nameSortOrder); // save settings gradebookPage.setUiSettings(settings); // refresh the page target.appendJavaScript("location.reload();"); return new EmptyOkResponse(); }
Example 9
Source File: ToggleCourseGradePoints.java From sakai with Educational Community License v2.0 | 6 votes |
@Override public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) { final GradebookPage gradebookPage = (GradebookPage) target.getPage(); // get current settings final GradebookUiSettings settings = gradebookPage.getUiSettings(); final Boolean currentSetting = settings.getShowPoints(); // toggle it final Boolean nextSetting = !currentSetting; // set it settings.setShowPoints(nextSetting); // save settings gradebookPage.setUiSettings(settings); // refresh the page target.appendJavaScript("location.reload();"); return new EmptyOkResponse(); }
Example 10
Source File: OverrideCourseGradeAction.java From sakai with Educational Community License v2.0 | 6 votes |
@Override public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) { final String studentUuid = params.get("studentId").asText(); final GradebookPage gradebookPage = (GradebookPage) target.getPage(); final GbModalWindow window = gradebookPage.getUpdateCourseGradeDisplayWindow(); window.setStudentToReturnFocusTo(studentUuid); window.setReturnFocusToCourseGrade(); window.setContent(new CourseGradeOverridePanel(window.getContentId(), Model.of(studentUuid), window)); window.showUnloadConfirmation(false); window.show(target); return new EmptyOkResponse(); }
Example 11
Source File: ValidateLink.java From JPPF with Apache License 2.0 | 6 votes |
@Override public void onSubmit(final AjaxRequestTarget target) { if (debugEnabled) log.debug("clicked on node.filter.validate"); final NodeFilterPage page = (NodeFilterPage) target.getPage(); final TextArea<String> area = page.getPolicyField(); final String xml = area.getModelObject(); final Pair<Boolean, String> result = NodeFilterUtils.validatePolicy(xml); final boolean valid = result.first(); final MessageDialog dialog = valid ? page.getValidDialog() : page.getErrorDialog(); String message = LocalizationUtils.getLocalized("org.jppf.ui.i18n.FilterPanel", "node.filter." + (valid ? "valid" : "invalid") + ".message", JPPFWebSession.get().getLocale()); if (!valid) message += "\n" + result.second(); if (debugEnabled) log.debug("message = {}", message); dialog.setModelObject(message); dialog.open(target); //target.add(page); }
Example 12
Source File: UploadLink.java From JPPF with Apache License 2.0 | 6 votes |
@Override public void onSubmit(final AjaxRequestTarget target) { if (debugEnabled) log.debug("clicked on node.filter.upload"); final NodeFilterPage page = (NodeFilterPage) target.getPage(); final FileUploadField fileUploadField = page.getFileUploadField(); final FileUpload fileUpload = fileUploadField.getFileUpload(); try { final byte[] bytes = fileUpload.getBytes(); final String s = new String(bytes, "UTF-8"); final TextArea<String> area = page.getPolicyField(); area.setModel(Model.of(s)); } catch (final Exception e) { log.error(e.getMessage(), e); } target.add(getForm()); }
Example 13
Source File: ViewAssignmentStatisticsAction.java From sakai with Educational Community License v2.0 | 5 votes |
@Override public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) { final String assignmentId = params.get("assignmentId").asText(); final GradebookPage gradebookPage = (GradebookPage) target.getPage(); final GbModalWindow window = gradebookPage.getAssignmentStatisticsWindow(); window.setAssignmentToReturnFocusTo(assignmentId); window.setContent(new AssignmentStatisticsPanel(window.getContentId(), Model.of(Long.valueOf(assignmentId)), window)); window.show(target); return new EmptyOkResponse(); }
Example 14
Source File: ServerResetStatsLink.java From JPPF with Apache License 2.0 | 5 votes |
@Override public void onClick(final AjaxRequestTarget target) { if (debugEnabled) log.debug("clicked on server reset stats"); final JPPFWebSession session = JPPFWebSession.get(); final TopologyDriver driver = session.getCurrentDriver(); try { final JMXDriverConnectionWrapper jmx = driver.getJmx(); if ((jmx != null) && jmx.isConnected()) jmx.resetStatistics(); } catch (final Exception e) { log.warn(e.getMessage(), e); } final StatisticsPage page = (StatisticsPage) target.getPage(); target.add(page.getTablesContainer()); }
Example 15
Source File: ViewCourseGradeLogAction.java From sakai with Educational Community License v2.0 | 5 votes |
@Override public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) { final String studentUuid = params.get("studentId").asText(); final GradebookPage page = (GradebookPage) target.getPage(); final GbModalWindow window = page.getUpdateCourseGradeDisplayWindow(); window.setStudentToReturnFocusTo(studentUuid); window.setReturnFocusToCourseGrade(); window.setContent(new CourseGradeOverrideLogPanel(window.getContentId(), Model.of(studentUuid), window)); window.showUnloadConfirmation(false); window.show(target); return new EmptyOkResponse(); }
Example 16
Source File: SetZeroScoreAction.java From sakai with Educational Community License v2.0 | 5 votes |
@Override public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) { final GradebookPage gradebookPage = (GradebookPage) target.getPage(); final GbModalWindow window = gradebookPage.getUpdateUngradedItemsWindow(); window.setTitle(gradebookPage.getString("heading.zeroungradeditems")); window.setReturnFocusToCourseGrade(); window.setContent(new ZeroUngradedItemsPanel(window.getContentId(), window)); window.showUnloadConfirmation(false); window.show(target); return new EmptyOkResponse(); }
Example 17
Source File: ViewGradeSummaryAction.java From sakai with Educational Community License v2.0 | 4 votes |
@Override public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) { final String studentUuid = params.get("studentId").asText(); final GradebookUiSettings settings = ((GradebookPage) target.getPage()).getUiSettings(); final GbUser student = businessService.getUser(studentUuid); final Map<String, Object> model = new HashMap<>(); model.put("studentUuid", studentUuid); model.put("groupedByCategoryByDefault", settings.isCategoriesEnabled()); final GradebookPage gradebookPage = (GradebookPage) target.getPage(); final GbModalWindow window = gradebookPage.getStudentGradeSummaryWindow(); final Component content = new StudentGradeSummaryPanel(window.getContentId(), Model.ofMap(model), window); if (window.isShown() && window.isVisible()) { window.replace(content); content.setVisible(true); target.add(content); } else { window.setContent(content); window.show(target); } window.setStudentToReturnFocusTo(studentUuid); content.setOutputMarkupId(true); final String modalTitle = (new StringResourceModel("heading.studentsummary", null, new Object[] { student.getDisplayName(), student.getDisplayId() })).getString(); window.setTitle(modalTitle); window.show(target); target.appendJavaScript(String.format( "new GradebookGradeSummary($(\"#%s\"), false, \"%s\");", content.getMarkupId(), modalTitle)); return new EmptyOkResponse(); }
Example 18
Source File: GradeUpdateAction.java From sakai with Educational Community License v2.0 | 4 votes |
@Override public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) { final GradebookPage page = (GradebookPage) target.getPage(); // clear the feedback message at the top of the page target.addChildren(page, FeedbackPanel.class); final String rawOldGrade = params.get("oldScore").textValue(); String rawNewGrade = StringUtils.trimToEmpty(params.get("newScore").textValue()); final String decimal = ComponentManager.get(FormattedText.class).getDecimalSeparator(); if (rawNewGrade.startsWith(decimal)) { rawNewGrade = "0" + rawNewGrade; // prepend a 0 so this passes validation (ie. ".1 " becomes "0.1") } if (StringUtils.isNotBlank(rawNewGrade) && (!NumberUtil.isValidLocaleDouble(rawNewGrade) || FormatHelper.validateDouble(rawNewGrade) < 0)) { target.add(page.updateLiveGradingMessage(page.getString("feedback.error"))); return new ArgumentErrorResponse("Grade not valid"); } final String oldGrade = FormatHelper.formatGradeFromUserLocale(rawOldGrade); final String newGrade = FormatHelper.formatGradeFromUserLocale(rawNewGrade); final String assignmentId = params.get("assignmentId").asText(); final String studentUuid = params.get("studentId").asText(); final String categoryId = params.has("categoryId") ? params.get("categoryId").asText() : null; // We don't pass the comment from the use interface, // but the service needs it otherwise it will assume 'null' // so pull it back from the service and poke it in there! final String comment = businessService.getAssignmentGradeComment(Long.valueOf(assignmentId), studentUuid); // for concurrency, get the original grade we have in the UI and pass it into the service as a check final GradeSaveResponse result = businessService.saveGrade(Long.valueOf(assignmentId), studentUuid, oldGrade, newGrade, comment); if (result.equals(GradeSaveResponse.NO_CHANGE)) { target.add(page.updateLiveGradingMessage(page.getString("feedback.saved"))); return new SaveGradeNoChangeResponse(); } if (!result.equals(GradeSaveResponse.OK) && !result.equals(GradeSaveResponse.OVER_LIMIT)) { target.add(page.updateLiveGradingMessage(page.getString("feedback.error"))); return new SaveGradeErrorResponse(result); } final CourseGrade studentCourseGrade = businessService.getCourseGrade(studentUuid); final Gradebook gradebook = businessService.getGradebook(); final CourseGradeFormatter courseGradeFormatter = new CourseGradeFormatter( gradebook, page.getCurrentRole(), businessService.isCourseGradeVisible(businessService.getCurrentUser().getId()), page.getUiSettings().getShowPoints(), true); final GbCourseGrade gbcg = new GbCourseGrade(studentCourseGrade); gbcg.setDisplayString(courseGradeFormatter.format(studentCourseGrade)); final String[] courseGradeData = GbGradebookData.getCourseGradeData(gbcg, gradebook.getSelectedGradeMapping().getGradeMap()); Optional<CategoryScoreData> catData = categoryId == null ? Optional.empty() : businessService.getCategoryScoreForStudent(Long.valueOf(categoryId), studentUuid, true); String categoryScore = catData.map(c -> String.valueOf(c.score)).orElse("-"); List<Long> droppedItems = catData.map(c -> c.droppedItems).orElse(Collections.emptyList()); target.add(page.updateLiveGradingMessage(page.getString("feedback.saved"))); return new GradeUpdateResponse( result.equals(GradeSaveResponse.OVER_LIMIT), courseGradeData, categoryScore, droppedItems); }
Example 19
Source File: GradeUpdateAction.java From sakai with Educational Community License v2.0 | 4 votes |
@Override public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) { final GradebookPage page = (GradebookPage) target.getPage(); // clear the feedback message at the top of the page target.addChildren(page, FeedbackPanel.class); final String rawOldGrade = params.get("oldScore").textValue(); String rawNewGrade = StringUtils.trimToEmpty(params.get("newScore").textValue()); final String decimal = ComponentManager.get(FormattedText.class).getDecimalSeparator(); if (rawNewGrade.startsWith(decimal)) { rawNewGrade = "0" + rawNewGrade; // prepend a 0 so this passes validation (ie. ".1 " becomes "0.1") } if (StringUtils.isNotBlank(rawNewGrade) && (!NumberUtil.isValidLocaleDouble(rawNewGrade) || FormatHelper.validateDouble(rawNewGrade) < 0)) { target.add(page.updateLiveGradingMessage(page.getString("feedback.error"))); return new ArgumentErrorResponse("Grade not valid"); } final String oldGrade = FormatHelper.formatGradeFromUserLocale(rawOldGrade); final String newGrade = FormatHelper.formatGradeFromUserLocale(rawNewGrade); final String assignmentId = params.get("assignmentId").asText(); final String studentUuid = params.get("studentId").asText(); final String categoryId = params.has("categoryId") ? params.get("categoryId").asText() : null; // We don't pass the comment from the use interface, // but the service needs it otherwise it will assume 'null' // so pull it back from the service and poke it in there! final String comment = businessService.getAssignmentGradeComment(Long.valueOf(assignmentId), studentUuid); // for concurrency, get the original grade we have in the UI and pass it into the service as a check final GradeSaveResponse result = businessService.saveGrade(Long.valueOf(assignmentId), studentUuid, oldGrade, newGrade, comment); if (result.equals(GradeSaveResponse.NO_CHANGE)) { target.add(page.updateLiveGradingMessage(page.getString("feedback.saved"))); return new SaveGradeNoChangeResponse(); } if (!result.equals(GradeSaveResponse.OK) && !result.equals(GradeSaveResponse.OVER_LIMIT)) { target.add(page.updateLiveGradingMessage(page.getString("feedback.error"))); return new SaveGradeErrorResponse(result); } final CourseGrade studentCourseGrade = businessService.getCourseGrade(studentUuid); final Gradebook gradebook = businessService.getGradebook(); final CourseGradeFormatter courseGradeFormatter = new CourseGradeFormatter( gradebook, page.getCurrentRole(), businessService.isCourseGradeVisible(businessService.getCurrentUser().getId()), page.getUiSettings().getShowPoints(), true); final GbCourseGrade gbcg = new GbCourseGrade(studentCourseGrade); gbcg.setDisplayString(courseGradeFormatter.format(studentCourseGrade)); final String[] courseGradeData = GbGradebookData.getCourseGradeData(gbcg, gradebook.getSelectedGradeMapping().getGradeMap()); Optional<CategoryScoreData> catData = categoryId == null ? Optional.empty() : businessService.getCategoryScoreForStudent(Long.valueOf(categoryId), studentUuid, true); String categoryScore = catData.map(c -> String.valueOf(c.score)).orElse("-"); List<Long> droppedItems = catData.map(c -> c.droppedItems).orElse(Collections.emptyList()); target.add(page.updateLiveGradingMessage(page.getString("feedback.saved"))); return new GradeUpdateResponse( result.equals(GradeSaveResponse.OVER_LIMIT), courseGradeData, categoryScore, droppedItems); }
Example 20
Source File: ViewCourseGradeStatisticsAction.java From sakai with Educational Community License v2.0 | 3 votes |
@Override public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget target) { final String siteId = params.get("siteId").asText(); final GradebookPage gradebookPage = (GradebookPage) target.getPage(); final GbModalWindow window = gradebookPage.getGradeLogWindow(); window.setContent(new CourseGradeStatisticsPanel(window.getContentId(), Model.of(siteId), window)); window.show(target); return new EmptyOkResponse(); }