List of usage examples for org.apache.wicket Component getDefaultModelObjectAsString
public final String getDefaultModelObjectAsString()
From source file:org.openengsb.ui.admin.serviceListPage.ServicesListPageTest.java
License:Apache License
@Test public void verifyListViews_ShouldBe_Connecting_Online_Disconnecting_And_Disconnected() { NullDomainImpl domainService = new NullDomainImpl(); domainService.setAliveState(AliveState.CONNECTING); Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put(Constants.ID_KEY, "test-service"); props.put("testprop", "42"); registerService(domainService, props, NullDomain.class, Domain.class, OpenEngSBService.class); startPage();/* ww w .j a va2 s . c om*/ Label nameLabel = (Label) tester.getComponentFromLastRenderedPage( "lazy:content:serviceListContainer:serviceListView:0:service.name"); assertThat(nameLabel.getDefaultModelObjectAsString(), is("test-service")); Component stateLabel = tester.getComponentFromLastRenderedPage( "lazy:content:serviceListContainer:serviceListView:0:service.state"); assertThat(stateLabel.getDefaultModelObjectAsString(), is(AliveState.CONNECTING.name())); tester.debugComponentTrees(); }
From source file:org.openengsb.ui.admin.testClient.TestClientTest.java
License:Apache License
@Test @SuppressWarnings("rawtypes") public void testForEachDomainVisibleInCreatePartIsAnEntryInTree() throws Exception { setupAndStartTestClientPage();/* w ww . j a v a 2s . co m*/ tester.assertRenderedPage(TestClient.class); List<String> domains = new ArrayList<String>(); List<String> availableInTree = new ArrayList<String>(); List<DefaultMutableTreeNode> availableInTreeAsTreeNode = new ArrayList<DefaultMutableTreeNode>(); int count = ((ArrayList) tester.getComponentFromLastRenderedPage("serviceManagementContainer:domains") .getDefaultModelObject()).size(); // get all domains tester.debugComponentTrees(); for (int i = 0; i < count; i++) { Component label = tester .getComponentFromLastRenderedPage("serviceManagementContainer:domains:" + i + ":domain.name"); domains.add(label.getDefaultModelObjectAsString()); } // get all services from the tree DefaultTreeModel serviceListTree = (DefaultTreeModel) tester .getComponentFromLastRenderedPage("methodCallForm:serviceList").getDefaultModelObject(); count = serviceListTree.getChildCount(serviceListTree.getRoot()); for (int i = 0; i < count; i++) { DefaultMutableTreeNode child = (DefaultMutableTreeNode) serviceListTree .getChild(serviceListTree.getRoot(), i); String userObject = (String) child.getUserObject(); availableInTreeAsTreeNode.add(child); availableInTree.add(userObject); } for (int i = 0; i < domains.size(); i++) { String domain = domains.get(i); assertThat(availableInTree.contains(domain), is(true)); assertThat(serviceListTree.getChildCount(availableInTreeAsTreeNode.get(i)), greaterThan(0)); } }
From source file:org.tomochika1985.rssreader.ListPage.java
License:Apache License
@SuppressWarnings("serial") void createUrlForm() { final Form<Void> urlForm = new Form<Void>("urlForm"); add(urlForm);/* w ww . j a va 2 s .c o m*/ final TextField<String> txtFld = new TextField<String>("urlTextField", new Model<String>()); txtFld.setRequired(true); txtFld.add(new PatternValidator("^http://.*$")); urlForm.add(txtFld); final CheckBox check1 = new CheckBox("check1", new Model<Boolean>(true)); final CheckBox check2 = new CheckBox("check2", new Model<Boolean>(true)); urlForm.add(check1); urlForm.add(check2); add(new FeedbackPanel("feedback")); urlForm.add(new Button("submitBtn") { @Override public void onSubmit() { Component urlField = this.getParent().get("urlTextField"); String newUrlStr = urlField.getDefaultModelObjectAsString(); info("?: " + newUrlStr); } }); urlForm.add(new AbstractFormValidator() { @Override public void validate(Form<?> form) { if (!check1.getConvertedInput() && !check2.getConvertedInput()) { urlForm.error("????????"); } } @Override public FormComponent<?>[] getDependentFormComponents() { return new FormComponent<?>[] { check1, check2 }; } }); }