/** * Sets the 'ok' button's action. * * @param action the ok action. */ public void setOKAction(final Action action) { okBtn.setAction(action); }
/** * @param action the submit action */ public void setSubmitAction(final Action action) { submitBtn.setAction(action); }
/** * Sets the 'cancel' button's action. * * @param action the cancel action. */ public void setCancelAction(final Action action) { cancelBtn.setAction(action); }
/** * Sets the submit button's action. * * @param action the submit action. */ public void setSubmitAction(final Action action) { submitBtn.setAction(action); }
/** * Sets the action for the validation button. The action should be a {@link ValidatingAction} for validation to * actually occur. * * @param action the button action. */ public void setValidatingAction(final Action action) { validateBtn.setAction(action); }
/** * Sets the action to invoke when the {@link #name} button is used. * * @param action the action for the name button. */ public void setNameAction(final Action action) { name.setAction(action); } }
/** * Creates a button to toggle the visibility of a tab. * * @param idx the index of the tab. * @return a button which toggles the visibility of the tab. */ private WButton newVisibilityToggleForTab(final int idx) { WButton toggleButton = new WButton("Toggle visibility of tab " + (idx + 1)); toggleButton.setAction(new Action() { @Override public void execute(final ActionEvent event) { boolean tabVisible = tabset.isTabVisible(idx); tabset.setTabVisible(idx, !tabVisible); } }); return toggleButton; } }
/** * Create the example. */ public WMultiDropdownTestingExample() { layout = new WFieldLayout(WFieldLayout.LAYOUT_STACKED); resetButton = new WButton("Cancel"); resetButton.setAction(new Action() { @Override public void execute(final ActionEvent event) { layout.reset(); } }); setupUI(); }
/** * Creates a SuccessDialog. */ private SuccessPanel() { add(new WMessageBox(WMessageBox.SUCCESS, "Everything is valid!")); WButton okBtn = new WButton("Ok"); okBtn.setAction(new Action() { @Override public void execute(final ActionEvent event) { cardManager.makeVisible(mainPanel); } }); add(okBtn); } }
/** * Creates a WButtonActionExample. */ public WButtonActionExample() { setLayout(new FlowLayout(Alignment.VERTICAL, 0, 6)); add(message); // Add the button to the panel. add(button); // Set the action on the button to be executed when the button is // pressed. button.setAction(new Action() { @Override public void execute(final ActionEvent event) { message.setText( "The \"" + event.getActionCommand() + "\" button was pressed at " + new Date()); } }); } }
/** * Creates a TextDuplicator_VelocityImpl with the specified label text. * * @param templateName the VM template name. * @param name the name label text */ public TextDuplicatorVelocityImpl(final String templateName, final String name) { // This is the line of code that associates this component with a // velocity template. A simple mapping is applied to the given class // to derive the name of a velocity template. // In this case, com.github.bordertech.wcomponents.examples.TextDuplicatorPretty // maps to the template com/github/bordertech/wcomponents/examples/TextDuplicator_VelocityImpl.vm super(templateName, TemplateRendererFactory.TemplateEngine.VELOCITY); WButton dupBtn = new WButton("Duplicate"); WButton clrBtn = new WButton("Clear"); addTaggedComponent("label", new WLabel(name, textFld)); addTaggedComponent("text", textFld); addTaggedComponent("duplicateButton", dupBtn); addTaggedComponent("clearButton", clrBtn); dupBtn.setAction(new DuplicateAction()); clrBtn.setAction(new ClearAction()); }
/** * Creates a WDropdownSpaceHandlingExample. */ public WDropdownSpaceHandlingExample() { drop = new WDropdown(); drop.setOptions(new String[]{null, NO_SPACE, LEADING_SPACE, TRAILING_SPACE, DOUBLE_SPACE}); text = new WText(); submit = new WButton("Submit"); submit.setAction(new Action() { @Override public void execute(final ActionEvent event) { String selected = (String) drop.getSelected(); if (selected != null) { selected = selected.replaceAll(" ", "%20"); } text.setText(selected); } }); setupUI(); }
/** * Creates a ForwardExample. */ public ForwardExample() { final WTextField urlField = new WTextField(); urlField.setText("http://www.google.com.au/"); urlField.setColumns(60); add(urlField, "urlField"); WButton forwardBtn = new WButton("Forward"); forwardBtn.setAction(new Action() { @Override public void execute(final ActionEvent event) { forward(urlField.getText()); } }); add(forwardBtn, "forwardBtn"); } }
/** * Add the controls to the UI. * @param labelText the text to show in the duplicator field's label. */ private void setupUI(final String labelText) { WButton dupBtn = new WButton("Duplicate"); dupBtn.setAction(new DuplicateAction()); WButton clrBtn = new WButton("Clear"); clrBtn.setAction(new ClearAction()); add(new WLabel(labelText, textFld)); add(textFld); add(dupBtn); add(clrBtn); add(new WAjaxControl(dupBtn, this)); add(new WAjaxControl(clrBtn, this)); }
/** * Creates a ContactContainer. */ public ContactContainer() { roleSelect.setButtonLayout(WCheckBoxSelect.LAYOUT_FLAT); roleSelect.setFrameless(true); roleSelect.setIdName(ID_ROLE); phoneNumField.setIdName(ID_PHONE); deleteButton.setRenderAsLink(true); deleteButton.setAction(new Action() { @Override public void execute(final ActionEvent event) { removeRow(); } }); deleteButton.setMessage("Are you really sure?"); deleteButton.setImage("/image/remove.png"); createUI(); }
/** * Creates an ErrorGenerator. */ public ErrorGenerator() { setLayout(new FlowLayout(FlowLayout.VERTICAL, 24)); actionErrorBtn.setAction(new Action() { @Override public void execute(final ActionEvent event) { throw new MyRuntimeException("A deliberate runtime exception thrown in Action."); } }); add(new TextDuplicator()); WContainer buttonContainer = new WContainer(); add(buttonContainer); buttonContainer.add(actionErrorBtn); buttonContainer.add(handleRequestErrorBtn); buttonContainer.add(preparePaintComponentErrorBtn); buttonContainer.add(paintComponentErrorBtn); }
@Test public void testActionSetPressed() { WButton button = new WButton("Test"); button.setLocked(true); UIContext uic = createUIContext(); setActiveContext(uic); uic.setUI(button); TestAction testAction = new TestAction(); testAction.reset(); button.setAction(testAction); button.setPressed(true, new MockRequest()); Assert.assertEquals("Button was not pressed", true, button.isPressed()); }
/** * Create the UI artefacts for the "Print contacts" sub form. */ private void createPrintContactsSubForm() { add(new WHeading(HeadingLevel.H3, "Print to CSV")); WButton printBtn = new WButton("Print"); printBtn.setAction(new Action() { @Override public void execute(final ActionEvent event) { printDetails(); } }); printBtn.setImage("/image/document-print.png"); printBtn.setImagePosition(WButton.ImagePosition.EAST); WFieldLayout layout = new WFieldLayout(); add(layout); layout.setMargin(new Margin(Size.LARGE, null, null, null)); layout.addField("Print output", printOutput); layout.addField((WLabel) null, printBtn); add(new WAjaxControl(printBtn, printOutput)); }
/** * Create the UI artefacts for the "Add contact" sub form. */ private void createAddContactSubForm() { add(new WHeading(HeadingLevel.H3, "Add a new contact")); WButton addBtn = new WButton("Add"); addBtn.setAction(new Action() { @Override public void execute(final ActionEvent event) { addNewContact(); } }); addBtn.setImage("/image/address-book-new.png"); newNameField.setDefaultSubmitButton(addBtn); WContainer container = new WContainer(); container.add(newNameField); container.add(addBtn); WFieldLayout layout = new WFieldLayout(); add(layout); layout.addField("New contact name", container); add(new WAjaxControl(addBtn, new AjaxTarget[]{repeater, newNameField})); }
/** * Creates a SearchResultsPage. */ public SearchResultsPage() { setTemplate(SearchResultsPage.class); resultsTable = new WDataTable(); resultsTable.setPaginationMode(PaginationMode.DYNAMIC); resultsTable.setRowsPerPage(SearchCriteriaPage.DEFAULT_ROWS_PER_PAGE); add(resultsTable, "resultsTable"); resultsTable.addColumn(new WTableColumn("Name", NameRenderer.class)); resultsTable.addColumn(new WTableColumn("Country", WText.class)); resultsTable.addColumn(new WTableColumn("Happy", WText.class)); WButton newSearchBtn = new WButton("New Search"); add(newSearchBtn, "newSearchButton"); newSearchBtn.setAction(new Action() { @Override public void execute(final ActionEvent event) { TestApp.getInstance().doNewSearch(); } }); }