List of usage examples for org.apache.wicket Page get
@Override public final Component get(String path)
From source file:com.evolveum.midpoint.gui.api.util.WebComponentUtil.java
License:Apache License
public static <T extends Component> T theSameForPage(T object, PageReference containingPageReference) { Page containingPage = containingPageReference.getPage(); if (containingPage == null) { return object; }//from w w w . j a v a 2 s.c om String path = object.getPageRelativePath(); T retval = (T) containingPage.get(path); if (retval == null) { return object; // throw new IllegalStateException("There is no component like " + // object + " (path '" + path + "') on " + containingPage); } return retval; }
From source file:org.geoserver.security.web.AbstractSecurityWicketTestSupport.java
License:Open Source License
private void initializeForService(String name, String panelName) { Page page = new UserGroupRoleServicesPage(); tester.startPage(page);// ww w . j a v a2 s . com tester.assertRenderedPage(page.getPageClass()); SecurityNamedServicesPanel panel = (SecurityNamedServicesPanel) page.get("panel:panel:" + panelName); // AjaxTabbedPanel tabbedPanel= (AjaxTabbedPanel) page.get(AbstractSecurityPage.TabbedPanelId); // String linkId = tabbedPanel.getId()+":tabs-container:tabs:"+tabIndex+":link"; // tester.clickLink(linkId,true); DataView<SecurityNamedServiceConfig> dv = (DataView<SecurityNamedServiceConfig>) panel .get("table:listContainer:items"); //page.get("tabbedPanel:panel:table:listContainer:items"); Iterator<Item<SecurityNamedServiceConfig>> it = dv.getItems(); while (it.hasNext()) { Item<SecurityNamedServiceConfig> item = it.next(); if (name.equals(item.getModelObject().getName())) tester.clickLink(item.getPageRelativePath() + ":itemProperties:0:component:link"); } }
From source file:org.odlabs.wiquery.tester.WiQueryTester.java
License:Open Source License
public RepeatingView getRepeatingView(String path) { Page renderedPage = getLastRenderedPage(); assertComponent(path, RepeatingView.class); RepeatingView rv = (RepeatingView) renderedPage.get(path); return rv;/* www . j a va 2s.co m*/ }
From source file:org.odlabs.wiquery.tester.WiQueryTester.java
License:Open Source License
public ListView<?> getListView(String path) { Page renderedPage = getLastRenderedPage(); assertComponent(path, ListView.class); ListView<?> rv = (ListView<?>) renderedPage.get(path); return rv;//from w ww .j a v a 2 s .co m }
From source file:org.wicketstuff.security.SecureLinkTest.java
License:Apache License
/** * Test visibility and clickability of a secure link. *//*from w w w . ja v a 2s. com*/ @Test public void testLink() { // step zero, login and you will not see the PageA link (it has no // authorization, the default render check // will prevent it from rendering doLogin(); mock.assertInvisible("link"); mock.assertVisible("sorry"); // step one, show the secure home page without a link to PageA Page lastPage = mock.getLastRenderedPage(); SecurePageLink<?> link = (SecurePageLink<?>) lastPage.get("link"); LinkSecurityCheck linkcheck = ((LinkSecurityCheck) link.getSecurityCheck()) .setUseAlternativeRenderCheck(true); // step two, show the secure home page with a not clickable link to // PageA (e.g. not a href) Map<String, WaspAction> authorized = new HashMap<String, WaspAction>(); authorized.put(SecureComponentHelper.alias(link), application.getActionFactory().getAction("access render")); login(authorized); mock.startPage(lastPage); mock.assertRenderedPage(getHomePage()); assertSame(lastPage, mock.getLastRenderedPage()); mock.assertInvisible("sorry"); mock.assertVisible("link"); TagTester tag = mock.getTagByWicketId("link"); assertNull(tag.getAttribute("href")); assertNull(tag.getAttribute("onclick")); // step three, show the secure home page with a clickable link to PageA authorized.clear(); authorized.put(SecureComponentHelper.alias(HomePage.class), application.getActionFactory().getAction("access render enable")); authorized.put(SecureComponentHelper.alias(PageA.class), application.getActionFactory().getAction("render enable")); login(authorized); Page page = mock.getLastRenderedPage(); mock.startPage(page); tag = mock.getTagByWicketId("link"); assertNotNull(tag.getAttribute("href")); logoff(authorized); authorized.clear(); // step four, show the secure home page with a clickable link and click // the link that is not enabled. linkcheck.setUseAlternativeRenderCheck(false); authorized.put(SecureComponentHelper.alias(HomePage.class), application.getActionFactory().getAction("access render enable")); authorized.put(SecureComponentHelper.alias(PageA.class), application.getActionFactory().getAction("access render")); login(authorized); mock.processRequest(); mock.assertRenderedPage(getHomePage()); mock.assertInvisible("sorry"); mock.assertVisible("link"); mock.assertDisabled("link"); // step five, add enable rights and click the link again. authorized.put(SecureComponentHelper.alias(PageA.class), application.getActionFactory().getAction("access render enable")); // Note that normally access is implied by render, just not in this // simple // testcase login(authorized); mock.startPage(getHomePage()); mock.clickLink("link", false); mock.assertRenderedPage(PageA.class); }
From source file:wicketdnd.DragSource.java
License:Apache License
/** * Get the drag source of the given request. * /*from w w w . ja v a 2s. c o m*/ * @param request * request on which a drag happened * @return drag source */ final static DragSource read(Page page, Request request) { String path = request.getRequestParameters().getParameterValue("path").toString(); Component component = page.get(path); if (component == null) { throw new PageExpiredException("No drag source found " + path); } int behavior = request.getRequestParameters().getParameterValue("behavior").toInt(); return (DragSource) component.getBehaviorById(behavior); }