List of usage examples for org.apache.wicket.extensions.markup.html.tabs ITab getPanel
WebMarkupContainer getPanel(final String containerId);
From source file:au.org.theark.core.web.component.tabbedPanel.DynamicTabbedPanel.java
License:Open Source License
/** * sets the selected tab//from w w w. jav a2s . c o m * * @param index * index of the tab to select * @return this for chaining */ public DynamicTabbedPanel setSelectedTab(final int index) { if ((index < 0) || ((index >= tabModel.getObject().size()) && (index > 0))) { throw new IndexOutOfBoundsException(); } setDefaultModelObject(index); final Component component; if ((tabModel.getObject().size() == 0) || !isTabVisible(index)) { // no tabs or the currently selected tab is not visible component = new EmptyPanel(TAB_PANEL_ID); } else { // show panel from selected tab ITab tab = tabModel.getObject().get(index); component = tab.getPanel(TAB_PANEL_ID); if (component == null) { throw new WicketRuntimeException("ITab.getPanel() returned null. TabbedPanel [" + getPath() + "] ITab index [" + index + "]"); } } if (!component.getId().equals(TAB_PANEL_ID)) { throw new WicketRuntimeException("ITab.getPanel() returned a panel with invalid id [" + component.getId() + "]. You must always return a panel with id equal to the provided panelId parameter. TabbedPanel [" + getPath() + "] ITab index [" + index + "]"); } addOrReplace(component); return this; }
From source file:ca.travelagency.identity.SystemUserPageTest.java
License:Apache License
private void validateTabPanel(ITab tab, Class<?> clazz) { Assert.assertEquals(clazz.getName(), tab.getPanel("containerId").getClass().getName()); }
From source file:com.googlecode.wicket.jquery.ui.widget.accordion.AccordionPanel.java
License:Apache License
@Override protected void onInitialize() { super.onInitialize(); this.add(new Loop("tabs", this.getCountModel()) { private static final long serialVersionUID = 1L; @Override// w ww. ja v a2 s . c om protected void populateItem(LoopItem item) { int index = item.getIndex(); final ITab tab = AccordionPanel.this.getModelObject().get(index); if (tab.isVisible()) { item.add(AccordionPanel.this.newTitleLabel("title", tab.getTitle())); item.add(tab.getPanel("panel")); } } }); this.add(this.widgetBehavior = this.newWidgetBehavior(JQueryWidget.getSelector(this))); }
From source file:com.googlecode.wicket.jquery.ui.widget.tabs.TabbedPanel.java
License:Apache License
@Override protected void onInitialize() { super.onInitialize(); final RepeatingView panels = new RepeatingView("panels") { private static final long serialVersionUID = 1L; @Override/*from w w w . j a va 2 s .c o m*/ public String newChildId() { return String.format("tab-%s-%s", this.getMarkupId(), super.newChildId()); //fixes issue #14 } @Override protected void onConfigure() { super.onConfigure(); this.removeAll(); //fixes issue #7 } }; this.add(panels); this.add(new ListView<ITab>("tabs", this.getModelObject()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<ITab> item) { final ITab tab = item.getModelObject(); if (tab.isVisible()) { final String newId = panels.newChildId(); // link (tab) // Label link = TabbedPanel.this.newTitleLabel("link", tab.getTitle()); link.add(AttributeModifier.replace("href", "#" + newId)); item.add(link); // panel // panels.add(tab.getPanel(newId).setMarkupId(newId).setOutputMarkupId(true)); } } }); this.add(this.widgetBehavior = this.newWidgetBehavior(JQueryWidget.getSelector(this))); }
From source file:com.googlecode.wicket.kendo.ui.widget.accordion.AccordionPanel.java
License:Apache License
@Override protected void onInitialize() { super.onInitialize(); final WebMarkupContainer root = new WebMarkupContainer("root"); this.add(root); root.add(new Loop("tabs", this.getCountModel()) { private static final long serialVersionUID = 1L; @Override//from w ww.j a v a2 s. co m protected LoopItem newItem(final int index) { ITab tab = AccordionPanel.this.getModelObject().get(index); LoopItem item = super.newItem(index); item.setVisible(tab.isVisible()); return item; } @Override protected void populateItem(LoopItem item) { int index = item.getIndex(); final ITab tab = AccordionPanel.this.getModelObject().get(index); item.add(AccordionPanel.this.newTitleLabel("title", tab.getTitle())); item.add(tab.getPanel("panel")); } }); this.widgetBehavior = JQueryWidget.newWidgetBehavior(this, root); this.add(this.widgetBehavior); }
From source file:com.googlecode.wicket.kendo.ui.widget.tabs.TabbedPanel.java
License:Apache License
@Override protected void onInitialize() { super.onInitialize(); final RepeatingView panels = new RepeatingView("panels") { private static final long serialVersionUID = 1L; @Override// ww w . j a v a2s .co m public String newChildId() { return String.format("tab-%s-%s", this.getMarkupId(), super.newChildId()); } @Override protected void onConfigure() { super.onConfigure(); this.removeAll(); } }; this.add(panels); this.add(new ListView<ITab>("tabs", this.getModelObject()) { private static final long serialVersionUID = 1L; @Override protected ListItem<ITab> newItem(int index, IModel<ITab> model) { ListItem<ITab> item = super.newItem(index, model); item.setVisible(model.getObject().isVisible()); return item; } @Override protected void populateItem(ListItem<ITab> item) { final ITab tab = item.getModelObject(); if (tab.isVisible()) { // link (tab) // item.add(TabbedPanel.this.newTitleLabel("title", tab.getTitle())); // panel // final String newId = panels.newChildId(); panels.add(tab.getPanel(newId).setMarkupId(newId).setOutputMarkupId(true)); } } }); this.widgetBehavior = JQueryWidget.newWidgetBehavior(this); this.add(this.widgetBehavior); }
From source file:com.googlecode.wicketwebbeans.containers.BeanForm.java
License:Apache License
/** * Rather than using Wicket's required field validation, which doesn't play well with Ajax and forms, * allow validation of fields on actions. User must call this from the action method. * Adds errors to the page if empty required fields are found. * * @return true if validation was successful, else false if errors were found. *///w w w.j a va 2 s .c o m public boolean validateRequired() { RequiredFieldValidator validator = new RequiredFieldValidator(); // If we have a tabbed panel, we have to go thru each tab and validate it because the components for a tab are only created // when the tab is open. if (tabbedPanel == null) { visitChildren(AbstractField.class, validator); } else { for (ITab tab : tabbedPanel.getTabs()) { Panel panel = tab.getPanel("x"); // Needs to be part of the page for errors. getPage().add(panel); // Cause ListViews to be populated. panel.beforeRender(); panel.visitChildren(AbstractField.class, validator); getPage().remove(panel); } } return !validator.errorsFound; }
From source file:org.artifactory.webapp.wicket.page.config.repos.RepoTabbedPanel.java
License:Open Source License
@Override public TabbedPanel setSelectedTab(int index) { setDefaultModelObject(index);//from w ww .ja va 2s . c o m ITab tab = getTabs().get(index); final Component component = tab.getPanel(TAB_PANEL_ID); component.add(new ScrollDivBehavior()); addOrReplace(component); return this; }
From source file:org.hippoecm.frontend.plugins.standards.tabs.TabbedPanel.java
License:Apache License
public void setSelectedTab(int index) { if (index >= tabs.size()) { // panelContainer.replace(plugin.getEmptyPanel()); return;/*from w w w . j av a 2 s .c o m*/ } setDefaultModelObject(index); if (index < 0) { cardView.select(null); return; } ITab tab = tabs.get(index); WebMarkupContainer panel = tab.getPanel(TAB_PANEL_ID); if (panel == null) { throw new WicketRuntimeException( "ITab.getPanel() returned null. TabbedPanel [" + getPath() + "] ITab index [" + index + "]"); } if (!panel.getId().equals(TAB_PANEL_ID)) { throw new WicketRuntimeException("ITab.getPanel() returned a panel with invalid id [" + panel.getId() + "]. You must always return a panel with id equal to the provided panelId parameter. TabbedPanel [" + getPath() + "] ITab index [" + index + "]"); } cardView.select((TabsPlugin.Tab) tab); // panelContainer.replace(panel); }
From source file:org.jabylon.rest.ui.wicket.components.ClientSideTabbedPanel.java
License:Open Source License
public ClientSideTabbedPanel(final String id, List<T> tabs, boolean vertical, String persistenceKey) { super(id);/* ww w. ja v a 2 s. c o m*/ WebMarkupContainer tabbable = new WebMarkupContainer("tabbable"); if (vertical) { tabbable.add(new AttributeAppender("class", " tabs-left")); } if (persistenceKey != null) { tabbable.add(new AttributeModifier("data-tabsheet", persistenceKey)); } add(tabbable); ListView<T> listView = new ListView<T>("tab-handles", tabs) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<T> item) { int index = item.getIndex(); if (index == activeTab.getObject()) item.add(new AttributeAppender("class", " active")); item.add(new ExternalLink("link", Model.of("#" + id + index), item.getModelObject().getTitle())); } }; listView.setReuseItems(true); tabContents = new ArrayList<WebMarkupContainer>(); ListView<T> tabContent = new ListView<T>("tab-content", tabs) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<T> item) { int index = item.getIndex(); if (index == activeTab.getObject()) item.add(new AttributeAppender("class", " active")); item.setMarkupId(id + index); Object object = item.getDefaultModelObject(); if (object instanceof ITab) { ITab tab = (ITab) object; WebMarkupContainer panel = tab.getPanel("content"); panel.setOutputMarkupId(true); tabContents.add(panel); item.add(panel); } } }; tabContent.setReuseItems(true); tabbable.add(tabContent); tabbable.add(listView); }