Search in sources :

Example 16 with WAjaxControl

use of com.github.bordertech.wcomponents.WAjaxControl in project wcomponents by BorderTech.

the class WRadioButtonTriggerActionExample method setup.

/**
 * Add controls to the UI.
 */
private void setup() {
    setLayout(new FlowLayout(FlowLayout.VERTICAL));
    WFieldSet fset = new WFieldSet("Select a meal");
    add(fset);
    fset.setMargin(new Margin(null, null, Size.LARGE, null));
    WFieldLayout flay = new WFieldLayout(WFieldLayout.LAYOUT_STACKED);
    fset.add(flay);
    flay.setLabelWidth(0);
    flay.addField("Breakfast", rb1);
    flay.addField("Lunch", rb2);
    flay.addField("Dinner", rb3);
    /*
		 * NOTE: you should never use submitOnChange with a WRadioButton
		 */
    fset.add(new WAjaxControl(mealSelections, textBox));
    mealSelections.setActionOnChange(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            String selection = null;
            if (rb1.isSelected()) {
                selection = "Breakfast selected";
            }
            if (rb2.isSelected()) {
                selection = "Lunch selected";
            }
            if (rb3.isSelected()) {
                selection = "Dinner selected";
            }
            text1.setText(selection + " : " + (new Date()).toString());
        }
    });
    textBox.add(text1);
    add(textBox);
    add(mealSelections);
}
Also used : WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) Action(com.github.bordertech.wcomponents.Action) FlowLayout(com.github.bordertech.wcomponents.layout.FlowLayout) WFieldSet(com.github.bordertech.wcomponents.WFieldSet) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) Date(java.util.Date) Margin(com.github.bordertech.wcomponents.Margin)

Example 17 with WAjaxControl

use of com.github.bordertech.wcomponents.WAjaxControl in project wcomponents by BorderTech.

the class GridLayoutOptionsExample method getLayoutControls.

/**
 * build the list controls field set.
 *
 * @param errors the error box to be linked to the apply button.
 * @return a field set for the controls.
 */
private WFieldSet getLayoutControls(final WValidationErrors errors) {
    // Options Layout
    WFieldSet fieldSet = new WFieldSet("List configuration");
    WFieldLayout layout = new ControlFieldLayout();
    fieldSet.add(layout);
    // options.
    columnCount.setDecimalPlaces(0);
    columnCount.setMinValue(0);
    columnCount.setNumber(DEFAULT_COLUMN_COUNT);
    columnCount.setMandatory(true);
    layout.addField("Number of Columns", columnCount);
    rowCount.setDecimalPlaces(0);
    rowCount.setMinValue(0);
    rowCount.setNumber(DEFAULT_ROW_COUNT);
    rowCount.setMandatory(true);
    layout.addField("Number of Rows", rowCount);
    hGap.setDecimalPlaces(0);
    hGap.setMinValue(0);
    hGap.setNumber(0);
    hGap.setMandatory(true);
    layout.addField("Horizontal Gap", hGap);
    vGap.setDecimalPlaces(0);
    vGap.setMinValue(0);
    vGap.setNumber(0);
    vGap.setMandatory(true);
    layout.addField("Vertical Gap", vGap);
    boxCount.setDecimalPlaces(0);
    boxCount.setMinValue(0);
    boxCount.setNumber(DEFAULT_BOX_COUNT);
    boxCount.setMandatory(true);
    layout.addField("Number of Boxes", boxCount);
    layout.addField("Visible", cbVisible);
    layout.addField("Allow responsive design", cbResponsive);
    // Apply Button
    WButton apply = new WButton("Apply");
    apply.setAction(new ValidatingAction(errors, this) {

        @Override
        public void executeOnValid(final ActionEvent event) {
            applySettings();
        }
    });
    layout.addField(apply);
    fieldSet.add(new WAjaxControl(apply, container));
    fieldSet.setMargin(new Margin(null, null, Size.LARGE, null));
    return fieldSet;
}
Also used : WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) WFieldSet(com.github.bordertech.wcomponents.WFieldSet) ValidatingAction(com.github.bordertech.wcomponents.validation.ValidatingAction) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) WButton(com.github.bordertech.wcomponents.WButton) Margin(com.github.bordertech.wcomponents.Margin)

Example 18 with WAjaxControl

use of com.github.bordertech.wcomponents.WAjaxControl in project wcomponents by BorderTech.

the class TreePicker method buildUI.

/**
 * Add all the bits in the right order.
 */
