List of usage examples for org.apache.wicket.ajax AjaxRequestTarget add
void add(Component... components);
From source file:ch.bd.qv.quiz.panels.BasePanel.java
License:Apache License
public BasePanel(String id) { super(id);//from w w w .ja va 2s. c o m add(new FeedbackPanel("feedback")); form = new Form("form"); add(form); form.add(new LangPanel("swapPanel")); final AjaxSubmitLink ajaxSubmitLink = new AjaxSubmitLink("submit") { @Override public boolean isVisible() { return isVisibleNotOnLangAndEnd(); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { driveNavigation(); target.add(findParent(BasePanel.class)); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(findParent(BasePanel.class)); } }; final AjaxLink cancelLink = new AjaxLink("cancel") { @Override public void onClick(AjaxRequestTarget target) { getSession().invalidateNow(); setResponsePage(HomePage.class); target.add(findParent(BasePanel.class)); } @Override public boolean isVisible() { return isVisibleNotOnLangAndEnd(); } }; ajaxSubmitLink.add(new Label("label", new LoadableDetachableModel<String>() { @Override protected String load() { if (data.getNavigation() == NavigationEnum.QUESTION && data.getQuestionNo() == data.getQuestions().size()) { LOGGER.debug("last question, display end. "); return new StringResourceModel("button.end", BasePanel.this, null).getObject(); } else { return new StringResourceModel("button.weiter", BasePanel.this, null).getObject(); } } })); form.add(ajaxSubmitLink, cancelLink); }
From source file:ch.bd.qv.quiz.panels.DataPanel.java
License:Apache License
public DataPanel(String id) { super(id, new CompoundPropertyModel<>(new Person())); final EmailTextField email = new EmailTextField("email", new Model()); email.setRequired(true);/*from w w w . j a va 2s . co m*/ email.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { Person p = personBean.getPersonByEmail(email.getDefaultModelObjectAsString()); if (p != null) { LOGGER.debug("person found: " + p.getEmail() + " replacing model "); setDefaultModelObject(p); target.add(findParent(BasePanel.class)); } ((Person) getDefaultModelObject()).setEmail(email.getModelObject()); } }); add(new FcBorder("emailcont", email)); add(new FcBorder("namecont", new TextField<String>("name").setRequired(true))); add(new FcBorder("vornamecont", new TextField("vorname").setRequired(true))); add(new FcBorder("firmacont", new TextField("firma").setRequired(true))); add(new FcBorder("telcont", new TextField("tel"))); }
From source file:ch.bd.qv.quiz.panels.LangPanel.java
License:Apache License
public LangPanel(String id) { super(id);// ww w . j a va 2 s. c om LOGGER.debug("lang received on panel: " + Joiner.on(":").join(supportedLocales.iterator())); add(new ListView<Locale>("list", supportedLocales) { @Override protected void populateItem(final ListItem<Locale> item) { AjaxLink<Void> langLink = new AjaxLink<Void>("lang") { @Override public void onClick(AjaxRequestTarget target) { getSession().setLocale(item.getModelObject()); BasePanel bp = findParent(BasePanel.class); bp.driveNavigation(); target.add(bp); } }; langLink.add(new Label("label", new LoadableDetachableModel<String>() { @Override protected String load() { LOGGER.debug("item: " + item.getModelObject()); return item.getModelObject().getLanguage().toUpperCase(); } })); item.add(langLink); } }); }
From source file:ch.qos.mistletoe.wicket.TreeExpansionLink.java
License:Open Source License
@SuppressWarnings("unchecked") @Override// ww w .j ava 2 s . c om public void onClick(AjaxRequestTarget target) { TestReportPanel nodePanel = (TestReportPanel) getParent(); if (nodePanel == null || nodePanel.testReport == null) { warn("Failed to find node panel"); return; } if (nodePanel.testReport.isSuite()) { expanded = !expanded; System.out.println("expanded=" + expanded); TreeExpansionLink link = (TreeExpansionLink) nodePanel.get(Constants.TREE_CONTROL_ID); target.add(link.getParent()); Image image = (Image) link.get(Constants.TREE_CONTROL_SYMBOL_ID); ResourceReference ref = getControlSymbolResourceReference(expanded); image.setImageResourceReference(ref); ListView<Node> payloadNode = (ListView<Node>) nodePanel.get(Constants.PAYLOAD_ID); payloadNode.setVisible(expanded); // can't update a ListView target.add(payloadNode.getParent()); } }
From source file:com.apachecon.memories.ApproveGallery.java
License:Apache License
@Override protected void enrich(WebMarkupContainer secondContainer, UserFile file, int page) { secondContainer.add(new ImageLink("imageLink", file)); final EmptyPanel decorator = new EmptyPanel("decorator"); decorator.setOutputMarkupId(true);/*from ww w .j a v a2 s .com*/ if (!file.isNew()) { // decorate files only if they come from approved/declined directory decorator.add(AttributeModifier.append("class", file.isApproved() ? "approved" : "declined")); } secondContainer.add(decorator); secondContainer.add(new ApproveLink("approve", file) { private static final long serialVersionUID = 1L; protected void update(AjaxRequestTarget target) { decorator.add(AttributeModifier.replace("class", "approved")); target.add(decorator); } }); secondContainer.add(new DeclineLink("decline", file) { private static final long serialVersionUID = 1L; protected void update(AjaxRequestTarget target) { decorator.add(AttributeModifier.replace("class", "declined")); target.add(decorator); } }); }
From source file:com.aplombee.navigator.ItemsNavigatorBase.java
License:Apache License
/** * on a stateful event say onclick ,this method creates new rows/items for the page * * @return list of items created/*from ww w .j a v a 2s. c o m*/ */ public List<Item> onStatefulEvent() { AjaxRequestTarget target = getAjaxRequestTarget(); List<Item> list = getRepeater().addItemsForNextPage(); target.add(getMore()); return list; }
From source file:com.axway.ats.testexplorer.pages.BasePage.java
License:Apache License
private void currentTestDetails() { currentClass = this.getClass(); final WebMarkupContainer testDetails = new WebMarkupContainer("testDetails"); testDetails.setOutputMarkupId(true); add(testDetails);/*from www . j ava 2 s.com*/ // here we will create empty datagrids, and later we will replace them with the full ones runGrid = new DataGrid("singleRun", new SuitesDataSource("0"), new ArrayList<IGridColumn>()); runGrid.setOutputMarkupId(true); runGrid.setVisible(false); testDetails.add(runGrid); suiteGrid = new DataGrid("singleSuite", new SuitesDataSource("0"), new ArrayList<IGridColumn>()); suiteGrid.setOutputMarkupId(true); suiteGrid.setVisible(false); testDetails.add(suiteGrid); scenarioGrid = new DataGrid("singleScenario", new SuitesDataSource("0"), new ArrayList<IGridColumn>()); scenarioGrid.setOutputMarkupId(true); scenarioGrid.setVisible(false); testDetails.add(scenarioGrid); AjaxLink<Object> testDetailslink = new AjaxLink<Object>("testDetailsButton") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { boolean isTestLocationDetailsVisible = runGrid.isVisible(); String runId = singleTestIds.get("runId"); String suiteId = singleTestIds.get("suiteId"); String scenarioId = singleTestIds.get("scenarioId"); if (runId != null) { RunsPanel runs = new RunsPanel(runId); createSingleGrid(testDetails, runGrid, "singleRun", new RunsDataSource(runId), runs.getColumns(null), runs.getTableColumnDefinitions()); runGrid.setVisible(!isTestLocationDetailsVisible); target.add(runGrid); if (suiteId != null) { SuitesPanel suites = new SuitesPanel(suiteId); createSingleGrid(testDetails, suiteGrid, "singleSuite", new SuitesDataSource(runId, suiteId), suites.getColumns(), suites.getTableColumnDefinitions()); suiteGrid.setVisible(!isTestLocationDetailsVisible); target.add(suiteGrid); if (scenarioId != null) { ScenariosPanel scenarios = new ScenariosPanel(scenarioId); createSingleGrid(testDetails, scenarioGrid, "singleScenario", new ScenariosDataSource(suiteId, scenarioId), scenarios.getColumns(), scenarios.getTableColumnDefinitions()); scenarioGrid.setVisible(!isTestLocationDetailsVisible); target.add(scenarioGrid); } } } else { // nothing to do here, do not modify anything return; } // here we will call JS function to show the navigation test details target.appendJavaScript("showOrHideTestDetails(" + !isTestLocationDetailsVisible + ")"); target.add(testDetails); } }; testDetailslink.setEnabled(currentClass != WelcomePage.class && currentClass != BasePage.class && currentClass != RunsPage.class); add(testDetailslink); }
From source file:com.axway.ats.testexplorer.pages.machines.MachinesPage.java
License:Apache License
private Component getMachineInfoDialogSaveButton() { return new AjaxButton("machineInfoDialogSave") { private static final long serialVersionUID = 1L; @Override//from ww w. jav a2s.co m protected void onSubmit(AjaxRequestTarget target, Form<?> form) { String information = machineInfoText.getModel().getObject(); if (information == null) { information = ""; } if (information.length() > MAX_MACHINE_INFO_LENGTH) { information = information.substring(0, MAX_MACHINE_INFO_LENGTH) + "..."; } updateMachineInformation(machineForEdit, information); machineInfoDialog.setVisible(false); target.add(machineInfoDialogForm); } }; }
From source file:com.axway.ats.testexplorer.pages.machines.MachinesPage.java
License:Apache License
private Component getMachineInfoDialogCancelButton() { return new AjaxButton("machineInfoDialogCancel") { private static final long serialVersionUID = 1L; @Override/* w w w .j a v a2 s . com*/ protected void onSubmit(AjaxRequestTarget target, Form<?> form) { machineInfoDialog.setVisible(false); target.add(machineInfoDialogForm); } }; }
From source file:com.axway.ats.testexplorer.pages.machines.MachinesPage.java
License:Apache License
private Form<Object> getMachinesForm(final Label noMachinesLabel) { final Form<Object> machinesForm = new Form<Object>("machinesForm"); machinesForm.setOutputMarkupId(true); machineModels = new HashMap<Integer, IModel<String>>(); ListView<Machine> machinesTable = new ListView<Machine>("machine", machines) { private static final long serialVersionUID = 1L; @Override//from w ww .j a v a 2s . co m protected void populateItem(final ListItem<Machine> item) { if (item.getIndex() % 2 != 0) { item.add(AttributeModifier.replace("class", "oddRow")); } IModel<String> aliasModel = new Model<String>(item.getModelObject().alias); machineModels.put(item.getModelObject().machineId, aliasModel); item.add(new TextField<String>("machineAlias", aliasModel)); item.add(new Label("machineName", item.getModelObject().name).setEscapeModelStrings(false)); final Machine machine = item.getModelObject(); item.add(new AjaxButton("machineInfo") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { if (machine.alias == null || machine.alias.trim().length() == 0) { machineInfoDialogTitle.setDefaultModelObject(machine.name); } else { machineInfoDialogTitle.setDefaultModelObject(machine.alias + " (" + machine.name + ")"); } machineInfoDialog.setVisible(true); machineForEdit = machine; machineInfoText.setModelObject(getMachineInformation(machine)); target.add(machineInfoDialogForm); } }); } }; machinesForm.add(machinesTable); AjaxButton saveMachineAliasesButton = new AjaxButton("saveMachineAliasesButton") { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form<?> form) { if (!form.isSubmitted()) { return; } for (Machine machine : machines) { String newMachineAlias = machineModels.get(machine.machineId).getObject(); if (newMachineAlias != null) { newMachineAlias = newMachineAlias.trim(); } if ((newMachineAlias == null && machine.alias != null) || (newMachineAlias != null && !newMachineAlias.equals(machine.alias))) { machine.alias = newMachineAlias; try { getTESession().getDbWriteConnection().updateMachineAlias(machine); } catch (DatabaseAccessException e) { LOG.error("Can't update alias of machine '" + machine.name + "'", e); target.appendJavaScript( "alert('There was an error while updating the machine aliases!');"); return; } } } target.appendJavaScript("alert('The machine aliases were successfully updated.');"); } }; boolean hasMachines = machines.size() > 0; machinesTable.setVisible(hasMachines); saveMachineAliasesButton.setVisible(hasMachines); noMachinesLabel.setVisible(!hasMachines); machinesForm.add(saveMachineAliasesButton); machinesForm.add(noMachinesLabel); return machinesForm; }