List of usage examples for org.apache.wicket.markup.html WebMarkupContainer removeAll
public MarkupContainer removeAll()
From source file:hsa.awp.admingui.rule.RuleCreatePanel.java
License:Open Source License
/** * Creates a new {@link RuleCreatePanel}. * * @param id wicket-id./*from w w w. j av a 2 s. c o m*/ */ public RuleCreatePanel(String id) { super(id); Form<Rule> form = new Form<Rule>("rule.create.form"); add(form); form.setOutputMarkupId(true); final WebMarkupContainer ruleContainer = new WebMarkupContainer("rule.create.container"); add(ruleContainer); ruleContainer.setOutputMarkupId(true); ruleContainer.add(new EmptyRulePanel("rule.create.container.createPanel")); final DropDownChoice<String> choices = new DropDownChoice<String>("rule.create.typeSelect", new Model<String>(), RuleType.getNames()); form.add(choices); choices.setOutputMarkupId(true); choices.add(new OnChangeAjaxBehavior() { /** * unique serialization id. */ private static final long serialVersionUID = 5597414843387619927L; @Override protected void onUpdate(AjaxRequestTarget target) { target.addComponent(ruleContainer); try { RuleType ruleType = RuleType.findByName((String) choices.getDefaultModelObject()); ruleContainer.removeAll(); Panel panel; if (ruleType == null) { panel = new EmptyRulePanel("rule.create.container.createPanel"); } else { Constructor<? extends Panel> constructor = ruleType.getRulePanel() .getConstructor(new Class[] { String.class }); panel = constructor.newInstance(new Object[] { "rule.create.container.createPanel" }); } ruleContainer.add(panel); } catch (Exception e) { e.printStackTrace(); getLogger().error(e.toString()); return; } } }); }
From source file:net.rrm.ehour.ui.common.panel.entryselector.EntrySelectorPanel.java
License:Open Source License
private void addHideInactiveFilter(Form<Void> form) { final HideInactiveFilter hideInactiveFilter = new HideInactiveFilter(); hideInactiveFilter.setHideInactive(getEhourWebSession().getHideInactiveSelections()); final WebMarkupContainer filterIcon = new WebMarkupContainer("filterIcon"); addFilterIconAttributes(filterIcon, getEhourWebSession().getHideInactiveSelections()); filterIcon.setOutputMarkupId(true);//from ww w.jav a 2s . c om final AjaxLink<Void> hideInactiveLink = new AjaxLink<Void>("filterToggle") { @Override public void onClick(AjaxRequestTarget target) { Boolean hideInactiveSelections = getEhourWebSession().toggleHideInactiveSelections(); HideInactiveFilter inactiveFilter = new HideInactiveFilter(hideInactiveSelections); send(getPage(), Broadcast.DEPTH, new InactiveFilterChangedEvent(inactiveFilter, target)); target.appendJavaScript(jsRefresh()); filterIcon.removeAll(); addFilterIconAttributes(filterIcon, getEhourWebSession().getHideInactiveSelections()); target.add(filterIcon); } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getAjaxCallListeners().add(new LoadingSpinnerDecorator()); } }; hideInactiveLink.setVisible(showHideInactiveLink); hideInactiveLink.add(filterIcon); form.add(hideInactiveLink); }