use of com.github.bordertech.wcomponents.AjaxTarget in project wcomponents by BorderTech.
the class RepeaterExampleWithStaticIDs method createAddContactSubForm.
/**
* 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 }));
}
use of com.github.bordertech.wcomponents.AjaxTarget 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 }));
}
use of com.github.bordertech.wcomponents.AjaxTarget 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));
}
use of com.github.bordertech.wcomponents.AjaxTarget in project wcomponents by BorderTech.
the class WAjaxControlRenderer method doRender.
/**
* Paints the given AjaxControl.
*
* @param component the AjaxControl to paint
* @param renderContext the RenderContext to paint to
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WAjaxControl ajaxControl = (WAjaxControl) component;
XmlStringBuilder xml = renderContext.getWriter();
WComponent trigger = ajaxControl.getTrigger() == null ? ajaxControl : ajaxControl.getTrigger();
int delay = ajaxControl.getDelay();
if (ajaxControl.getTargets() == null || ajaxControl.getTargets().isEmpty()) {
return;
}
// Start tag
xml.appendTagOpen("ui:ajaxtrigger");
xml.appendAttribute("triggerId", trigger.getId());
xml.appendOptionalAttribute("loadOnce", ajaxControl.isLoadOnce(), "true");
xml.appendOptionalAttribute("delay", delay > 0, delay);
xml.appendClose();
// Targets
for (AjaxTarget target : ajaxControl.getTargets()) {
xml.appendTagOpen("ui:ajaxtargetid");
xml.appendAttribute("targetId", target.getId());
xml.appendEnd();
}
// End tag
xml.appendEndTag("ui:ajaxtrigger");
}
use of com.github.bordertech.wcomponents.AjaxTarget in project wcomponents by BorderTech.
the class WLinkRenderer method paintAjaxTrigger.
/**
* Paint the AJAX trigger if the link has an action.
*
* @param link the link component being rendered
* @param xml the XmlStringBuilder to paint to.
*/
private void paintAjaxTrigger(final WLink link, final XmlStringBuilder xml) {
AjaxTarget[] actionTargets = link.getActionTargets();
// Start tag
xml.appendTagOpen("ui:ajaxtrigger");
xml.appendAttribute("triggerId", link.getId());
xml.appendClose();
if (actionTargets != null && actionTargets.length > 0) {
// Targets
for (AjaxTarget target : actionTargets) {
xml.appendTagOpen("ui:ajaxtargetid");
xml.appendAttribute("targetId", target.getId());
xml.appendEnd();
}
} else {
// Target itself
xml.appendTagOpen("ui:ajaxtargetid");
xml.appendAttribute("targetId", link.getId());
xml.appendEnd();
}
// End tag
xml.appendEndTag("ui:ajaxtrigger");
}
Aggregations