List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink AjaxLink
public AjaxLink(final String id)
From source file:name.martingeisse.webeco.SimulatorPage.java
License:Open Source License
/** * Constructor.//from w ww .ja v a2 s .c om */ public SimulatorPage() { final GuiMessageHub guiMessageHub = Simulator.getGuiMessageHub(); final CharacterDisplayPanel characterDisplayPanel = new CharacterDisplayPanel("characterDisplayPanel", guiMessageHub.getCharacterDisplayQueue()); add(characterDisplayPanel); final QueueTextFeeder feeder = new QueueTextFeeder("text", guiMessageHub.getTerminalOutputQueue()); add(feeder); add(new AbstractAjaxTimerBehavior(Duration.seconds(1)) { @Override protected void onTimer(final AjaxRequestTarget target) { characterDisplayPanel.feed(target); feeder.feed(target); } }); final Form<Void> inputForm = new Form<Void>("inputForm"); add(inputForm); final TextField<String> inputLineTextField = new TextField<String>("text", new PropertyModel<String>(this, "inputLine")); inputLineTextField.setOutputMarkupId(true); inputForm.add(inputLineTextField); inputForm.add(new AjaxButton("submit", inputForm) { @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { inputLine = (inputLine == null) ? "" : inputLine; guiMessageHub.getTerminalInputQueue().add(inputLine + "\r\n"); notifyTerminalInputAvailable(); inputLine = null; target.add(inputLineTextField); } @Override protected void onError(AjaxRequestTarget arg0, Form<?> arg1) { } }); final WebMarkupContainer backspaceButton = new WebMarkupContainer("backspaceButton"); add(backspaceButton); backspaceButton.add(new AjaxEventBehavior("onclick") { @Override protected void onEvent(final AjaxRequestTarget target) { guiMessageHub.getTerminalInputQueue().add("\b"); notifyTerminalInputAvailable(); } }); add(new AjaxLink<Void>("resetLink") { @Override public void onClick(AjaxRequestTarget target) { guiMessageHub.getActions().add(new ISimulatorAction() { @Override public void execute(SimulationModel model) { model.getCpu().reset(); } }); } }); }
From source file:name.martingeisse.webide.experiment.PushTestPage.java
License:Open Source License
/** * Constructor.//from w w w. j av a 2 s . com */ public PushTestPage() { setStatelessHint(false); final Application application = getApplication(); add(new AjaxLink<Void>("link") { @Override public void onClick(AjaxRequestTarget target) { new Timer().schedule(new TimerTask() { @Override public void run() { status = "idle "; EventBus.get(application).post(new MyMessage()); } }, 5000); status = "running ..."; target.add(PushTestPage.this.get("status")); } }); add(new Label("status", new PropertyModel<String>(this, "status")).setOutputMarkupId(true)); }
From source file:name.martingeisse.webide.features.simvm.editor.SimulatorControlPanel.java
License:Open Source License
/** * Constructor.// ww w. ja va 2 s .c o m * @param id the wicket id * @param model the model */ public SimulatorControlPanel(final String id, final IModel<SimulatedVirtualMachine> model) { super(id, model); setOutputMarkupId(true); // create components add(new AjaxLink<Void>("startButton") { @Override public void onClick(AjaxRequestTarget target) { getVirtualMachine().startSimulation(); getVirtualMachine().resume(); if (getVirtualMachine().getState() != SimulationState.STOPPED) { target.add(SimulatorControlPanel.this); } } /* (non-Javadoc) * @see org.apache.wicket.ajax.markup.html.AjaxLink#onComponentTag(org.apache.wicket.markup.ComponentTag) */ @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); if (getVirtualMachine().getState() != SimulationState.STOPPED) { tag.append("style", "display: none", "; "); } } }); add(new AjaxLink<Void>("terminateButton") { @Override public void onClick(AjaxRequestTarget target) { getVirtualMachine().terminate(); if (getVirtualMachine().getState() == SimulationState.STOPPED) { target.add(SimulatorControlPanel.this); } } /* (non-Javadoc) * @see org.apache.wicket.ajax.markup.html.AjaxLink#onComponentTag(org.apache.wicket.markup.ComponentTag) */ @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); if (getVirtualMachine().getState() == SimulationState.STOPPED) { tag.append("style", "display: none", "; "); } } }); }
From source file:net.dontdrinkandroot.extensions.wicket.component.button.DropDownChoiceButton.java
License:Apache License
protected void populateItem(final ListItem<T> item) { final AjaxLink<Void> choiceLink = new AjaxLink<Void>("choiceLink") { @Override/*from w w w . j a v a 2 s. c o m*/ public void onClick(AjaxRequestTarget target) { DropDownChoiceButton.this.onSelectionChanged(target, item.getModelObject()); } }; choiceLink.setBody(new ChoiceModel(item.getModel())); item.add(choiceLink); }
From source file:net.dontdrinkandroot.wicket.bootstrap.component.button.ButtonGroupChoice.java
License:Apache License
public ButtonGroupChoice(String id, IModel<T> model, IModel<List<T>> choicesModel) { super(id, model); this.setOutputMarkupId(true); this.add(new CssClassAppender(BootstrapCssClass.BTN_GROUP)); final RepeatingView choicesView = new RepeatingView("choice"); choicesView.setOutputMarkupId(true); this.add(choicesView); for (final T choice : choicesModel.getObject()) { AjaxLink<Void> choiceLink = new AjaxLink<Void>(choicesView.newChildId()) { @Override/*from w ww . ja v a 2 s. co m*/ public void onClick(AjaxRequestTarget target) { ButtonGroupChoice.this.onSelectionChanged(choice, target); } }; choiceLink.setBody(this.getDisplayModel(choice)); choiceLink.add(new CssClassAppender(new Model<BootstrapCssClass>() { @Override public BootstrapCssClass getObject() { if (ButtonGroupChoice.this.getModelObject().equals(choice)) { super.getObject(); } return null; } })); choicesView.add(choiceLink); } }
From source file:net.dontdrinkandroot.wicket.bootstrap.component.button.DropDownChoiceButton.java
License:Apache License
@Override protected void onInitialize() { super.onInitialize(); this.setOutputMarkupId(true); this.add(new CssClassAppender(BootstrapCssClass.BTN_GROUP)); this.add(new CssClassAppender("dropdownchoice")); Label selectedLabel = new Label("selected", new ChoiceModel(this.getModel())); selectedLabel.add(new CssClassAppender("selection")); this.add(selectedLabel); ListView<T> choicesView = new ListView<T>("choiceItem", this.choicesModel) { @Override/*ww w .j a v a2 s.c om*/ protected void populateItem(final ListItem<T> item) { AjaxLink<Void> choiceLink = new AjaxLink<Void>("choiceLink") { @Override public void onClick(AjaxRequestTarget target) { DropDownChoiceButton.this.onSelectionChanged(target, item.getModelObject()); } }; choiceLink.setBody(new ChoiceModel(item.getModel())); item.add(choiceLink); } }; this.add(choicesView); this.valueInputField = new HiddenField<T>("valueInput", this.getModel(), this.type); this.add(this.valueInputField); }
From source file:net.form105.web.base.component.command.CommandPanel.java
License:Apache License
@SuppressWarnings("unchecked") private ListView createListView() { ListView lView = new ListView("commandLabels", linkList) { private static final long serialVersionUID = 1L; @Override//from ww w . j a v a 2s. com protected void populateItem(ListItem item) { IPageAction action = (IPageAction) item.getModelObject(); SubmitLink submitLink; if (action instanceof AbstractFormAction) { AbstractFormAction<T> formAction = (AbstractFormAction<T>) action; submitLink = new SubmitLink("commandLink", formAction.getForm()) { private static final long serialVersionUID = 1L; public void onSubmit() { setResponsePage(this.getPage()); } }; Label label = new Label("commandLabel", formAction.getName()); submitLink.add(label); item.add(submitLink); } else if (action instanceof IAjaxLinkToPanelAction) { IAjaxLinkToPanelAction ajaxLinkAction = (IAjaxLinkToPanelAction) action; AjaxLink ajaxLink = new AjaxLink("commandLink") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { Page page = getPage(); ((BasePage) page).ajaxRequestReceived(target, null, EventType.ADD_EVENT); } }; Label label = new Label("commandLabel", ajaxLinkAction.getName()); ajaxLink.add(label); item.add(ajaxLink); } else if (action instanceof IAjaxLinkToModalWindowAction) { IAjaxLinkToModalWindowAction ajaxModalAction = (IAjaxLinkToModalWindowAction) action; AjaxLink ajaxLink = new AjaxLink("commandLink") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { Page page = getPage(); ((BasePage) page).ajaxRequestReceived(target, null, EventType.ADD_MODAL); } }; Label label = new Label("commandLabel", ajaxModalAction.getName()); ajaxLink.add(label); item.add(ajaxLink); } } }; return lView; }
From source file:net.kornr.swit.site.buttoneditor.ButtonEditor.java
License:Apache License
private void init() { this.innerAdd(new Image("logo", ButtonResource.getReference(), ButtonResource.getValueMap(s_logoTemplate, "The Swit Buttons Generator"))); m_codeEncoder = new ButtonCodeMaker(m_selectedDescriptor, m_currentProperties, new PropertyModel<String>(this, "text")); final Form form = new Form("form") { @Override//from w w w .j ava 2s . c o m protected void onSubmit() { if (((WebRequest) (WebRequestCycle.get().getRequest())).isAjax() == false) createButton(null); } }; this.innerAdd(form); Border sampleborder = new TableImageBorder("sampleborder", s_border3, Color.white); form.add(sampleborder); WebMarkupContainer samplecont = new WebMarkupContainer("samplecontainer"); sampleborder.add(samplecont); samplecont.add((m_sample = new Image("sample")).setOutputMarkupId(true)); sampleborder .add(new ColorPickerField("samplebgcolor", new PropertyModel<String>(this, "bgcolor"), samplecont)); ImageButton submit = new ImageButton("submit", ButtonResource.getReference(), ButtonResource.getValueMap(s_buttonTemplate, "Update that button, now!")); sampleborder.add(submit); submit.add(new AjaxFormSubmitBehavior(form, "onclick") { @Override protected void onError(AjaxRequestTarget arg0) { } @Override protected void onSubmit(AjaxRequestTarget target) { createButton(target); } @Override protected CharSequence getEventHandler() { return new AppendingStringBuffer(super.getEventHandler()).append("; return false;"); } }); sampleborder.add(m_downloadLink = new MutableResourceReferenceLink("downloadbutton", ButtonResource.getReference(), null)); m_downloadLink.setOutputMarkupId(true); // this.innerAdd(m_codeLabel = new Label("code", new PropertyModel(m_codeEncoder, "code"))); // m_codeLabel.setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true).setEscapeModelStrings(false); // m_codeLabel.setVisible(true); final ModalWindow codewindow = new ModalWindow("code"); this.innerAdd(codewindow); Fragment codefrag = new Fragment(codewindow.getContentId(), "codepanel", this); Label lcode = new Label("code", new PropertyModel(m_codeEncoder, "code")); codefrag.add(lcode); codewindow.setContent(codefrag); codewindow.setTitle("Java Code"); codewindow.setCookieName("switjavacodewindow"); sampleborder.add(new AjaxLink("showwindowcode") { @Override public void onClick(AjaxRequestTarget target) { codewindow.show(target); } }); form.add((m_feedback = new FeedbackPanel("feedback")).setOutputMarkupId(true) .setOutputMarkupPlaceholderTag(true)); ThreeColumnsLayoutManager layout = new ThreeColumnsLayoutManager("2col-layout", s_layout); form.add(layout); ColumnPanel rightcol = layout.getRightColumn(); ColumnPanel leftcol = layout.getLeftColumn(); Border textborder = new TableImageBorder("textborder", s_shadow, s_blocColor); layout.add(textborder); textborder.add(new TextField<String>("button-text", new PropertyModel<String>(this, "text"))); Border buttonsborder = new TableImageBorder("buttonsborder", s_shadow, s_blocColor); layout.add(buttonsborder); buttonsborder.add(new ListView<ButtonDescriptor>("types", s_buttons) { @Override protected void populateItem(ListItem<ButtonDescriptor> item) { final IModel<ButtonDescriptor> model = item.getModel(); ButtonDescriptor bd = item.getModelObject(); ButtonTemplate tmpl = s_buttonsTemplates.get(bd.getName()); if (tmpl == null) { tmpl = bd.createTemplate(); try { List<ButtonProperty> props = bd.getProperties(); bd.applyProperties(tmpl, props); tmpl.setWidth(200); tmpl.setFont(s_defaultButtonFont); tmpl.setFontColor(Color.white); tmpl.setShadowDisplayed(true); tmpl.addEffect(new ShadowBorder(4, 0, 0, Color.black)); tmpl.setAutoExtend(true); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } s_buttonsTemplates.put(bd.getName(), tmpl); } ImageButton button = new ImageButton("sample", ButtonResource.getReference(), ButtonResource.getValueMap(tmpl, bd.getName())); item.add(button); button.add(new AjaxFormSubmitBehavior(form, "onclick") { @Override protected void onError(AjaxRequestTarget arg0) { } @Override protected void onSubmit(AjaxRequestTarget target) { m_selectedDescriptor = model.getObject(); m_currentProperties = m_selectedDescriptor.getProperties(); if (target != null) { // target.addComponent(m_properties); } createButton(target); } @Override protected CharSequence getEventHandler() { String hider = getJQueryCodeForPropertiesHiding(model.getObject()); return new AppendingStringBuffer(hider + ";" + super.getEventHandler()) .append("; return false;"); } }); } }); m_properties = new TableImageBorder("propertiesborder", s_shadow, s_blocColor); layout.add(m_properties); m_properties.setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true); m_currentProperties = m_selectedDescriptor.getProperties(); m_propEditors = new ListView<ButtonDescriptor>("property", s_buttons) { @Override protected void populateItem(ListItem<ButtonDescriptor> item) { ButtonDescriptor desc = item.getModelObject(); WebMarkupContainer container = new WebMarkupContainer("container"); item.add(container); PropertyListEditor lst = new PropertyListEditor("lst", desc.getProperties()); container.add(lst); container.setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true); m_propertiesContainer.add(new Pair(desc.getName(), container)); } }; m_properties.add(m_propEditors); // Border fontborder = new TableImageBorder("fontborder", s_shadow, s_blocColor); // form.add(fontborder); // fontborder.add(new ButtonPropertyEditorPanel("fontselector", PROPERTY_FONT, false)); // fontborder.add(new ButtonPropertyEditorPanel("fontcolor", PROPERTY_FONT_COLOR, false)); // fontborder.add(new ButtonPropertyEditorPanel("fontshadow", PROPERTY_FONT_SHADOW, true)); rightcol.addContent(createFragment(ColumnPanel.CONTENT_ID, Arrays.asList(new Component[] { new ButtonPropertyEditorPanel("element", PROPERTY_WIDTH, true), new ButtonPropertyEditorPanel("element", PROPERTY_HEIGHT, true), new ButtonPropertyEditorPanel("element", PROPERTY_AUTO_EXTEND, true) }), "Button Size")); rightcol.addContent(createFragment(rightcol.CONTENT_ID, Arrays.asList(new Component[] { new ButtonPropertyEditorPanel("element", PROPERTY_FONT, false), new ButtonPropertyEditorPanel("element", PROPERTY_FONT_COLOR, true), new ButtonPropertyEditorPanel("element", PROPERTY_FONT_SHADOW, true) }), "Font Selection")); rightcol.addContent(createFragment( rightcol.CONTENT_ID, new EffectChoicePanel("element", new PropertyModel<Integer>(this, "shadowEffect"), EffectUtils.getShadowEffects()), "Shadow Effect")); rightcol.addContent(createFragment( rightcol.CONTENT_ID, new EffectChoicePanel("element", new PropertyModel<Integer>(this, "mirrorEffect"), EffectUtils.getMirrorEffects()), "Mirror Effect")); createButton(null); }
From source file:net.mad.ads.manager.web.pages.HomePage.java
License:Open Source License
public HomePage() { super();/*from w w w . j ava2 s . c o m*/ add(new AjaxLink<Void>("firstButton") { @Override public void onClick(AjaxRequestTarget target) { System.out.println("firstbutton clicked"); } }.add(new ButtonBehavior())); add(new SimplePanel("spanel")); List<Widget> widgets = new ArrayList<Widget>(); widgets.add(new Widget("Simple Stat", new SimplePanel("panel"))); widgets.add(new Widget("Simple Stat", new SimplePanel("panel"))); add(new ListView<Widget>("widgets", widgets) { protected void populateItem(ListItem<Widget> item) { item.add((Widget) item.getModelObject()); } }); }
From source file:net.rrm.ehour.ui.common.form.FormUtil.java
License:Open Source License
public static void setSubmitActions(final FormConfig formConfig) { final boolean inDemoMode = formConfig.getConfig().isInDemoMode(); AjaxButton submitButton = new AjaxButton("submitButton", formConfig.getForm()) { @Override// ww w.j a v a 2 s .c o m protected void onSubmit(AjaxRequestTarget target, Form<?> form) { if (!inDemoMode) { AdminBackingBean backingBean = (AdminBackingBean) formConfig.getForm().getDefaultModelObject(); PayloadAjaxEvent<AdminBackingBean> ajaxEvent = new PayloadAjaxEvent<>( formConfig.getSubmitEventType(), backingBean); EventPublisher.publishAjaxEvent(formConfig.getSubmitTarget(), ajaxEvent); } } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getAjaxCallListeners() .add(inDemoMode ? new DemoDecorator() : new LoadingSpinnerDecorator()); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(form); if (formConfig.getErrorEventType() != null) { AjaxEvent errorEvent = new AjaxEvent(formConfig.getErrorEventType()); EventPublisher.publishAjaxEvent(formConfig.getSubmitTarget(), errorEvent); } } }; submitButton.setModel(new ResourceModel("general.save")); // default submit formConfig.getForm().add(submitButton); AjaxLink<Void> deleteButton = new AjaxLink<Void>("deleteButton") { @Override public void onClick(AjaxRequestTarget target) { if (!inDemoMode) { AdminBackingBean backingBean = (AdminBackingBean) formConfig.getForm().getDefaultModelObject(); PayloadAjaxEvent<AdminBackingBean> ajaxEvent = new PayloadAjaxEvent<>( formConfig.getDeleteEventType(), backingBean); EventPublisher.publishAjaxEvent(formConfig.getSubmitTarget(), ajaxEvent); } } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); List<IAjaxCallListener> callListeners = attributes.getAjaxCallListeners(); if (inDemoMode) { callListeners.add(new DemoDecorator()); } else { callListeners.add(new JavaScriptConfirmation(new ResourceModel("general.deleteConfirmation"))); callListeners.add(new LoadingSpinnerDecorator()); } } }; deleteButton.setVisible(formConfig.isIncludeDelete()); formConfig.getForm().add(deleteButton); }