List of usage examples for org.apache.wicket.ajax AbstractDefaultAjaxBehavior AbstractDefaultAjaxBehavior
AbstractDefaultAjaxBehavior
From source file:au.org.theark.lims.web.component.barcodelabel.form.DetailForm.java
License:Open Source License
@Override public void onBeforeRender() { if (!isNew()) { BarcodeLabelDataPanel barcodeLabelDataPanel = new BarcodeLabelDataPanel("barcodeLabelDataPanel", containerForm.getModelObject(), feedBackPanel); barcodeLabelDataPanel.initialisePanel(); arkCrudContainerVO.getDetailPanelFormContainer().addOrReplace(barcodeLabelDataPanel); exampleBarcodeDataFile/*from w w w . j ava 2 s . c o m*/ .setModelObject(iLimsAdminService.getBarcodeLabelTemplate(containerForm.getModelObject())); } String selected = new String(); if (containerForm.getModelObject().getBarcodePrinterName() != null) { selected = containerForm.getModelObject().getBarcodePrinterName(); } printerList = new PrinterListPanel("printerList", selected, isNew()); printerList.add(new AbstractDefaultAjaxBehavior() { private static final long serialVersionUID = 1L; @Override public void renderHead(Component component, IHeaderResponse response) { super.renderHead(component, response); response.renderOnLoadJavaScript("findPrinters()"); String js = "function callWicket(selectedPrinter) { var wcall = wicketAjaxGet ('" + getCallbackUrl() + "&selectedPrinter='+selectedPrinter, function() { }, function() { } ) }"; response.renderJavaScript(js, "selectPrinter"); } @Override protected void respond(AjaxRequestTarget arg0) { barcodePrinterName = RequestCycle.get().getRequest().getQueryParameters() .getParameterValue("selectedPrinter"); } }); arkCrudContainerVO.getDetailPanelFormContainer().addOrReplace(printerList); super.onBeforeRender(); }
From source file:au.org.theark.lims.web.component.button.PrinterListPanel.java
License:Open Source License
private void initPanel() { DropDownChoice<String> printerListDdc = new DropDownChoice<String>("printerList", new PropertyModel<String>(this, "selected"), PRINTERLIST); printerListDdc.add(new AttributeModifier("name", "printerList")); printerListDdc.add(new AttributeModifier("onchange", "changeHiddenInput(this)")); printerListDdc.setOutputMarkupPlaceholderTag(true); this.add(printerListDdc); selectedPrinter = new HiddenField<String>("selectedPrinter", new PropertyModel<String>(this, "selected")); selectedPrinter.setOutputMarkupPlaceholderTag(true); selectedPrinter.add(new AttributeModifier("name", "selectedPrinter")); selectedPrinter.add(new AbstractDefaultAjaxBehavior() { private static final long serialVersionUID = 1L; @Override//from w w w .ja v a 2s .com protected void respond(AjaxRequestTarget arg0) { StringValue selectedPrinter = RequestCycle.get().getRequest().getQueryParameters() .getParameterValue("selectedPrinter"); selected = selectedPrinter.toString(); } }); this.add(selectedPrinter); StringBuilder javaScript = new StringBuilder(); javaScript.append("function findPrinters() {"); javaScript.append("\n"); javaScript.append(" var applet = document.jZebra;"); javaScript.append("\n"); javaScript.append(" if (applet != null) {"); javaScript.append("\n"); javaScript.append(" document.getElementById('"); javaScript.append(printerListDdc.getMarkupId()); javaScript.append("').disabled = false;"); javaScript.append("\n"); javaScript.append(" var listing = applet.getPrinters();"); javaScript.append("\n"); javaScript.append(" var printers = listing.split(',');\n"); javaScript.append(" var objHidden = document.getElementById('"); javaScript.append(selectedPrinter.getMarkupId()); javaScript.append("');\n"); javaScript.append("\n"); javaScript.append(" for ( var i in printers) {"); javaScript.append("\n"); javaScript.append(" if(objHidden.value == printers[i]) {\n"); javaScript.append(" document.getElementById('"); javaScript.append(printerListDdc.getMarkupId()); javaScript.append("').options[i] = new Option(printers[i], printers[i], true, true);\n"); javaScript.append(" } else {\n"); javaScript.append(" document.getElementById('"); javaScript.append(printerListDdc.getMarkupId()); javaScript.append("').options[i] = new Option(printers[i], printers[i], false, false);\n"); javaScript.append(" }\n"); javaScript.append(" }"); javaScript.append("\n"); javaScript.append(" } else {"); javaScript.append("\n"); javaScript.append(" document.getElementById('"); javaScript.append(printerListDdc.getMarkupId()); javaScript.append("').options[i] = new Option('N/A');"); javaScript.append("\n"); javaScript.append(" document.getElementById('"); javaScript.append(printerListDdc.getMarkupId()); javaScript.append("').disabled = true;"); javaScript.append("\n"); javaScript.append(" }"); javaScript.append("\n"); javaScript.append("}"); javaScript.append("\n"); javaScript.append("\n"); javaScript.append("function changeHiddenInput (objDropDown) {"); javaScript.append("\n"); javaScript.append(" var objHidden = document.getElementById('"); javaScript.append(selectedPrinter.getMarkupId()); javaScript.append("');\n"); javaScript.append(" objHidden.value = objDropDown.value;"); javaScript.append("\n"); javaScript.append(" callWicket(objDropDown.value);"); javaScript.append("}"); final Label script = new Label("script", javaScript.toString()); script.setOutputMarkupPlaceholderTag(true); script.add(new AttributeModifier("onload", "findPrinters()")); script.setEscapeModelStrings(false); // do not HTML escape JavaScript code this.add(script); }
From source file:com.axway.ats.testexplorer.pages.BasePage.java
License:Apache License
public BasePage(PageParameters parameters) { super(parameters); LOG = Logger.getLogger(this.getClass()); add(new Label("page_title", "Axway ATS Test Explorer - " + getPageName())); // check DB connection and sets the current DB Name getTESession().getDbReadConnection(); WebMarkupContainer topRightContent = new WebMarkupContainer("topRightContent"); add(topRightContent);//from www. j a v a2 s . c o m String dbName = getTESession().getDbName(); if (dbName == null || "".equals(dbName)) { topRightContent.add(new Label("dbName", "").setVisible(false)); topRightContent.add(new Label("machinesLink", "").setVisible(false)); topRightContent.add(new Label("runCopyLink", runCopyLinkModel).setVisible(false)); topRightContent.add(new Label("testcasesCopyLink", testcasesCopyLinkModel).setVisible(false)); topRightContent.add(new Label("representationLink", representationLinkModel).setVisible(false)); } else { String dbNameAndVersion = dbName; String dbVersion = getTESession().getDbVersion(); if (dbVersion != null) { dbNameAndVersion = dbNameAndVersion + ", v" + dbVersion; } topRightContent.add(new Label("dbName", "<div class=\"dbName\"><span style=\"color:#C8D5DF;\">Exploring database:</span> " + dbNameAndVersion + "</div>").setEscapeModelStrings(false)); topRightContent.add(new Label("machinesLink", "<a href=\"machines?dbname=" + dbName + "\" class=\"machinesLink\" target=\"_blank\"></a>") .setEscapeModelStrings(false)); runCopyLinkModel.setObject( "<a href=\"runCopy?dbname=" + dbName + "\" class=\"runCopyLink\" target=\"_blank\"></a>"); topRightContent.add(new Label("runCopyLink", runCopyLinkModel).setEscapeModelStrings(false)); testcasesCopyLinkModel.setObject("<a href=\"testcasesCopy?dbname=" + dbName + "\" class=\"testcasesCopyLink\" target=\"_blank\"></a>"); topRightContent.add(getTestcasesCopyButton()); representationLinkModel.setObject(createRepresentationLinkModelObject()); topRightContent .add(new Label("representationLink", representationLinkModel).setEscapeModelStrings(false)); } itemsCountLabel = new Label("itemsCount", new Model<Integer>() { private static final long serialVersionUID = 1L; @Override public Integer getObject() { return getTESession().getCompareContainer().size(); } }); itemsCountLabel.setOutputMarkupId(true); topRightContent.setVisible(!(this instanceof WelcomePage)); topRightContent.add(itemsCountLabel); FeedbackPanel feedbackPanel = new FeedbackPanel("feedback"); feedbackPanel.setOutputMarkupId(true); add(feedbackPanel); // add navigation panel add(new ListView<PagePojo>("navigation_links", navigationList) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<PagePojo> item) { final PagePojo pp = item.getModelObject(); if (pp.pageSuffix != null && !pp.pageName.endsWith("</span>")) { pp.pageName = pp.pageName + " <span class=\"locationName\">[" + pp.pageSuffix + "]</span>"; } item.add(new Link<Object>("navigation_link") { private static final long serialVersionUID = 1L; @Override protected CharSequence getURL() { // generate Bookmarkable link url return urlFor(pp.pageClass, pp.parameters); } @Override public void onClick() { // This link acts like Bookmarkable link and don't have a click handler. } }.add(new Label("navigation_link_name", pp.pageName).setEscapeModelStrings(false))); } }); add(new Label("navigation_current_page_name", getPageName())); add(getNavigationSuffixComponent()); add(getTestcaseNavigationButtons()); currentTestDetails(); // add child page TransparentWebMarkupContainer pageWrapper = new TransparentWebMarkupContainer("page_wrapper"); add(pageWrapper); if (TestExplorerUtils.extractPageParameter(parameters, "hacks") != null) { showTestcaseStatusChangeButtons = true; } add(timeOffsetField); add(dayLightSavingOnField); // AJAX handler for obtaining browser's time offset from UTC and current browser timestamp add(new AbstractDefaultAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void respond(AjaxRequestTarget target) { IRequestParameters request = RequestCycle.get().getRequest().getRequestParameters(); int timeOffset = request.getParameterValue("timeOffset").toInt(); TestExplorerSession teSession = (TestExplorerSession) Session.get(); teSession.setTimeOffset(timeOffset); teSession.setDayLightSavingOn(request.getParameterValue("dayLightSavingOn").toBoolean()); } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getDynamicExtraParameters().add("return {'timeOffset': $('#timeOffset').val(), " + "'dayLightSavingOn': $('#dayLightSavingOn').val() }"); } @Override public void renderHead(Component component, IHeaderResponse response) { // Date.prototype.getTimezoneOffset() returns negative value if the local time is ahead of UTC, // so we invert the result, before sending it to Wicket String getTimeOffsetScript = ";var timeOffset = $('#timeOffset');timeOffset.val(new Date().getTimezoneOffset()*60*1000*-1);" + ";var dayLightSavingOn = $('#dayLightSavingOn');dayLightSavingOn.val(isDayLightSavingOn());"; response.render(OnLoadHeaderItem.forScript(getCallbackScript().toString())); response.render(OnLoadHeaderItem.forScript(getTimeOffsetScript)); } }); }
From source file:com.axway.ats.testexplorer.pages.reports.testcase.TestcaseReportPage.java
License:Apache License
public TestcaseReportPage(PageParameters parameters) throws IOException { super(parameters); reportHomeFolder = getAbsolutePathOfClass(); reportHomeFolder = IoUtils.normalizeDirPath(reportHomeFolder); if (OperatingSystemType.getCurrentOsType().isWindows() && reportHomeFolder.startsWith(SYSTEM_FILE_SEPARATOR)) { reportHomeFolder = reportHomeFolder.substring(1); }/* www . j ava 2 s . c om*/ reportHomeFolder = reportHomeFolder.substring(0, reportHomeFolder.lastIndexOf(SYSTEM_FILE_SEPARATOR)); // the current folder path is encoded (e.g. ' ' = '%20'). We need to decode it reportHomeFolder = URLDecoder.decode(reportHomeFolder, "UTF-8"); add(timeOffsetField); add(dayLightSavingOnField); // AJAX handler for obtaining browser's time offset from UTC add(new AbstractDefaultAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void respond(AjaxRequestTarget target) { IRequestParameters request = RequestCycle.get().getRequest().getRequestParameters(); int timeOffset = request.getParameterValue("timeOffset").toInt(); TestExplorerSession teSession = (TestExplorerSession) Session.get(); teSession.setTimeOffset(timeOffset); teSession.setDayLightSavingOn(request.getParameterValue("dayLightSavingOn").toBoolean()); } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getDynamicExtraParameters().add("return {'timeOffset': $('#timeOffset').val()," + "'dayLightSavingOn': $('#dayLightSavingOn').val() }"); } @Override public void renderHead(Component component, IHeaderResponse response) { // Date.prototype.getTimezoneOffset() returns negative value if the local time is ahead of UTC, // so we invert the result, before sending it to Wicket String getTimeOffsetScript = ";var timeOffset = $('#timeOffset');timeOffset.val(new Date().getTimezoneOffset()*60*1000*-1);" + ";var dayLightSavingOn = $('#dayLightSavingOn');dayLightSavingOn.val(isDayLightSavingOn());"; response.render(OnLoadHeaderItem.forScript(getCallbackScript().toString())); response.render(OnLoadHeaderItem.forScript(getTimeOffsetScript)); } }); }
From source file:com.cubeia.games.poker.admin.wicket.pages.tournaments.scheduled.EditTournament.java
License:Open Source License
private void addPreviewSchedule(Form<ScheduledTournamentConfiguration> tournamentForm) { WebMarkupContainer pc = new WebMarkupContainer("previewContainer"); pc.setOutputMarkupId(true);/*from w w w. j a v a2 s .co m*/ final SchedulePreviewPanel previewContent = new SchedulePreviewPanel("previewContent"); previewContent.setOutputMarkupId(true); TournamentSchedule schedule = tournament.getSchedule(); if (schedule != null) { previewContent.setSchedule(schedule); } pcAjaxBehaviour = new AbstractDefaultAjaxBehavior() { @Override protected void respond(AjaxRequestTarget target) { IRequestParameters params = getRequestCycle().getRequest().getRequestParameters(); SimpleDateFormat sdf = new SimpleDateFormat(new DateTextField("dummy").getTextFormat()); String cron = params.getParameterValue("cron").toOptionalString(); int minInAnnounced = params.getParameterValue("announceMinutes").toInt(0); int minInRegistering = params.getParameterValue("registeringMinutes").toInt(0); int minAfterClose = params.getParameterValue("visibleMinutes").toInt(0); Date start = new Date(0); Date end = new Date(0); try { start = sdf.parse(params.getParameterValue("start").toString()); end = sdf.parse(params.getParameterValue("end").toString()); } catch (ParseException e) { log.warn("error parsing start/end date"); } updatePreviewValues(previewContent, cron, start, end, minInAnnounced, minInRegistering, minAfterClose); target.add(previewContent); } }; pc.add(pcAjaxBehaviour); pc.add(previewContent); tournamentForm.add(pc); }
From source file:com.evolveum.midpoint.gui.api.page.PageBase.java
License:Apache License
protected ModalWindow createModalWindow(final String id, IModel<String> title, int width, int height) { final ModalWindow modal = new ModalWindow(id); add(modal);//from www.j av a2s . co m modal.setResizable(false); modal.setTitle(title); modal.setCookieName(PageBase.class.getSimpleName() + ((int) (Math.random() * 100))); modal.setInitialWidth(width); modal.setWidthUnit("px"); modal.setInitialHeight(height); modal.setHeightUnit("px"); modal.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() { @Override public boolean onCloseButtonClicked(AjaxRequestTarget target) { return true; } }); modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { @Override public void onClose(AjaxRequestTarget target) { modal.close(target); } }); modal.add(new AbstractDefaultAjaxBehavior() { @Override public void renderHead(Component component, IHeaderResponse response) { response.render(OnDomReadyHeaderItem.forScript("Wicket.Window.unloadConfirmation = false;")); response.render(JavaScriptHeaderItem.forScript( "$(document).ready(function() {\n" + " $(document).bind('keyup', function(evt) {\n" + " if (evt.keyCode == 27) {\n" + getCallbackScript() + "\n" + " evt.preventDefault();\n" + " }\n" + " });\n" + "});", id)); } @Override protected void respond(AjaxRequestTarget target) { modal.close(target); } }); return modal; }
From source file:com.evolveum.midpoint.web.component.util.SimplePanel.java
License:Apache License
protected ModalWindow createModalWindow(final String id, IModel<String> title, int width, int height) { final ModalWindow modal = new ModalWindow(id); add(modal);//from ww w.j av a 2 s.co m modal.setResizable(false); modal.setTitle(title); modal.setCookieName(PageBase.class.getSimpleName() + ((int) (Math.random() * 100))); modal.setInitialWidth(width); modal.setWidthUnit("px"); modal.setInitialHeight(height); modal.setHeightUnit("px"); modal.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() { @Override public boolean onCloseButtonClicked(AjaxRequestTarget target) { return true; } }); modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { @Override public void onClose(AjaxRequestTarget target) { modal.close(target); } }); modal.add(new AbstractDefaultAjaxBehavior() { @Override public void renderHead(Component component, IHeaderResponse response) { response.render(OnDomReadyHeaderItem.forScript("Wicket.Window.unloadConfirmation = false;")); response.render(JavaScriptHeaderItem.forScript( "$(document).ready(function() {\n" + " $(document).bind('keyup', function(evt) {\n" + " if (evt.keyCode == 27) {\n" + getCallbackScript() + "\n" + " evt.preventDefault();\n" + " }\n" + " });\n" + "});", id)); } @Override protected void respond(AjaxRequestTarget target) { modal.close(target); } }); return modal; }
From source file:com.evolveum.midpoint.web.page.PageTemplate.java
License:Apache License
protected ModalWindow createModalWindow(final String id, IModel<String> title, int width, int height) { final ModalWindow modal = new ModalWindow(id); add(modal);/* w ww . j ava2 s . c o m*/ modal.setResizable(false); modal.setTitle(title); modal.setCookieName(PageTemplate.class.getSimpleName() + ((int) (Math.random() * 100))); modal.setInitialWidth(width); modal.setWidthUnit("px"); modal.setInitialHeight(height); modal.setHeightUnit("px"); modal.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() { @Override public boolean onCloseButtonClicked(AjaxRequestTarget target) { return true; } }); modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { @Override public void onClose(AjaxRequestTarget target) { modal.close(target); } }); modal.add(new AbstractDefaultAjaxBehavior() { @Override public void renderHead(Component component, IHeaderResponse response) { response.render(OnDomReadyHeaderItem.forScript("Wicket.Window.unloadConfirmation = false;")); response.render(JavaScriptHeaderItem.forScript( "$(document).ready(function() {\n" + " $(document).bind('keyup', function(evt) {\n" + " if (evt.keyCode == 27) {\n" + getCallbackScript() + "\n" + " evt.preventDefault();\n" + " }\n" + " });\n" + "});", id)); } @Override protected void respond(AjaxRequestTarget target) { modal.close(target); } }); return modal; }
From source file:com.google.code.jqwicket.dnd.DroppablePanel.java
License:Apache License
protected void initInternal() { super.add(new DroppableBehavior(newDroppableOptions())); super.add(new AbstractDefaultAjaxBehavior() { private static final long serialVersionUID = 1L; @Override//from w ww . ja v a2 s . co m protected void respond(AjaxRequestTarget target) { DraggableVisitor visitor = new DraggableVisitor(RequestCycle.get().getRequest() .getRequestParameters().getParameterValue("draggableId").toString()); getPage().visitChildren(DraggablePanel.class, visitor); if (visitor.getDraggable() != null && supports(visitor.getDraggable())) { onDrop(target, visitor.getDraggable()); } } @Override protected void onComponentTag(ComponentTag tag) { tag.put("rel", this.getCallbackUrl()); } }); }
From source file:com.google.code.jqwicket.DNDPage.java
License:Apache License
public DNDPage() { // Create accordion containing dummy products AccordionWebMarkupContainer accordion = new AccordionWebMarkupContainer("catalog"); for (Map.Entry<String, String> e : labels.entrySet()) { accordion.add(new Label(e.getKey(), e.getValue()) .add(JQBehaviors.draggable(new DraggableOptions().appendTo("body").helper("clone")))); }//from w w w. j a va 2s . co m add(accordion); // Create shopping cart webmarkup container WebMarkupContainer cartContainer = new WebMarkupContainer("cartContainer"); add(cartContainer); // added ajax behavior to the shopping cart that responds to the page // with simple javascript alert final AbstractDefaultAjaxBehavior behave = new AbstractDefaultAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void respond(AjaxRequestTarget target) { String product = RequestCycle.get().getRequest().getRequestParameters().getParameterValue("product") .toString(); if (Utils.isNotBlank(product)) target.appendJavaScript("alert('product \"" + product + "\" added on the serverside!')"); } }; cartContainer.add(behave); // make shopping cart container droppable // and implement onDropEvent to send the ajax request to the shopping // cart! Map<String, Object> ajaxGetParams = new MapBuilder<String, Object>() .add("product", js("ui.draggable.text()")).build(); DroppableOptions options = new DroppableOptions().activeClass("ui-state-default") .hoverClass("ui-state-hover").accept(":not(.ui-sortable-helper)") .dropEvent($f($this().find(S.clazz("placeholder")).remove(), $("<li></li>").text(_raw("ui.draggable.text()")).appendTo(_raw("this")), wicketAjaxGet(behave, ajaxGetParams)// ).withParams("event", "ui") // ); cartContainer.add(JQBehaviors.droppable(options)); }