List of usage examples for org.apache.wicket.markup.html.basic Label getDefaultModel
public final IModel<?> getDefaultModel()
From source file:de.micromata.genome.junittools.wicket.TpsbWicketTools.java
License:Apache License
/** * Gets the label text./*ww w . java2s . com*/ * * @param label the label * @return the label text */ public static String getLabelText(Label label) { try { IModel<?> model = label.getDefaultModel(); if (model == null) { return null; } Object obj = model.getObject(); if ((obj instanceof String) == false) { return null; } return (String) obj; } catch (RuntimeException ex) { return null; } }
From source file:org.geoserver.web.admin.StatusPageTest.java
License:Open Source License
@Test public void testExtraTabExists() { // render the page, GeoServer status tab is show tester.assertRenderedPage(StatusPage.class); // click on the extra tab link tester.clickLink("tabs:tabs-container:tabs:2:link", true); // render extra tab content tester.assertRenderedPage(StatusPage.class); // check that extra tab content was rendered tester.assertContains("extra tab content"); // check that the tab has the correct title Component component = tester.getComponentFromLastRenderedPage("tabs:tabs-container:tabs:2:link:title"); assertThat(component, instanceOf(Label.class)); Label label = (Label) component; assertThat(label.getDefaultModel(), notNullValue()); assertThat(label.getDefaultModel().getObject(), is("extra")); }
From source file:org.hippoecm.frontend.plugins.console.menu.cnd.CndExportDialog.java
License:Apache License
public CndExportDialog() { final PropertyModel<String> selectedNsModel = new PropertyModel<String>(this, "selectedNs"); List<String> nsPrefixes = null; try {/*from ww w . ja va 2 s .c om*/ Session session = getJcrSession(); nsPrefixes = getNsPrefixes(session); } catch (RepositoryException e) { log.error(e.getMessage()); } // output for view final Label dump = new Label("dump"); dump.setOutputMarkupId(true); add(dump); // add dropdown for namespaces FormComponent<String> dropdown = new DropDownChoice<String>("nsprefixes", selectedNsModel, nsPrefixes) { private static final long serialVersionUID = 1L; @Override public boolean isNullValid() { return false; } @Override public boolean isRequired() { return false; } }; add(dropdown); dropdown.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { String export; try { Session session = getJcrSession(); export = JcrCompactNodeTypeDefWriter.compactNodeTypeDef(session.getWorkspace(), selectedNs); } catch (RepositoryException e) { log.error( "RepositoryException while exporting NodeType Definitions of namespace : " + selectedNs, e); export = e.getMessage(); } catch (IOException e) { log.error("IOException while exporting NodeType Definitions of namespace : " + selectedNs, e); export = e.getMessage(); } dump.setDefaultModel(new Model<String>(export)); target.add(CndExportDialog.this); } }); // Add download link DownloadLink link = new DownloadLink<Node>("download-link") { private static final long serialVersionUID = 1L; protected String getFilename() { return selectedNs + ".cnd"; } protected InputStream getContent() { String export = (String) dump.getDefaultModel().getObject(); ByteArrayOutputStream ostream = new ByteArrayOutputStream(); PrintWriter writer = new PrintWriter(ostream); writer.print(export); writer.flush(); return new ByteArrayInputStream(ostream.toByteArray()); } @Override public boolean isVisible() { return selectedNs != null && !dump.getDefaultModelObjectAsString().equals(""); } }; link.add(new Label("download-link-text", "Download (or right click and choose \"Save as..\"")); link.setOutputMarkupId(true); add(link); setOkVisible(false); }
From source file:org.obiba.onyx.ruby.core.wicket.wizard.BarcodePartColumnTest.java
License:Open Source License
@Test public void testPopulateItem() { int firstBarcodePartColumnIndex = 2; BarcodePartColumn barcodePartColumn = new BarcodePartColumn(new Model("testPartTitle"), firstBarcodePartColumnIndex); ParticipantTubeRegistration participantTubeRegistration = new ParticipantTubeRegistration(); participantTubeRegistration.setTubeSetName("SamplesCollection"); RegisteredParticipantTube registeredParticipantTube = new RegisteredParticipantTube(); registeredParticipantTube.setParticipantTubeRegistration(participantTubeRegistration); registeredParticipantTube.setBarcode("1234567011"); Item cellItem = new Item("itemId", firstBarcodePartColumnIndex, new Model()); barcodePartColumn.populateItem(cellItem, "componentId", new Model(registeredParticipantTube)); // Verify that the cell item contains a label with the expected text (<partTitle>.<partLabel>), // where <partLabel> is the first seven characters of the barcode. Label label = (Label) cellItem.get("componentId"); Assert.assertNotNull(label);/*from w w w. ja va2s. c o m*/ MessageSourceResolvableStringModel model = (MessageSourceResolvableStringModel) label.getDefaultModel(); Assert.assertNotNull(model); // Assert.assertTrue(Arrays.asList(model.getCodes()).contains("testPartTitle.1234567")); }
From source file:org.openengsb.ui.admin.testClient.TestClientTest.java
License:Apache License
@Test public void testListToCreateNewServices() throws Exception { setupAndStartTestClientPage();/*from ww w . j av a 2s . c o m*/ tester.debugComponentTrees(); tester.assertRenderedPage(TestClient.class); Label domainName = (Label) tester .getComponentFromLastRenderedPage("serviceManagementContainer:domains:1:domain.name"); Label domainDescription = (Label) tester .getComponentFromLastRenderedPage("serviceManagementContainer:domains:1:domain.description"); Label domainClass = (Label) tester .getComponentFromLastRenderedPage("serviceManagementContainer:domains:1:domain.class"); tester.debugComponentTrees(); Label name = (Label) tester .getComponentFromLastRenderedPage("serviceManagementContainer:domains:1:services:0:service.name"); Label description = (Label) tester.getComponentFromLastRenderedPage( "serviceManagementContainer:domains:" + "1:services:0:service.description"); assertThat(domainName.getDefaultModel().getObject().toString(), equalTo("testdomain")); assertThat(domainDescription.getDefaultModel().getObject().toString(), equalTo("testdomain")); assertThat(domainClass.getDefaultModel().getObject().toString(), equalTo(TestInterface.class.getName())); Assert.assertEquals("service.name", name.getDefaultModel().getObject()); Assert.assertEquals("service.description", description.getDefaultModel().getObject()); }
From source file:org.projectforge.web.wicket.WicketUtils.java
License:Open Source License
@SuppressWarnings("unchecked") public static void setLabel(final FormComponent<?> component, final Label label) { final IModel<String> labelModel = (IModel<String>) label.getDefaultModel(); if (component instanceof DatePanel) { ((DatePanel) component).getDateField().setLabel(labelModel); } else {//from w w w.j ava2 s . c om component.setLabel(labelModel); } }
From source file:org.wicketstuff.push.AbstractPushEventHandler.java
License:Apache License
protected void appendHTML(final AjaxRequestTarget target, final Label component, final String html) { Args.notNull(target, "target"); Args.notNull(component, "component"); if (html == null) return;/*w w w . j a va 2 s . c o m*/ // update the component's model object for the case when the page is refreshed using F5 component.setEscapeModelStrings(false); final IModel<?> model = component.getDefaultModel(); component.setDefaultModelObject( model == null || model.getObject() == null ? html : model.getObject() + html); // escape backslashes for JavaScript final String escapedHTML = html.replaceAll("\\\\", "\"); target.appendJavaScript("" + // "var target = document.getElementById('" + component.getMarkupId() + "');" + // "target.innerHTML += '" + escapedHTML + "';" + // "target.scrollTop = target.scrollHeight" // ); }