use of com.github.bordertech.wcomponents.WContentLink in project wcomponents by BorderTech.
the class WContentExample method addContentRow.
/**
* Adds components to the given container which demonstrate various ways of acessing the given content.
*
* @param contentDesc the description of the content, used to label the controls.
* @param contentAccess the content which will be displayed.
* @param target the container to add the UI controls to.
*/
private void addContentRow(final String contentDesc, final ContentAccess contentAccess, final MutableContainer target) {
// Demonstrate WButton + WContent, round trip
WButton button = new WButton(contentDesc);
final WContent buttonContent = new WContent();
button.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
buttonContent.setContentAccess(contentAccess);
buttonContent.display();
}
});
WContainer buttonCell = new WContainer();
buttonCell.add(buttonContent);
buttonCell.add(button);
target.add(buttonCell);
// Demonstrate WButton + WContent, using AJAX
WButton ajaxButton = new WButton(contentDesc);
final WContent ajaxContent = new WContent();
ajaxButton.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
ajaxContent.setContentAccess(contentAccess);
ajaxContent.display();
}
});
WContainer ajaxCell = new WContainer();
// The WContent must be wrapped in an AJAX targetable container
WPanel ajaxContentPanel = new WPanel();
ajaxContentPanel.add(ajaxContent);
ajaxCell.add(ajaxButton);
ajaxCell.add(ajaxContentPanel);
ajaxButton.setAjaxTarget(ajaxContentPanel);
target.add(ajaxCell);
// Demonstrate WContentLink - new window
WContentLink contentLinkNewWindow = new WContentLink(contentDesc) {
@Override
protected void preparePaintComponent(final Request request) {
super.preparePaintComponent(request);
setContentAccess(contentAccess);
}
};
target.add(contentLinkNewWindow);
// Demonstrate WContentLink - prompt to save
WContentLink contentLinkPromptToSave = new WContentLink(contentDesc) {
@Override
protected void preparePaintComponent(final Request request) {
super.preparePaintComponent(request);
setContentAccess(contentAccess);
}
};
contentLinkPromptToSave.setDisplayMode(DisplayMode.PROMPT_TO_SAVE);
target.add(contentLinkPromptToSave);
// Demonstrate WContentLink - inline
WContentLink contentLinkInline = new WContentLink(contentDesc) {
@Override
protected void preparePaintComponent(final Request request) {
super.preparePaintComponent(request);
setContentAccess(contentAccess);
}
};
contentLinkInline.setDisplayMode(DisplayMode.DISPLAY_INLINE);
target.add(contentLinkInline);
// Demonstrate targeting of content via a URL
WMenu menu = new WMenu(WMenu.MenuType.FLYOUT);
final WContent menuContent = new WContent();
menuContent.setDisplayMode(DisplayMode.PROMPT_TO_SAVE);
WMenuItem menuItem = new WMenuItem(contentDesc) {
@Override
protected void preparePaintComponent(final Request request) {
super.preparePaintComponent(request);
menuContent.setContentAccess(contentAccess);
setUrl(menuContent.getUrl());
}
};
menu.add(menuItem);
WContainer menuCell = new WContainer();
menuCell.add(menuContent);
menuCell.add(menu);
target.add(menuCell);
}
Aggregations