List of usage examples for org.apache.wicket Component getId
@Override
public String getId()
From source file:org.dcm4chee.wizard.common.behavior.TooltipBehavior.java
License:LGPL
String getResourceKey(Component component) { if (generateComponentTreePrefix) prefix = generateComponentTreePrefix(component); StringBuilder sb = new StringBuilder(); if (prefix != null) sb.append(prefix);//from w ww . java 2s. c om sb.append(id == null ? component.getId() : id); sb.append(this.showTooltipModel == null ? "" : "." + (this.showTooltipModel.getObject() ? "hide" : "show")); sb.append(POSTFIX); return sb.toString(); }
From source file:org.dcm4chee.wizard.common.behavior.TooltipBehavior.java
License:LGPL
private String generateComponentTreePrefix(Component component) { generateComponentTreePrefix = false; StringBuilder sb = new StringBuilder(""); Component parent = component.getParent(); while ((parent != null) && !parent.equals("") && !(parent instanceof ExtendedForm)) { sb.insert(0, "."); sb.insert(0, parent.getId()); parent = parent.getParent();/* ww w . j av a 2s . c o m*/ } if ((prefix != null) && (!prefix.equals(""))) sb.insert(0, prefix); return sb.toString(); }
From source file:org.devproof.portal.core.app.PortalSession.java
License:Apache License
/** * Whether an user has the right for this component * * @param component component//w ww .j a va2 s .c o m * @param action * @return true if the user has the right */ public boolean hasRight(Component component, Action action) { List<Right> allRights = rightService.getAllRights(); if (component instanceof BookmarkablePageLink<?>) { /* * This will remove the links for pages where the user hasn't got * rights. If there exists a right starting with page.PageClassName, * the user must have the right to access the page! */ BookmarkablePageLink<?> l = (BookmarkablePageLink<?>) component; Class<? extends Page> pageClass = l.getPageClass(); return hasRight(pageClass, action); } else if (hasSecuredAnnotation(component.getClass())) { return evaluateSecuredAnnotation(component.getClass(), action); } // problem with tree table, i dont know why else if (!(component instanceof TreeTable)) { String rightName = RightConstants.COMPONENT_RIGHT_PREFIX + component.getPage().getClass().getSimpleName() + "." + component.getId(); Right right = rightService.newRightEntity(rightName); if (allRights.contains(right)) { return hasRight(right); } rightName = RightConstants.GENERAL_RIGHT_PREFIX + component.getClass().getSimpleName(); right = rightService.newRightEntity(rightName); if (allRights.contains(right)) { return hasRight(right); } } return true; }
From source file:org.efaps.ui.wicket.behaviors.dojo.RequireBehavior.java
License:Apache License
/** * Render the links for the head./*from w ww.j a v a 2 s . co m*/ * * @param _component component the header will be rendered for * @param _response resonse to add */ @Override public void renderHead(final Component _component, final IHeaderResponse _response) { super.renderHead(_component, _response); final StringBuilder js = new StringBuilder().append("require(["); for (int i = 0; i < this.packages.length; i++) { if (i > 0) { js.append(","); } js.append("\"").append(this.packages[i]).append("\""); } js.append("]);"); _response.render(JavaScriptHeaderItem.forScript(js, _component.getId())); }
From source file:org.efaps.ui.wicket.components.search.ResultPanel.java
License:Apache License
/** * Update./*from ww w .ja v a 2s.c o m*/ * * @param _target the target * @param _indexSearch the index search */ public void update(final AjaxRequestTarget _target, final IndexSearch _indexSearch) { ResultPanel.this.visitChildren(DimensionPanel.class, new IVisitor<Component, Void>() { @Override public void component(final Component _component, final IVisit<Void> _visit) { try { if (_indexSearch.getSearch().getConfigs().contains(SearchConfig.ACTIVATE_DIMENSION)) { _component.setVisible(true); } else { _component.setVisible(false); } } catch (final EFapsException e) { LOG.error("Catched error", e); } _visit.dontGoDeeper(); } }); ResultPanel.this.visitChildren(DataTable.class, new IVisitor<Component, Void>() { @Override public void component(final Component _component, final IVisit<Void> _visit) { if (_indexSearch.getResult().getElements().isEmpty()) { _component.setVisible(false); } else { _component.setVisible(true); } if (_indexSearch.isUpdateTable()) { _component.replaceWith(getDataTable(_indexSearch)); } _visit.dontGoDeeper(); } }); ResultPanel.this.visitChildren(Label.class, new IVisitor<Component, Void>() { @Override public void component(final Component _component, final IVisit<Void> _visit) { final String compid = _component.getId(); switch (compid) { case "hits": if (_indexSearch.getResult().getElements().isEmpty()) { _component.setVisible(false); } else { _component.setVisible(true); ((Label) _component).setDefaultModelObject( DBProperties.getFormatedDBProperty(ResultPanel.class.getName() + ".Hits", _indexSearch.getResult().getElements().size(), _indexSearch.getResult().getHitCount())); } break; case "noResult": if (_indexSearch.getResult().getElements().isEmpty()) { _component.setVisible(true); ((Label) _component).setDefaultModelObject( DBProperties.getProperty(ResultPanel.class.getName() + ".NoResult")); } else { _component.setVisible(false); } break; default: break; } } }); }
From source file:org.eknet.wicket.commons.textstore.TextNodeModel.java
License:Apache License
protected String getKey(Component component) { return component.getId(); }
From source file:org.geoserver.security.web.data.DataSecurityPageTest.java
License:Open Source License
@Test public void testEditCatalogMode() throws Exception { tester.startPage(DataSecurityPage.class); tester.assertRenderedPage(DataSecurityPage.class); // simple test assertFalse(("CHALLENGE".equals( tester.getComponentFromLastRenderedPage("catalogModeForm:catalogMode").getDefaultModelObject()))); // edit catalogMode value final FormTester form = tester.newFormTester("catalogModeForm"); form.select("catalogMode", 1); form.getForm().visitChildren(RadioChoice.class, new IVisitor() { public Object component(final Component component) { if (component.getId().equals("catalogMode")) { ((RadioChoice) component).onSelectionChanged(); }/* w ww . ja v a2 s. c o m*/ return CONTINUE_TRAVERSAL; } }); assertEquals("MIXED", tester.getComponentFromLastRenderedPage("catalogModeForm:catalogMode") .getDefaultModelObject().toString()); }
From source file:org.geoserver.security.web.GeoserverTablePanelTestPage.java
License:Open Source License
public GeoserverTablePanelTestPage(ComponentBuilder builder) { Form<Serializable> form = new Form<Serializable>(FORM); Component c = builder.buildComponent(TABLE); componentId = c.getId(); form.add(c);//ww w .j av a 2 s.co m add(form); }
From source file:org.geoserver.web.data.layergroup.LayerGroupEditPage.java
License:Open Source License
public LayerGroupEditPage(PageParameters parameters) { String groupName = parameters.getString(GROUP); String wsName = parameters.getString(WORKSPACE); LayerGroupInfo lg = wsName != null ? getCatalog().getLayerGroupByName(wsName, groupName) : getCatalog().getLayerGroupByName(groupName); if (lg == null) { error(new ParamResourceModel("LayerGroupEditPage.notFound", this, groupName).getString()); doReturn(LayerGroupPage.class); return;/*from w ww . ja va2s .c o m*/ } initUI(lg); if (!isAuthenticatedAsAdmin()) { Form f = (Form) get("form"); //global layer groups only editable by full admin if (lg.getWorkspace() == null) { //disable all form components but cancel f.visitChildren(new IVisitor<Component>() { @Override public Object component(Component c) { if (!(c instanceof AbstractLink && "cancel".equals(c.getId()))) { c.setEnabled(false); } return CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER; } }); f.get("save").setVisible(false); info(new StringResourceModel("globalLayerGroupReadOnly", this, null).getString()); } //always disable the workspace toggle f.get("workspace").setEnabled(false); } }
From source file:org.geoserver.web.GeoServerBasePage.java
License:Open Source License
/** * The base page is built with an empty panel in the page-header section that can be filled by * subclasses calling this method/*w w w . ja v a 2 s . c om*/ * * @param component * The component to be placed at the bottom of the page-header section. The component * must have "page-header" id */ protected void setHeaderPanel(Component component) { if (!HEADER_PANEL.equals(component.getId())) throw new IllegalArgumentException("The header panel component must have 'headerPanel' id"); remove(HEADER_PANEL); add(component); }