List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink AjaxLink
public AjaxLink(final String id)
From source file:de.lichtflut.glasnost.is.components.devops.items.DevOpsItemPanel.java
License:Apache License
/** * Adds an Ajaxlink to fold/unfold further info *///from www . ja v a2 s .c o m private void addMoreLink(final String id, final IModel<PerceptionItem> model) { final IModel<String> labelModel = new Model<String>(" "); AjaxLink<String> moreLink = new AjaxLink<String>(id) { @Override public void onClick(final AjaxRequestTarget target) { if (Boolean.TRUE == expanded.getObject()) { expanded.setObject(false); // labelModel.setObject("+"); } else { expanded.setObject(true); // labelModel.setObject("-"); } RBAjaxTarget.add(DevOpsItemPanel.this); } @Override protected IAjaxCallDecorator getAjaxCallDecorator() { return new AjaxCancelEventBubbleCallDecorator(); } @Override protected void onComponentTag(final ComponentTag tag) { super.onComponentTag(tag); if (Boolean.TRUE == expanded.getObject()) { tag.put("class", "devops-fold-action fold"); } else { tag.put("class", "devops-fold-action unfold"); } } }; moreLink.add(new Label("linkLabel", labelModel)); add(moreLink); }
From source file:de.lichtflut.glasnost.is.components.devops.perceptions.PerceptionManagementPanel.java
License:Apache License
private AbstractLink createNewLink() { return new AjaxLink<Void>("createPerceptionLink") { @Override// w w w. ja v a 2s .com public void onClick(final AjaxRequestTarget target) { PageParameters parameters = new PageParameters(); parameters.add(DisplayMode.PARAMETER, DisplayMode.CREATE); setResponsePage(PerceptionEditPage.class, parameters); } }; }
From source file:de.lichtflut.glasnost.is.components.devops.perceptions.PerceptionManagementPanel.java
License:Apache License
private AbstractLink createPerceptionWizzardLink(final String id) { return new AjaxLink<Void>(id) { @Override/*from ww w .ja va 2s . com*/ public void onClick(final AjaxRequestTarget target) { final DialogHoster dialogHoster = findParent(DialogHoster.class); dialogHoster.openDialog(new CreatePerceptionsWizzardDialog(dialogHoster.getDialogID()) { @Override protected void onUpdate(final AjaxRequestTarget target, final Form<?> form) { dialogHoster.closeDialog(this); } }); } }; }
From source file:de.lichtflut.glasnost.is.components.devops.perceptions.PerceptionManagementPanel.java
License:Apache License
private AjaxLink<?> createDeleteLink(final IModel<Perception> model) { final AjaxLink<?> link = new AjaxLink<Void>("delete") { @Override/*from w ww . ja v a 2s. c o m*/ public void onClick(final AjaxRequestTarget target) { openConfirmationDialog(model); } private void openConfirmationDialog(final IModel<Perception> model) { final String confirmation = getString("dialog.confirmation.delete") + " '" + model.getObject().getID() + "'"; final DialogHoster hoster = findParent(DialogHoster.class); hoster.openDialog(new ConfirmationDialog(hoster.getDialogID(), Model.of(confirmation)) { @Override public void onConfirm() { removePerception(model); send(getPage(), Broadcast.BREADTH, new ModelChangeEvent<Void>(ModelChangeEvent.PERCEPTION)); } @Override public void onCancel() { hoster.closeDialog(this); } }); } }; return link; }
From source file:de.lichtflut.glasnost.is.components.devops.perceptions.PerceptionManagementPanel.java
License:Apache License
private AjaxLink<?> createViewLink(final IModel<Perception> model) { return new AjaxLink<Void>("view") { @Override/*w ww . j av a 2 s .co m*/ public void onClick(final AjaxRequestTarget target) { PageParameters parameters = new PageParameters(); parameters.add(CommonParams.PARAM_RESOURCE_ID, model.getObject().toURI()); parameters.add(DisplayMode.PARAMETER, DisplayMode.VIEW); setResponsePage(PerceptionDisplayPage.class, parameters); } }; }
From source file:de.lichtflut.glasnost.is.components.devops.perceptions.PerceptionManagementPanel.java
License:Apache License
private AjaxLink<?> createUpLink(final IModel<Perception> model, final IModel<List<Perception>> perceptions) { final AjaxLink<?> link = new AjaxLink<Void>("up") { @Override/* w w w . j av a2 s . c o m*/ public void onClick(final AjaxRequestTarget target) { swapAndStore(model, perceptions, -1); update(); } }; return link; }
From source file:de.lichtflut.glasnost.is.components.devops.perceptions.PerceptionManagementPanel.java
License:Apache License
private AjaxLink<?> createDownLink(final IModel<Perception> model, final IModel<List<Perception>> perceptions) { final AjaxLink<?> link = new AjaxLink<Void>("down") { @Override/*from w ww. j a v a 2 s . co m*/ public void onClick(final AjaxRequestTarget target) { swapAndStore(model, perceptions, +1); update(); } }; return link; }
From source file:de.tudarmstadt.ukp.clarin.webanno.webapp.page.annotation.AnnotationPage.java
License:Apache License
public AnnotationPage() { editor = new AnnotationDetailEditorPanel("annotationDetailEditorPanel", new Model<BratAnnotatorModel>(bModel)) { private static final long serialVersionUID = 2857345299480098279L; @Override//from w w w . j a v a2 s .com protected void onChange(AjaxRequestTarget aTarget, BratAnnotatorModel aBModel) { aTarget.addChildren(getPage(), FeedbackPanel.class); try { annotator.bratRender(aTarget, getCas(aBModel)); } catch (UIMAException | ClassNotFoundException | IOException e) { LOG.info("Error reading CAS " + e.getMessage()); error("Error reading CAS " + e.getMessage()); return; } annotator.bratRenderHighlight(aTarget, aBModel.getSelection().getAnnotation()); annotator.onChange(aTarget, aBModel); } @Override protected void onAutoForward(AjaxRequestTarget aTarget, BratAnnotatorModel aBModel) { try { annotator.autoForward(aTarget, getCas(aBModel)); } catch (UIMAException | ClassNotFoundException | IOException | BratAnnotationException e) { LOG.info("Error reading CAS " + e.getMessage()); error("Error reading CAS " + e.getMessage()); return; } } }; editor.setOutputMarkupId(true); add(editor); annotator = new BratAnnotator("embedder1", new Model<BratAnnotatorModel>(bModel), editor) { private static final long serialVersionUID = 7279648231521710155L; @Override public void onChange(AjaxRequestTarget aTarget, BratAnnotatorModel aBratAnnotatorModel) { bModel = aBratAnnotatorModel; aTarget.add(numberOfPages); } @Override public void renderHead(IHeaderResponse aResponse) { super.renderHead(aResponse); // If the page is reloaded in the browser and a document was already open, we need // to render it. We use the "later" commands here to avoid polluting the Javascript // header items with document data and because loading times are not that critical // on a reload. if (getModelObject().getProject() != null) { // We want to trigger a late rendering only on a page reload, but not on a // Ajax request. if (!aResponse.getResponse().getClass().getName().endsWith("AjaxResponse")) { aResponse.render(OnLoadHeaderItem.forScript(bratInitLaterCommand())); aResponse.render(OnLoadHeaderItem.forScript(bratRenderLaterCommand())); } } } }; // This is an Annotation Operation, set model to ANNOTATION mode bModel.setMode(Mode.ANNOTATION); add(annotator); add(documentNamePanel = (DocumentNamePanel) new DocumentNamePanel("documentNamePanel", new Model<BratAnnotatorModel>(bModel)).setOutputMarkupId(true)); numberOfPages = new Label("numberOfPages", new Model<String>()); numberOfPages.setOutputMarkupId(true); add(numberOfPages); final ModalWindow openDocumentsModal; add(openDocumentsModal = new ModalWindow("openDocumentsModal")); openDocumentsModal.setOutputMarkupId(true); openDocumentsModal.setInitialWidth(500); openDocumentsModal.setInitialHeight(300); openDocumentsModal.setResizable(true); openDocumentsModal.setWidthUnit("px"); openDocumentsModal.setHeightUnit("px"); openDocumentsModal.setTitle("Open document"); openDocumentsModal.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() { private static final long serialVersionUID = -5423095433535634321L; @Override public boolean onCloseButtonClicked(AjaxRequestTarget aTarget) { closeButtonClicked = true; return true; } }); add(new AjaxLink<Void>("showOpenDocumentModal") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget aTarget) { editor.reset(aTarget); closeButtonClicked = false; openDocumentsModal.setContent(new OpenModalWindowPanel(openDocumentsModal.getContentId(), bModel, openDocumentsModal, Mode.ANNOTATION) { private static final long serialVersionUID = -3434069761864809703L; @Override protected void onCancel(AjaxRequestTarget aTarget) { closeButtonClicked = true; }; }); openDocumentsModal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = -1746088901018629567L; @Override public void onClose(AjaxRequestTarget target) { // A hack, the dialog opens for the first time, and if no document is // selected window will be "blind down". Something in the brat js causes // this! if (bModel.getProject() == null || bModel.getDocument() == null) { setResponsePage(WelcomePage.class); } // Dialog was cancelled rather that a document was selected. if (closeButtonClicked) { return; } loadDocumentAction(target); String username = SecurityContextHolder.getContext().getAuthentication().getName(); User user = userRepository.get(username); editor.setEnabled( !FinishImage.isFinished(new Model<BratAnnotatorModel>(bModel), user, repository)); } }); // target.appendJavaScript("Wicket.Window.unloadConfirmation = false;"); openDocumentsModal.show(aTarget); } }); add(new AnnotationLayersModalPanel("annotationLayersModalPanel", new Model<BratAnnotatorModel>(bModel), editor) { private static final long serialVersionUID = -4657965743173979437L; @Override protected void onChange(AjaxRequestTarget aTarget) { try { JCas jCas = getJCas(); annotator.bratRender(aTarget, jCas); updateSentenceAddress(jCas, aTarget); } catch (UIMAException | ClassNotFoundException | IOException e) { LOG.info("Error reading CAS " + e.getMessage()); error("Error reading CAS " + e.getMessage()); return; } } }); add(new ExportModalPanel("exportModalPanel", new Model<BratAnnotatorModel>(bModel))); // Show the previous document, if exist add(new AjaxLink<Void>("showPreviousDocument") { private static final long serialVersionUID = 7496156015186497496L; /** * Get the current beginning sentence address and add on it the size of the display * window */ @Override public void onClick(AjaxRequestTarget aTarget) { editor.reset(aTarget); // List of all Source Documents in the project List<SourceDocument> listOfSourceDocuements = repository.listSourceDocuments(bModel.getProject()); String username = SecurityContextHolder.getContext().getAuthentication().getName(); User user = userRepository.get(username); List<SourceDocument> sourceDocumentsinIgnorState = new ArrayList<SourceDocument>(); for (SourceDocument sourceDocument : listOfSourceDocuements) { if (repository.existsAnnotationDocument(sourceDocument, user) && repository.getAnnotationDocument(sourceDocument, user).getState() .equals(AnnotationDocumentState.IGNORE)) { sourceDocumentsinIgnorState.add(sourceDocument); } } listOfSourceDocuements.removeAll(sourceDocumentsinIgnorState); // Index of the current source document in the list int currentDocumentIndex = listOfSourceDocuements.indexOf(bModel.getDocument()); // If the first the document if (currentDocumentIndex == 0) { aTarget.appendJavaScript("alert('This is the first document!')"); return; } bModel.setDocumentName(listOfSourceDocuements.get(currentDocumentIndex - 1).getName()); bModel.setDocument(listOfSourceDocuements.get(currentDocumentIndex - 1)); loadDocumentAction(aTarget); } }.add(new InputBehavior(new KeyType[] { KeyType.Shift, KeyType.Page_up }, EventType.click))); // Show the next document if exist add(new AjaxLink<Void>("showNextDocument") { private static final long serialVersionUID = 7496156015186497496L; /** * Get the current beginning sentence address and add on it the size of the display * window */ @Override public void onClick(AjaxRequestTarget aTarget) { editor.reset(aTarget); // List of all Source Documents in the project List<SourceDocument> listOfSourceDocuements = repository.listSourceDocuments(bModel.getProject()); String username = SecurityContextHolder.getContext().getAuthentication().getName(); User user = userRepository.get(username); List<SourceDocument> sourceDocumentsinIgnorState = new ArrayList<SourceDocument>(); for (SourceDocument sourceDocument : listOfSourceDocuements) { if (repository.existsAnnotationDocument(sourceDocument, user) && repository.getAnnotationDocument(sourceDocument, user).getState() .equals(AnnotationDocumentState.IGNORE)) { sourceDocumentsinIgnorState.add(sourceDocument); } } listOfSourceDocuements.removeAll(sourceDocumentsinIgnorState); // Index of the current source document in the list int currentDocumentIndex = listOfSourceDocuements.indexOf(bModel.getDocument()); // If the first document if (currentDocumentIndex == listOfSourceDocuements.size() - 1) { aTarget.appendJavaScript("alert('This is the last document!')"); return; } bModel.setDocumentName(listOfSourceDocuements.get(currentDocumentIndex + 1).getName()); bModel.setDocument(listOfSourceDocuements.get(currentDocumentIndex + 1)); loadDocumentAction(aTarget); } }.add(new InputBehavior(new KeyType[] { KeyType.Shift, KeyType.Page_down }, EventType.click))); // Show the next page of this document add(new AjaxLink<Void>("showNext") { private static final long serialVersionUID = 7496156015186497496L; /** * Get the current beginning sentence address and add on it the size of the display * window */ @Override public void onClick(AjaxRequestTarget aTarget) { try { if (bModel.getDocument() != null) { JCas jCas = getJCas(); int nextSentenceAddress = BratAjaxCasUtil.getNextPageFirstSentenceAddress(jCas, bModel.getSentenceAddress(), bModel.getPreferences().getWindowSize()); if (bModel.getSentenceAddress() != nextSentenceAddress) { updateSentenceNumber(jCas, nextSentenceAddress); aTarget.addChildren(getPage(), FeedbackPanel.class); annotator.bratRenderLater(aTarget); gotoPageTextField.setModelObject( BratAjaxCasUtil.getFirstSentenceNumber(jCas, bModel.getSentenceAddress()) + 1); updateSentenceAddress(jCas, aTarget); } else { aTarget.appendJavaScript("alert('This is last page!')"); } } else { aTarget.appendJavaScript("alert('Please open a document first!')"); } } catch (Exception e) { error(e.getMessage()); aTarget.addChildren(getPage(), FeedbackPanel.class); } } }.add(new InputBehavior(new KeyType[] { KeyType.Page_down }, EventType.click))); // Show the previous page of this document add(new AjaxLink<Void>("showPrevious") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget aTarget) { try { if (bModel.getDocument() != null) { JCas jCas = getJCas(); int previousSentenceAddress = BratAjaxCasUtil.getPreviousDisplayWindowSentenceBeginAddress( jCas, bModel.getSentenceAddress(), bModel.getPreferences().getWindowSize()); if (bModel.getSentenceAddress() != previousSentenceAddress) { updateSentenceNumber(jCas, previousSentenceAddress); aTarget.addChildren(getPage(), FeedbackPanel.class); annotator.bratRenderLater(aTarget); gotoPageTextField.setModelObject( BratAjaxCasUtil.getFirstSentenceNumber(jCas, bModel.getSentenceAddress()) + 1); updateSentenceAddress(jCas, aTarget); } else { aTarget.appendJavaScript("alert('This is First Page!')"); } } else { aTarget.appendJavaScript("alert('Please open a document first!')"); } } catch (Exception e) { error(e.getMessage()); aTarget.addChildren(getPage(), FeedbackPanel.class); } } }.add(new InputBehavior(new KeyType[] { KeyType.Page_up }, EventType.click))); add(new AjaxLink<Void>("showFirst") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget aTarget) { try { if (bModel.getDocument() != null) { JCas jCas = getJCas(); if (bModel.getFirstSentenceAddress() != bModel.getSentenceAddress()) { updateSentenceNumber(jCas, bModel.getFirstSentenceAddress()); aTarget.addChildren(getPage(), FeedbackPanel.class); annotator.bratRenderLater(aTarget); gotoPageTextField.setModelObject( BratAjaxCasUtil.getFirstSentenceNumber(jCas, bModel.getSentenceAddress()) + 1); updateSentenceAddress(jCas, aTarget); } else { aTarget.appendJavaScript("alert('This is first page!')"); } } else { aTarget.appendJavaScript("alert('Please open a document first!')"); } } catch (Exception e) { error(e.getMessage()); aTarget.addChildren(getPage(), FeedbackPanel.class); } } }.add(new InputBehavior(new KeyType[] { KeyType.Home }, EventType.click))); add(new AjaxLink<Void>("showLast") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget aTarget) { try { if (bModel.getDocument() != null) { JCas jCas = getJCas(); int lastDisplayWindowBeginingSentenceAddress = BratAjaxCasUtil .getLastDisplayWindowFirstSentenceAddress(jCas, bModel.getPreferences().getWindowSize()); if (lastDisplayWindowBeginingSentenceAddress != bModel.getSentenceAddress()) { updateSentenceNumber(jCas, lastDisplayWindowBeginingSentenceAddress); aTarget.addChildren(getPage(), FeedbackPanel.class); annotator.bratRenderLater(aTarget); gotoPageTextField.setModelObject( BratAjaxCasUtil.getFirstSentenceNumber(jCas, bModel.getSentenceAddress()) + 1); updateSentenceAddress(jCas, aTarget); } else { aTarget.appendJavaScript("alert('This is last Page!')"); } } else { aTarget.appendJavaScript("alert('Please open a document first!')"); } } catch (Exception e) { error(e.getMessage()); aTarget.addChildren(getPage(), FeedbackPanel.class); } } }.add(new InputBehavior(new KeyType[] { KeyType.End }, EventType.click))); add(new AjaxLink<Void>("toggleScriptDirection") { private static final long serialVersionUID = -4332566542278611728L; @Override public void onClick(AjaxRequestTarget aTarget) { if (ScriptDirection.LTR.equals(bModel.getScriptDirection())) { bModel.setScriptDirection(ScriptDirection.RTL); } else { bModel.setScriptDirection(ScriptDirection.LTR); } annotator.bratRenderLater(aTarget); } }); add(new GuidelineModalPanel("guidelineModalPanel", new Model<BratAnnotatorModel>(bModel))); gotoPageTextField = (NumberTextField<Integer>) new NumberTextField<Integer>("gotoPageText", new Model<Integer>(0)); Form<Void> gotoPageTextFieldForm = new Form<Void>("gotoPageTextFieldForm"); gotoPageTextFieldForm.add(new AjaxFormSubmitBehavior(gotoPageTextFieldForm, "onsubmit") { private static final long serialVersionUID = -4549805321484461545L; @Override protected void onSubmit(AjaxRequestTarget aTarget) { try { if (gotoPageAddress == 0) { aTarget.appendJavaScript("alert('The sentence number entered is not valid')"); return; } if (bModel.getSentenceAddress() != gotoPageAddress) { JCas jCas = getJCas(); updateSentenceNumber(jCas, gotoPageAddress); aTarget.addChildren(getPage(), FeedbackPanel.class); annotator.bratRenderLater(aTarget); aTarget.add(numberOfPages); gotoPageTextField.setModelObject( BratAjaxCasUtil.getFirstSentenceNumber(jCas, bModel.getSentenceAddress()) + 1); aTarget.add(gotoPageTextField); } } catch (Exception e) { error(e.getMessage()); aTarget.addChildren(getPage(), FeedbackPanel.class); } } }); gotoPageTextField.setType(Integer.class); gotoPageTextField.setMinimum(1); gotoPageTextField.setDefaultModelObject(1); add(gotoPageTextFieldForm.add(gotoPageTextField)); gotoPageTextField.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 56637289242712170L; @Override protected void onUpdate(AjaxRequestTarget aTarget) { try { if (gotoPageTextField.getModelObject() < 1) { aTarget.appendJavaScript("alert('Page number shouldn't be less than 1')"); } else { updateSentenceAddress(getJCas(), aTarget); } } catch (Exception e) { error(e.getMessage()); aTarget.addChildren(getPage(), FeedbackPanel.class); } } }); add(new AjaxLink<Void>("gotoPageLink") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget aTarget) { try { if (gotoPageAddress == 0) { aTarget.appendJavaScript("alert('The sentence number entered is not valid')"); return; } if (bModel.getDocument() == null) { aTarget.appendJavaScript("alert('Please open a document first!')"); return; } if (bModel.getSentenceAddress() != gotoPageAddress) { JCas jCas = getJCas(); updateSentenceNumber(jCas, gotoPageAddress); updateSentenceAddress(jCas, aTarget); annotator.bratRenderLater(aTarget); } } catch (Exception e) { error(e.getMessage()); aTarget.addChildren(getPage(), FeedbackPanel.class); } } }); finish = new FinishImage("finishImage", new Model<BratAnnotatorModel>(bModel)); finish.setOutputMarkupId(true); add(new FinishLink("showYesNoModalPanel", new Model<BratAnnotatorModel>(bModel), finish) { private static final long serialVersionUID = -4657965743173979437L; }); }
From source file:de.tudarmstadt.ukp.clarin.webanno.webapp.page.annotation.component.AnnotationLayersModalPanel.java
License:Apache License
public AnnotationLayersModalPanel(String id, final IModel<BratAnnotatorModel> aBModel, AnnotationDetailEditorPanel aEditor) { super(id, aBModel); // dialog window to select annotation layer preferences final ModalWindow annotationLayerSelectionModal; add(annotationLayerSelectionModal = new ModalWindow("annotationLayerModal")); annotationLayerSelectionModal.setOutputMarkupId(true); annotationLayerSelectionModal.setInitialWidth(450); annotationLayerSelectionModal.setInitialHeight(350); annotationLayerSelectionModal.setResizable(true); annotationLayerSelectionModal.setWidthUnit("px"); annotationLayerSelectionModal.setHeightUnit("px"); annotationLayerSelectionModal.setTitle("Annotation Layer and window size configuration Window"); annotationLayerSelectionModal.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() { private static final long serialVersionUID = -5423095433535634321L; @Override/* w w w . j ava2 s.c om*/ public boolean onCloseButtonClicked(AjaxRequestTarget aTarget) { closeButtonClicked = true; return true; } }); add(new AjaxLink<Void>("showannotationLayerModal") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget target) { if (aBModel.getObject().getProject() == null) { target.appendJavaScript("alert('Please open a project first!')"); } else { closeButtonClicked = false; annotationLayerSelectionModal.setContent( new AnnotationPreferenceModalPanel(annotationLayerSelectionModal.getContentId(), annotationLayerSelectionModal, aBModel.getObject(), aEditor) { private static final long serialVersionUID = -3434069761864809703L; @Override protected void onCancel(AjaxRequestTarget aTarget) { closeButtonClicked = true; }; }); annotationLayerSelectionModal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 1643342179335627082L; @Override public void onClose(AjaxRequestTarget target) { if (!closeButtonClicked) { onChange(target); } } }); annotationLayerSelectionModal.show(target); } } }); }
From source file:de.tudarmstadt.ukp.clarin.webanno.webapp.page.annotation.component.ExportModalPanel.java
License:Apache License
public ExportModalPanel(String id, final IModel<BratAnnotatorModel> aModel) { super(id, aModel); final ModalWindow exportModal; add(exportModal = new ModalWindow("exportModal")); exportModal.setCookieName("modal-1"); exportModal.setInitialWidth(550);//from w w w. ja v a 2 s .c o m exportModal.setInitialHeight(450); exportModal.setResizable(true); exportModal.setWidthUnit("px"); exportModal.setHeightUnit("px"); exportModal.setTitle("Export Annotated data to a given Format"); exportModal.setContent( new ExportModalWindowPanel(exportModal.getContentId(), exportModal, aModel.getObject())); add(new AjaxLink<Void>("showExportModal") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget target) { if (aModel.getObject().getDocument() == null) { target.appendJavaScript("alert('Please open a document first!')"); } else { exportModal.show(target); } } }); }