List of usage examples for org.apache.wicket.ajax AjaxEventBehavior AjaxEventBehavior
public AjaxEventBehavior(String event)
From source file:org.onehippo.forge.settings.management.config.brokenlinks.BrokenLinksCheckerConfigPanel.java
License:Apache License
public BrokenLinksCheckerConfigPanel(IPluginContext context, IPluginConfig config) { super(context, config, new ResourceModel("title")); brokenLinksCheckerConfigModel = new BrokenLinksCheckerConfigModel(); BrokenlinksCheckerConfig brokenlinksCheckerConfig = brokenLinksCheckerConfigModel.getObject(); checkerContentUUID = brokenlinksCheckerConfig.getStartPathUUID(); checkerStartPath = brokenlinksCheckerConfig.getStartPath(); RadioGroup linksCheckEnabledRadioGroup = new RadioGroup("linkscheck-enabledgroup", new PropertyModel(brokenLinksCheckerConfigModel, "enabled")); linksCheckEnabledRadioGroup.add(new Radio("linkscheck-disabled", new Model(Boolean.FALSE))); linksCheckEnabledRadioGroup.add(new Radio("linkscheck-enabled", new Model(Boolean.TRUE))); TextField cronExpressionField = new TextField("linkscheck-cronexpression", new PropertyModel(brokenLinksCheckerConfigModel, "cronExpression")); TextField brokenlinksCheckConnectionTimeoutField = new TextField("linkscheck-connectionTimeout", new PropertyModel(brokenLinksCheckerConfigModel, "connectionTimeout")); TextField brokenlinksCheckSocketTimeoutField = new TextField("linkscheck-socketTimeout", new PropertyModel(brokenLinksCheckerConfigModel, "socketTimeout")); TextField brokenlinksCheckNrHttpThreads = new TextField("linkscheck-nrHttpThreads", new PropertyModel(brokenLinksCheckerConfigModel, "nrHttpThreads")); TextField brokenlinksUrlExcludes = new TextField("linkscheck-urlExcludes", new PropertyModel(brokenLinksCheckerConfigModel, "urlExcludes")); final TextField brokenlinksCheckStartPath = new TextField("linkscheck-startPath", new PropertyModel(this, "checkerStartPath")); final Image locationPickLink = new Image("linkcheck-startPath-location-search", new PackageResourceReference(BrokenLinksCheckerConfigPanel.class, "folder-choose.png")) { private static final long serialVersionUID = 1L; @Override//from w ww .j ava 2 s .com public boolean isVisible() { return true; } }; brokenlinksCheckStartPath.setOutputMarkupId(true); brokenlinksCheckStartPath.add(createSimpleAjaxChangeBehavior(brokenlinksCheckStartPath)); final PropertyModel<String> contentUUID = new PropertyModel<String>(this, "checkerContentUUID"); final IDialogFactory dialogFactory = new IDialogFactory() { private static final long serialVersionUID = 1L; @Override public AbstractDialog<String> createDialog() { return new LinkPickerDialog(getContext(), getConfig(), contentUUID) { private static final long serialVersionUID = 1L; @Override public void render(PluginRequestTarget target) { target.add(brokenlinksCheckStartPath); super.render(target); } @Override protected IModel<Node> getFolderModel() { return super.getFolderModel(); } @Override protected void saveNode(Node node) { try { getModel().setObject(node.getIdentifier()); checkerStartPath = node.getPath(); checkerContentUUID = node.getIdentifier(); brokenlinksCheckStartPath.setModel(new PropertyModel<String>( BrokenLinksCheckerConfigPanel.this, "checkerStartPath")); } catch (RepositoryException ex) { error(ex.getMessage()); } } }; } }; final DialogAction dialogAction = new DialogAction(dialogFactory, getDialogService()); locationPickLink.add(new AjaxEventBehavior("onclick") { private static final long serialVersionUID = 1L; @Override protected void onEvent(final AjaxRequestTarget target) { dialogAction.execute(); } }); add(linksCheckEnabledRadioGroup); add(cronExpressionField); add(locationPickLink); add(brokenlinksCheckConnectionTimeoutField); add(brokenlinksCheckSocketTimeoutField); add(brokenlinksCheckNrHttpThreads); add(brokenlinksCheckStartPath); add(brokenlinksUrlExcludes); }
From source file:org.onexus.ui.api.utils.panels.HelpMark.java
License:Apache License
public HelpMark(final String panelId, final String title, final String displayLabel, final String helpText) { super(panelId); // Add modal window final ModalWindow modal = new ModalWindow("modalWindowEmbeeded"); modal.setTitle(title);// ww w .j av a2 s .c om modal.setInitialWidth(700); modal.setInitialHeight(500); add(modal); // Add mark label final WebMarkupContainer container = new WebMarkupContainer("displayLabel"); container.add(new Label("label", displayLabel)); add(container); // Add question mark icon Image img = null; container.add(img = new Image("imageHelp", Icons.HELP) { @Override protected boolean shouldAddAntiCacheParameter() { return false; } }); img.add(new AjaxEventBehavior("onclick") { @Override protected void onEvent(final AjaxRequestTarget target) { if (modal != null) { modal.setInitialWidth(700); modal.setInitialHeight(500); modal.setContent(new HelpContentPanel(modal.getContentId(), helpText)); modal.show(target); } } }); // Visible only if there is some setVisible(helpText != null); }
From source file:org.onexus.website.api.pages.browser.layouts.ButtonWidget.java
License:Apache License
public ButtonWidget(String id, final WidgetConfig widgetConfig, final IModel<BrowserPageStatus> pageModel) { super(id);//w w w. j a v a2 s.c o m onEventFireUpdate(EventQueryUpdate.class); this.widgetConfig = widgetConfig; this.pageModel = pageModel; this.widgetModal = new WebMarkupContainer("widgetModal"); widgetModal.setOutputMarkupId(true); widgetModal.add(new EmptyPanel("widget")); widgetModal.add(new AjaxLink<String>("close") { @Override public void onClick(AjaxRequestTarget target) { Component widget = widgetModal.get("widget"); if (widget instanceof Widget) { ((Widget) widget).onClose(target); } target.appendJavaScript("$('#" + widgetModal.getMarkupId() + "').modal('hide')"); } }); if (!Strings.isEmpty(widgetConfig.getWidth())) { int width = Integer.valueOf(widgetConfig.getWidth()); int marginLeft = width / 2; widgetModal.add( new AttributeModifier("style", "width: " + width + "px; margin-left: -" + marginLeft + "px;")); } add(widgetModal); Label button = new Label("button", new PropertyModel<String>(this, "buttonText")); button.setEscapeModelStrings(false); button.setOutputMarkupId(true); if (widgetConfig.getTitle() != null) { button.add(new AttributeModifier("title", widgetConfig.getTitle())); button.add(new AttributeModifier("rel", "tooltip")); widgetModal.add(new Label("modalHeader", widgetConfig.getTitle())); } else { widgetModal.add(new Label("modalHeader", "")); } button.add(new AjaxEventBehavior("onclick") { @Override protected void onEvent(AjaxRequestTarget target) { Widget<?, ?> widgetPanel = getWidgetManager().create("widget", new WidgetModel(widgetConfig.getId(), pageModel)); widgetModal.addOrReplace(widgetPanel); target.add(widgetModal); target.appendJavaScript("$('#" + widgetModal.getMarkupId() + "').modal('show')"); } }); add(button); }
From source file:org.onexus.website.api.utils.panels.HelpMark.java
License:Apache License
public HelpMark(final String panelId, final String title, final String displayLabel, final String helpText) { super(panelId); // Add modal window final ModalWindow modal = new ModalWindow("modalWindowEmbeeded"); modal.setTitle(title);/*from w w w.j a v a 2 s . co m*/ modal.setInitialWidth(700); modal.setInitialHeight(500); add(modal); // Add mark label final WebMarkupContainer container = new WebMarkupContainer("displayLabel"); container.add(new Label("label", displayLabel)); add(container); // Add question mark icon Image img = new Image("imageHelp", Icons.HELP) { @Override protected boolean shouldAddAntiCacheParameter() { return false; } }; container.add(img); img.add(new AjaxEventBehavior("onclick") { @Override protected void onEvent(final AjaxRequestTarget target) { if (modal != null) { modal.setInitialWidth(700); modal.setInitialHeight(500); modal.setContent(new HelpContentPanel(modal.getContentId(), helpText)); modal.show(target); } } }); // Visible only if there is some setVisible(helpText != null); }
From source file:org.onexus.website.api.utils.panels.ondomready.OnDomReadyPanel.java
License:Apache License
public OnDomReadyPanel(String id, IModel<?> model) { super(id, model); setOutputMarkupId(true);//from w w w . java 2 s . c om add(new AjaxEventBehavior("domready") { @Override protected void onEvent(AjaxRequestTarget target) { MarkupContainer parent = OnDomReadyPanel.this.getParent(); Panel newPanel = onDomReadyPanel(OnDomReadyPanel.this.getId()); newPanel.setOutputMarkupId(true); parent.addOrReplace(newPanel); target.add(newPanel); } }); add(new Image("loading", LOADING_IMAGE)); }
From source file:org.opensingular.form.wicket.mapper.attachment.list.AttachmentListMapper.java
License:Apache License
@Override public void buildView(WicketBuildContext ctx) { final FileListUploadPanel comp = new FileListUploadPanel(MULTIPLE_HIDDEN_UPLOAD_FIELD_ID, (IModel<SIList<SIAttachment>>) ctx.getModel(), ctx); ctx.getContainer().appendTag("div", comp); final WicketBuildContext.OnFieldUpdatedListener listener = new WicketBuildContext.OnFieldUpdatedListener(); comp.add(new AjaxEventBehavior(SINGULAR_PROCESS_EVENT) { @Override/*from w w w . j a v a 2 s.co m*/ protected void onEvent(AjaxRequestTarget target) { listener.onProcess(comp, target, ctx.getModel()); } }); }
From source file:org.opensingular.form.wicket.mapper.search.SearchModalPanel.java
License:Apache License
private Button buildModelTrigger() { final Button modalTrigger = new Button(MODAL_TRIGGER_ID); modalTrigger.add(new AjaxEventBehavior("click") { @Override/* w ww . j a va 2 s . c o m*/ protected void onEvent(AjaxRequestTarget target) { modal.show(target); } }); return modalTrigger; }
From source file:org.patientview.radar.web.panels.DiagnosisGeneMutationPanel.java
License:Open Source License
public DiagnosisGeneMutationPanel(final String id, int i, CompoundPropertyModel model, final IModel<Boolean> otherDetailsVisibilityModel, final IModel<Boolean> moreDetailsVisibilityModel, final List<Component> componentsToUpdateList) { super(id);//from w ww . j av a 2 s .c o m // Add the field for mutationYorN RadioGroup<Diagnosis.MutationYorN> mutationYorN = new RadioGroup<Diagnosis.MutationYorN>("mutationYorN", model.bind("mutationYorN" + i)); Radio<Diagnosis.MutationYorN> y = new Radio<Diagnosis.MutationYorN>("y", new Model<Diagnosis.MutationYorN>(Diagnosis.MutationYorN.Y)); mutationYorN.add(y); y.add(new AjaxEventBehavior("onClick") { @Override protected void onEvent(AjaxRequestTarget target) { if (id.equals(DiagnosisPanel.OTHER_CONTAINER_ID)) { otherDetailsVisibilityModel.setObject(true); } else { moreDetailsVisibilityModel.setObject(true); } for (Component component : componentsToUpdateList) { if (component.isVisibleInHierarchy()) { target.add(component); } } } }); Radio<Diagnosis.MutationYorN> n = new Radio<Diagnosis.MutationYorN>("n", new Model<Diagnosis.MutationYorN>(Diagnosis.MutationYorN.N)); mutationYorN.add(n); n.add(new AjaxEventBehavior("onClick") { @Override protected void onEvent(AjaxRequestTarget target) { if (id.equals(DiagnosisPanel.OTHER_CONTAINER_ID)) { otherDetailsVisibilityModel.setObject(false); for (Component component : componentsToUpdateList) { if (component.isVisibleInHierarchy()) { target.add(component); } } } } }); add(mutationYorN); // Add the field for mutationSorSN RadioGroup<Diagnosis.MutationSorSN> mutationSorSN = new RadioGroup<Diagnosis.MutationSorSN>("mutationSorSN", model.bind("mutationSorSN" + i)); mutationSorSN.add(new Radio<Diagnosis.MutationSorSN>("s", new Model<Diagnosis.MutationSorSN>(Diagnosis.MutationSorSN.S))); mutationSorSN.add(new Radio<Diagnosis.MutationSorSN>("sn", new Model<Diagnosis.MutationSorSN>(Diagnosis.MutationSorSN.SN))); add(mutationSorSN); }
From source file:org.patientview.radar.web.panels.NonAlportGeneticsPanel.java
License:Open Source License
public NonAlportGeneticsPanel(final String id, final Patient patient) { super(id);//from www .ja va 2 s . c o m setOutputMarkupId(true); setOutputMarkupPlaceholderTag(true); Genetics genetics = null; if (patient.hasValidId()) { genetics = geneticsManager.get(patient.getRadarNo()); } if (genetics == null) { genetics = new Genetics(); genetics.setRadarNo(patient.getRadarNo()); } // main model for this tab final IModel<Genetics> model = new Model<Genetics>(genetics); // components to update on ajax refresh final List<Component> componentsToUpdateList = new ArrayList<Component>(); // general feedback for messages that are not to do with a certain component in the form final FeedbackPanel formFeedback = new FeedbackPanel("formFeedbackPanel"); formFeedback.setOutputMarkupId(true); formFeedback.setOutputMarkupPlaceholderTag(true); componentsToUpdateList.add(formFeedback); Form<Genetics> form = new Form<Genetics>("form", new CompoundPropertyModel<Genetics>(model)) { @Override protected void onSubmit() { Genetics genetics = getModelObject(); if (genetics.getLabWhereTestWasDone() != null && genetics.getLabWhereTestWasDone().length() > 150) { error("Laboratory where sent/done is limited to 150 characters."); } // requirement is to limit to 20 lines of text -> 130 chars per line ~ 2500 chars if (genetics.getWhatResultsShowed() != null && genetics.getWhatResultsShowed().length() > 2500) { error("Laboratory where sent/done is limited to 2500 characters."); } if (genetics.getTestsDone() == null) { error("Please select if a sample been sent for Genetic analysis"); } if (Genetics.TestsDone.YES_IN_THIS_PATIENT.equals(genetics.getTestsDone())) { if (genetics.getDateSent() == null) { error("Please select Date Sent if a sample been sent."); } } if (!hasError()) { genetics.setRadarNo(patient.getRadarNo()); geneticsManager.save(genetics); } } }; add(form); // have to set the generic feedback panel to only pick up msgs for them form ComponentFeedbackMessageFilter filter = new ComponentFeedbackMessageFilter(form); formFeedback.setFilter(filter); form.add(formFeedback); // add the patient detail bar to the tab PatientDetailPanel patientDetail = new PatientDetailPanel("patientDetail", patient, "Genetics"); patientDetail.setOutputMarkupId(true); form.add(patientDetail); componentsToUpdateList.add(patientDetail); // Date picker final DateTextField dateSent = new RadarRequiredDateTextField("dateSent", form, componentsToUpdateList); componentsToUpdateList.add(dateSent); MarkupContainer dateSentLabel = new WebMarkupContainer("dateSentLabel") { @Override public boolean isVisible() { Genetics genetics = model.getObject(); if (genetics.getTestsDone() == null || genetics.getTestsDone().equals(Genetics.TestsDone.NO)) { return false; } else { return true; } } }; dateSentLabel.setOutputMarkupId(true); dateSentLabel.add(dateSent); dateSentLabel.setOutputMarkupPlaceholderTag(true); form.add(dateSentLabel); componentsToUpdateList.add(dateSentLabel); // if (genetics.getTestsDone() == null || genetics.getTestsDone().equals(Genetics.TestsDone.NO)){ // dateSent.setVisible(false); // dateSentLabel.setVisible(false); // } RadioGroup<Genetics.TestsDone> testsDoneRadioGroup = new RadioGroup<Genetics.TestsDone>("testsDone"); form.add(testsDoneRadioGroup); Radio testsDoneNo = new Radio<Genetics.TestsDone>("testsDoneNo", new Model<Genetics.TestsDone>(Genetics.TestsDone.NO)); testsDoneRadioGroup.add(testsDoneNo); testsDoneNo.add(new AjaxEventBehavior("onchange") { @Override protected void onEvent(AjaxRequestTarget target) { model.getObject().setTestsDone(Genetics.TestsDone.NO); target.add(componentsToUpdateList.toArray(new Component[componentsToUpdateList.size()])); } }); Radio testsDoneYes = new Radio<Genetics.TestsDone>("testsDoneYes", new Model<Genetics.TestsDone>(Genetics.TestsDone.YES_IN_THIS_PATIENT)); testsDoneRadioGroup.add(testsDoneYes); testsDoneYes.add(new AjaxEventBehavior("onchange") { @Override protected void onEvent(AjaxRequestTarget target) { model.getObject().setTestsDone(Genetics.TestsDone.YES_IN_THIS_PATIENT); target.add(componentsToUpdateList.toArray(new Component[componentsToUpdateList.size()])); } }); form.add(new TextArea<String>("labWhereTestWasDone")); form.add(new TextField<String>("referenceNumber")); form.add(new TextArea<String>("whatResultsShowed")); Label successMessageTop = RadarComponentFactory.getSuccessMessageLabel("successMessageTop", form, componentsToUpdateList); Label errorMessageTop = RadarComponentFactory.getErrorMessageLabel("errorMessageTop", form, componentsToUpdateList); Label successMessageBottom = RadarComponentFactory.getSuccessMessageLabel("successMessageBottom", form, componentsToUpdateList); Label errorMessageBottom = RadarComponentFactory.getErrorMessageLabel("errorMessageBottom", form, componentsToUpdateList); form.add(new AjaxSubmitLink("saveTop") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { ComponentHelper.updateComponentsIfParentIsVisible(target, componentsToUpdateList); target.appendJavaScript(RadarApplication.FORM_IS_DIRTY_FALSE_SCRIPT); target.add(formFeedback); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { ComponentHelper.updateComponentsIfParentIsVisible(target, componentsToUpdateList); target.add(formFeedback); } }); form.add(new AjaxSubmitLink("saveBottom") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { ComponentHelper.updateComponentsIfParentIsVisible(target, componentsToUpdateList); target.appendJavaScript(RadarApplication.FORM_IS_DIRTY_FALSE_SCRIPT); target.add(formFeedback); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { ComponentHelper.updateComponentsIfParentIsVisible(target, componentsToUpdateList); target.add(formFeedback); } }); }
From source file:org.projectforge.plugins.ffp.wicket.FFPDebtListPage.java
License:Open Source License
@Override public List<IColumn<FFPDebtDO, String>> createColumns(final WebPage returnToPage, final boolean sortable) { final List<IColumn<FFPDebtDO, String>> columns = new ArrayList<>(); columns.add(new PropertyColumn<FFPDebtDO, String>(new ResourceModel("plugins.ffp.eventDate"), "event.eventDate")); columns.add(new PropertyColumn<FFPDebtDO, String>(new ResourceModel("plugins.ffp.title"), "event.title")); columns.add(new PropertyColumn<FFPDebtDO, String>(new ResourceModel("plugins.ffp.from"), "from.fullname")); columns.add(new PropertyColumn<FFPDebtDO, String>(new ResourceModel("plugins.ffp.to"), "to.fullname")); columns.add(/*from w ww . j a v a 2s.c om*/ new CellItemListenerPropertyColumn<FFPDebtDO>(FFPDebtDO.class, "plugins.ffp.value", "value", null)); columns.add(new CellItemListenerPropertyColumn<FFPDebtDO>(FFPDebtDO.class, "plugins.ffp.approvedByFrom", "approvedByFrom", null) { private static final long serialVersionUID = 3672950740712610620L; @Override public void populateItem(Item<ICellPopulator<FFPDebtDO>> item, String componentId, IModel<FFPDebtDO> rowModel) { FFPDebtDO debt = rowModel.getObject(); Button button = new Button(ButtonPanel.BUTTON_ID); if (debt.getFrom().equals(ThreadLocalUserContext.getUser())) { button.setOutputMarkupId(true); button.add(new AjaxEventBehavior("click") { @Override protected void onEvent(AjaxRequestTarget target) { if (debt.isApprovedByFrom() == false) { eventService.updateDebtFrom(debt); button.add(AttributeModifier.append("class", ButtonType.GREEN.getClassAttrValue())); button.addOrReplace( new Label("title", I18nHelper.getLocalizedMessage("plugins.ffp.payed"))); target.add(button); } } }); } String label = debt.isApprovedByFrom() ? I18nHelper.getLocalizedMessage("plugins.ffp.payed") : I18nHelper.getLocalizedMessage("plugins.ffp.notPayed"); ButtonType bt = debt.isApprovedByFrom() ? ButtonType.GREEN : ButtonType.RED; ButtonPanel buttonPanel = new ButtonPanel(componentId, label, button, bt); item.add(buttonPanel); } }); columns.add(new CellItemListenerPropertyColumn<FFPDebtDO>(FFPDebtDO.class, I18nHelper.getLocalizedMessage("plugins.ffp.approvedByTo"), "approvedByTo", null) { private static final long serialVersionUID = 367295074123610620L; @Override public void populateItem(Item<ICellPopulator<FFPDebtDO>> item, String componentId, IModel<FFPDebtDO> rowModel) { FFPDebtDO debt = rowModel.getObject(); Button button = new Button(ButtonPanel.BUTTON_ID); if (debt.isApprovedByFrom() && debt.getTo().equals(ThreadLocalUserContext.getUser())) { button.setOutputMarkupId(true); button.add(new AjaxEventBehavior("click") { @Override protected void onEvent(AjaxRequestTarget target) { if (debt.isApprovedByTo() == false) { eventService.updateDebtTo(debt); button.add(AttributeModifier.append("class", ButtonType.GREEN.getClassAttrValue())); button.addOrReplace( new Label("title", I18nHelper.getLocalizedMessage("plugins.ffp.approved"))); target.add(button); } } }); } String label = debt.isApprovedByTo() ? I18nHelper.getLocalizedMessage("plugins.ffp.approved") : I18nHelper.getLocalizedMessage("plugins.ffp.notApproved"); ButtonType bt = debt.isApprovedByTo() ? ButtonType.GREEN : ButtonType.RED; ButtonPanel buttonPanel = new ButtonPanel(componentId, label, button, bt); item.add(buttonPanel); } }); return columns; }