List of usage examples for org.apache.wicket Component getId
@Override
public String getId()
From source file:org.opensingular.lib.wicket.util.bootstrap.layout.BSInputGroupButton.java
License:Apache License
public BSInputGroupButton appendButtonAddon(SingularIcon singularIcon, Component button) { return this .appendTag("wicket:container", new TemplatePanel("_", () -> "" + "<button wicket:id='" + button.getId() + "' class='btn btn-default'>" + "<i class='" + singularIcon.getCssClass() + "'></i>" + "</button>") .add(button)); }
From source file:org.opensingular.lib.wicket.util.bootstrap.layout.TemplatePanel.java
License:Apache License
@Override protected IMarkupSourcingStrategy newMarkupSourcingStrategy() { return new PanelMarkupSourcingStrategy(false) { @Override//from w w w . ja va2 s.c o m public IMarkupFragment getMarkup(MarkupContainer parent, Component child) { // corrige o problema de encoding StringResourceStream stringResourceStream = new StringResourceStream( "<wicket:panel>" + getTemplateFunction().apply(TemplatePanel.this) + "</wicket:panel>", "text/html"); stringResourceStream.setCharset(Charset.forName( Optional.ofNullable(Application.get().getMarkupSettings().getDefaultMarkupEncoding()) .orElse(StandardCharsets.UTF_8.name()))); MarkupParser markupParser = new MarkupParser(new MarkupResourceStream(stringResourceStream)); markupParser.setWicketNamespace(MarkupParser.WICKET); Markup markup; try { markup = markupParser.parse(); } catch (Exception e) { throw SingularUtil.propagate(e); } // If child == null, than return the markup fragment starting // with <wicket:panel> if (child == null) { return markup; } // Copiado da superclasse. buscando markup do child IMarkupFragment associatedMarkup = markup.find(child.getId()); if (associatedMarkup != null) { return associatedMarkup; } associatedMarkup = searchMarkupInTransparentResolvers(parent, parent.getMarkup(), child); if (associatedMarkup != null) { return associatedMarkup; } return findMarkupInAssociatedFileHeader(parent, child); } @Override public void onComponentTagBody(Component component, MarkupStream markupStream, ComponentTag openTag) { TemplatePanel.this.onBeforeComponentTagBody(markupStream, openTag); super.onComponentTagBody(component, markupStream, openTag); TemplatePanel.this.onAfterComponentTagBody(markupStream, openTag); } }; }
From source file:org.patientview.radar.web.pages.patient.srns.SrnsPatientPageReadOnly.java
License:Open Source License
public SrnsPatientPageReadOnly(PageParameters parameters) { super(parameters); //a patient cannot edit so hide and disable stuff so only a read only view is available visitChildren(new IVisitor<Component, Object>() { public void component(Component component, IVisit<Object> objectIVisit) { RadarSecuredSession session = RadarSecuredSession.get(); if (session.get().isSignedIn()) { if (session.getRoles().hasRole(User.ROLE_PATIENT)) { if (component instanceof FormComponent) { component.setEnabled(false); }/*ww w .j ava 2 s. com*/ if (component instanceof AjaxSubmitLink) { component.setVisible(false); } for (String regexToHide : Arrays.asList("\\w*edit\\w*(container|form)", "\\w*delete\\w*(container|form)", "\\w*add\\w*(container|form)", "\\w*addnew\\w*")) { Matcher matcher = Pattern.compile(regexToHide, Pattern.CASE_INSENSITIVE) .matcher(component.getId().toLowerCase()); if (matcher.matches()) { component.setVisible(false); } } for (String regexToEnable : Arrays.asList("\\w*switcher\\w*")) { Matcher matcher = Pattern.compile(regexToEnable, Pattern.CASE_INSENSITIVE) .matcher(component.getId().toLowerCase()); if (matcher.matches()) { component.setEnabled(true); } } } } } }); }
From source file:org.patientview.radar.web.visitors.PatientFormVisitor.java
License:Open Source License
public void component(Component component, IVisit iVisit) { //add onkeyup event to date to santise input - tried attaching behaviour in the component class itself // but did not work if (component instanceof RadarDateTextField || component instanceof RadarRequiredDateTextField) { component.add(new AttributeModifier("onkeyup", "radarUtility.sanitiseDateInput(this);")); }/*ww w . j a v a 2s . co m*/ // add validator to date components - adding it inside the component constructor does not work if (component instanceof RadarDateTextField || component instanceof RadarRequiredDateTextField) { component.add(new RadarDateValidator()); } //if form component - mark form as dirty onchange if (component instanceof FormComponent || component instanceof Radio) { // ignore the subform components String[] ignoreParents = { "immunosuppression", "plasmapheresispanel", "dialysiscontainer", "transplantscontainer", "rejectDataContainer", "editTransplantContainer", "addTransplantForm" }; // ignore record switchers String[] ignoreIds = { "switcher" }; boolean ignoreComponent = false; for (String ignore : ignoreParents) { if (component.getPath().toLowerCase().contains(ignore.toLowerCase())) { ignoreComponent = true; break; } } for (String ignore : ignoreIds) { if (component.getId().toLowerCase().contains(ignore.toLowerCase())) { ignoreComponent = true; break; } } if (!ignoreComponent) { component.add(new AttributeAppender("onchange", RadarApplication.FORM_IS_DIRTY_TRUE_SCRIPT)); } } }
From source file:org.projectforge.web.wicket.WicketPageTestBase.java
License:Open Source License
/** * Searches FormComponents (model object), LabeledWebmarkupContainers (label model) and ContentMenuEntryPanels (label). * @param container//from ww w . jav a2s . c o m * @param label i18n key of the label or label (for buttons). * @return Found component with the given label or null if no such component found. * @see FormComponent#getModelObject() * @see LabeledWebMarkupContainer#getLabel() * @see ContentMenuEntryPanel#getLabel() */ public Component findComponentByLabel(final MarkupContainer container, final String label) { String str = label; try { str = container.getString(label); } catch (final MissingResourceException ex) { // OK } final String locLabel = str; final Component[] component = new Component[1]; container.visitChildren(new IVisitor<Component, Void>() { @Override public void component(final Component object, final IVisit<Void> visit) { if (object instanceof AbstractLink) { final MarkupContainer parent = object.getParent(); if (parent instanceof ContentMenuEntryPanel) { if (labelEquals(((ContentMenuEntryPanel) parent).getLabel(), label, locLabel) == true) { component[0] = object; visit.stop(); } } else if (object.getId().equals(locLabel) == true) { component[0] = object; visit.stop(); } } else { if (object instanceof LabeledWebMarkupContainer) { final IModel<String> labelModel = ((LabeledWebMarkupContainer) object).getLabel(); if (labelModel != null) { if (labelEquals(labelModel.getObject(), label, locLabel) == true) { component[0] = object; visit.stop(); } } } if (object instanceof FormComponent<?>) { final Object modelObject = ((FormComponent<?>) object).getModelObject(); if (modelObject instanceof String) { if (labelEquals((String) modelObject, label, locLabel) == true) { component[0] = object; visit.stop(); } } } } } }); return component[0]; }
From source file:org.sakaiproject.dash.tool.panels.CalendarLinksPanel.java
License:Educational Community License
/** * @param rl//from ww w. j av a2 s . co m * @param calendarLinksDiv * @param calendarDataView */ protected void renderItemCounter(WebMarkupContainer calendarLinksDiv, DataView<CalendarLink> calendarDataView) { ResourceLoader rl = new ResourceLoader("dash_entity"); if (calendarLinksCountId != null) { Iterator itx = calendarLinksDiv.iterator(); while (itx.hasNext()) { Component child = (Component) itx.next(); if (calendarLinksCountId.equals(child.getId())) { calendarLinksDiv.remove(child); break; } } } int itemCount = 0; String pagerStatus = ""; if (calendarDataView != null) { int first = 0; int last = 0; itemCount = calendarDataView.getItemCount(); int pageSize = calendarDataView.getItemsPerPage(); if (itemCount > pageSize) { int page = calendarDataView.getCurrentPage(); first = page * pageSize + 1; last = Math.min(itemCount, (page + 1) * pageSize); if (first == last) { pagerStatus = rl.getFormattedMessage("dash.calendar.linksCount2", new Object[] { new Integer(first), new Integer(itemCount) }); } else { pagerStatus = rl.getFormattedMessage("dash.calendar.linksCount3", new Object[] { new Integer(first), new Integer(last), new Integer(itemCount) }); } } else if (itemCount > 1) { pagerStatus = rl.getFormattedMessage("dash.calendar.linksCount3", new Object[] { new Integer(1), new Integer(itemCount), new Integer(itemCount) }); } else if (itemCount > 0) { pagerStatus = rl.getString("dash.calendar.linksCount1"); } else { pagerStatus = rl.getString("dash.calendar.linksCount0"); } } Label calendarLinksCount = new Label("calendarLinksCount", pagerStatus); // add the count to the calendarLinksDiv calendarLinksDiv.add(calendarLinksCount); calendarLinksCountId = calendarLinksCount.getId(); }
From source file:org.sakaiproject.dash.tool.panels.MOTDPanel.java
License:Educational Community License
/** * @param rl/* w w w.j a v a2 s. c om*/ * @param motdDiv * @param newsDataView */ protected void renderItemCounter(final WebMarkupContainer motdDiv, final DataView<NewsItem> newsDataView) { ResourceLoader rl = new ResourceLoader("dash_entity"); if (motdCountId != null) { Iterator itx = motdDiv.iterator(); while (itx.hasNext()) { Component child = (Component) itx.next(); if (motdCountId.equals(child.getId())) { motdDiv.remove(child); break; } } } int itemCount = 0; String pagerStatus = ""; if (newsDataView != null) { int first = 0; int last = 0; itemCount = newsDataView.getItemCount(); int pageSize = newsDataView.getItemsPerPage(); if (itemCount > pageSize) { int page = newsDataView.getCurrentPage(); first = page * pageSize + 1; last = Math.min(itemCount, (page + 1) * pageSize); if (first == last) { pagerStatus = rl.getFormattedMessage("dash.news.linksCount2", new Object[] { new Integer(first), new Integer(itemCount) }); } else { pagerStatus = rl.getFormattedMessage("dash.news.linksCount3", new Object[] { new Integer(first), new Integer(last), new Integer(itemCount) }); } } else if (itemCount > 1) { pagerStatus = rl.getFormattedMessage("dash.news.linksCount3", new Object[] { new Integer(1), new Integer(itemCount), new Integer(itemCount) }); } else if (itemCount > 0) { pagerStatus = rl.getString("dash.news.linksCount1"); } else { pagerStatus = rl.getString("dash.news.linksCount0"); } } Label motdCount = new Label("motdCount", pagerStatus); motdCount.setOutputMarkupId(true); // add the count to the motdDiv motdDiv.add(motdCount); motdCountId = motdCount.getId(); }
From source file:org.sakaiproject.dash.tool.panels.NewsLinksPanel.java
License:Educational Community License
/** * @param rl//from w w w.j av a2s. c om * @param newsLinksDiv * @param newsDataView */ protected void renderItemCounter(final WebMarkupContainer newsLinksDiv, final DataView<NewsLink> newsDataView) { ResourceLoader rl = new ResourceLoader("dash_entity"); if (newsLinksCountId != null) { Iterator itx = newsLinksDiv.iterator(); while (itx.hasNext()) { Component child = (Component) itx.next(); if (newsLinksCountId.equals(child.getId())) { newsLinksDiv.remove(child); break; } } } int itemCount = 0; String pagerStatus = ""; if (newsDataView != null) { int first = 0; int last = 0; itemCount = newsDataView.getItemCount(); int pageSize = newsDataView.getItemsPerPage(); if (itemCount > pageSize) { int page = newsDataView.getCurrentPage(); first = page * pageSize + 1; last = Math.min(itemCount, (page + 1) * pageSize); if (first == last) { pagerStatus = rl.getFormattedMessage("dash.news.linksCount2", new Object[] { new Integer(first), new Integer(itemCount) }); } else { pagerStatus = rl.getFormattedMessage("dash.news.linksCount3", new Object[] { new Integer(first), new Integer(last), new Integer(itemCount) }); } } else if (itemCount > 1) { pagerStatus = rl.getFormattedMessage("dash.news.linksCount3", new Object[] { new Integer(1), new Integer(itemCount), new Integer(itemCount) }); } else if (itemCount > 0) { pagerStatus = rl.getString("dash.news.linksCount1"); } else { pagerStatus = rl.getString("dash.news.linksCount0"); } } Label newsLinksCount = new Label("newsLinksCount", pagerStatus); newsLinksCount.setOutputMarkupId(true); // add the count to the newsLinksDiv newsLinksDiv.add(newsLinksCount); newsLinksCountId = newsLinksCount.getId(); }
From source file:org.wicketstuff.extjs.util.ExtConfigResourceLoader.java
License:Apache License
protected String getCacheKey(final String key, final Component component) { String cacheKey = key;/*from ww w . j av a 2 s. c om*/ if (component != null) { AppendingStringBuffer buffer = new AppendingStringBuffer(200); buffer.append(key); Component cursor = component; while (cursor != null) { buffer.append("-").append(cursor.getClass().hashCode()); if (cursor instanceof Page) { break; } if (cursor.getParent() != null && !(cursor.getParent() instanceof AbstractRepeater)) { /* * only append component id if parent is not a repeater because * * (a) these ids are irrelevant when generating resource cache keys * * (b) they cause a lot of redundant keys to be generated */ buffer.append(":").append(cursor.getId()); } cursor = cursor.getParent(); } buffer.append("-").append(component.getLocale()); buffer.append("-").append(component.getStyle()); // TODO 1.4 look if we want to properly separate getstyle/getvariation // for now getvariation() is rolled up into getstyle() // buffer.append("-").append(component.getVariation()); cacheKey = buffer.toString(); } return cacheKey; }
From source file:org.wicketstuff.poi.excel.TablesComponentAsXlsHandler.java
License:Apache License
/** * Create the sheet in where component table data will be set * * @return a new {@link Sheet} to receive the table component data *//*from w w w . j av a 2 s .c o m*/ protected Sheet newSheet(Workbook workbook, Component component, int index) { return workbook.createSheet("Worksheet " + component.getId()); }