private void buildUI() {
    add(new WSkipLinks());
    // the application header
    add(headerPanel);
    headerPanel.add(new UtilityBar());
    headerPanel.add(new WHeading(HeadingLevel.H1, "WComponents"));
    // mainPanel holds the menu and the actual example.
    add(mainPanel);
    mainPanel.add(menuPanel);
    mainPanel.add(exampleSection);
    // An application footer?
    WPanel footer = new WPanel(WPanel.Type.FOOTER);
    footer.add(lastLoaded);
    add(footer);
    add(new WAjaxControl(menuPanel.getTree(), new AjaxTarget[] { menuPanel.getMenu(), exampleSection }));
}
Also used : WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) WSkipLinks(com.github.bordertech.wcomponents.WSkipLinks) WPanel(com.github.bordertech.wcomponents.WPanel) WHeading(com.github.bordertech.wcomponents.WHeading) AjaxTarget(com.github.bordertech.wcomponents.AjaxTarget)

Example 19 with WAjaxControl

use of com.github.bordertech.wcomponents.WAjaxControl in project wcomponents by BorderTech.

the class RepeaterExampleWithEditableRows method createExampleUi.

/**
 * Add all the required UI artefacts for this example.
 */
private void createExampleUi() {
    add(new WHeading(HeadingLevel.H2, "Contacts"));
    add(repeater);
    WButton addBtn = new WButton("Add");
    addBtn.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            addNewContact();
        }
    });
    newNameField.setDefaultSubmitButton(addBtn);
    WButton printBtn = new WButton("Print");
    printBtn.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            printEditedDetails();
        }
    });
    WFieldLayout layout = new WFieldLayout();
    add(layout);
    layout.addField("New contact name", newNameField);
    layout.addField((WLabel) null, addBtn);
    layout.addField("Print output", console);
    layout.addField((WLabel) null, printBtn);
    // Ajax controls to make things zippier
    add(new WAjaxControl(addBtn, new AjaxTarget[] { repeater, newNameField }));
    add(new WAjaxControl(printBtn, console));
}
Also used : Action(com.github.bordertech.wcomponents.Action) WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) WButton(com.github.bordertech.wcomponents.WButton) WHeading(com.github.bordertech.wcomponents.WHeading) AjaxTarget(com.github.bordertech.wcomponents.AjaxTarget)

Example 20 with WAjaxControl

use of com.github.bordertech.wcomponents.WAjaxControl in project wcomponents by BorderTech.

the class RepeaterExampleWithStaticIDs method createButtonBar.

/**
 * Create the UI artefacts for the update and reset buttons.
 */
private void createButtonBar() {
    // Update and reset controls for the repeater.
    WPanel buttonPanel = new WPanel(WPanel.Type.FEATURE);
    buttonPanel.setMargin(new Margin(Size.MEDIUM, null, Size.LARGE, null));
    buttonPanel.setLayout(new BorderLayout());
    WButton updateButton = new WButton("Update");
    updateButton.setImage("/image/document-save-5.png");
    updateButton.setImagePosition(WButton.ImagePosition.EAST);
    buttonPanel.add(updateButton, BorderLayout.EAST);
    WButton resetButton = new WButton("Reset");
    resetButton.setImage("/image/edit-undo-8.png");
    resetButton.setImagePosition(WButton.ImagePosition.WEST);
    resetButton.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            repeater.setData(fetchDataList());
        }
    });
    buttonPanel.add(resetButton, BorderLayout.WEST);
    add(buttonPanel);
    add(new WAjaxControl(updateButton, repeater));
    add(new WAjaxControl(resetButton, repeater));
}
Also used : Action(com.github.bordertech.wcomponents.Action) WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) BorderLayout(com.github.bordertech.wcomponents.layout.BorderLayout) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WPanel(com.github.bordertech.wcomponents.WPanel) WButton(com.github.bordertech.wcomponents.WButton) Margin(com.github.bordertech.wcomponents.Margin)

Aggregations

WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)27 WButton (com.github.bordertech.wcomponents.WButton)18 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)16 Action (com.github.bordertech.wcomponents.Action)15 WHeading (com.github.bordertech.wcomponents.WHeading)13 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)10 WPanel (com.github.bordertech.wcomponents.WPanel)8 Margin (com.github.bordertech.wcomponents.Margin)6 WTextField (com.github.bordertech.wcomponents.WTextField)6 WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)5 WLabel (com.github.bordertech.wcomponents.WLabel)5 AjaxTarget (com.github.bordertech.wcomponents.AjaxTarget)4 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)4 ValidatingAction (com.github.bordertech.wcomponents.validation.ValidatingAction)4 WRadioButtonSelect (com.github.bordertech.wcomponents.WRadioButtonSelect)3 Equal (com.github.bordertech.wcomponents.subordinate.Equal)3 Rule (com.github.bordertech.wcomponents.subordinate.Rule)3 WSubordinateControl (com.github.bordertech.wcomponents.subordinate.WSubordinateControl)3 ArrayList (java.util.ArrayList)3 WComponent (com.github.bordertech.wcomponents.WComponent)2