List of usage examples for org.apache.wicket.feedback IFeedbackMessageFilter IFeedbackMessageFilter
IFeedbackMessageFilter
From source file:abid.password.wicket.components.ErrorInfoFeedbackPanel.java
License:Apache License
private FeedbackPanel createFeedBackFilter(String id, final int filterLevel) { FeedbackPanel feedbackPanel = new FeedbackPanel(id) { private static final long serialVersionUID = 1L; @Override// w w w . j av a 2s . c o m public boolean isVisible() { return anyMessage(filterLevel); } }; feedbackPanel.setFilter(new IFeedbackMessageFilter() { private static final long serialVersionUID = 1L; public boolean accept(FeedbackMessage message) { return message.getLevel() == filterLevel; } }); feedbackPanel.setEscapeModelStrings(false); return feedbackPanel; }
From source file:com.googlecode.wicketwebbeans.containers.BeanForm.java
License:Apache License
/** * Construct a new BeanForm.// w w w . java2 s .co m * * @param id the Wicket id for the panel. * @param bean the bean to be displayed. This may be an IModel or regular bean object. * The bean may be a List or, if an IModel, a model that returns a List. If so, the bean is display is * displayed using BeanTablePanel. Otherwise BeanGridPanel is used. * @param beanMetaData the meta data for the bean. If bean is a List or model of a List, then this must be * the BeanMetaData for a single element (row) of the List. * @param container an optional container to use in place of the default BeanGridPanel or BeanTablePanel. This container must must be a Panel and * implement a constructor of the form: <p> * <code>public Constructor(String id, final Object bean, BeanMetaData beanMetaData, TabMetaData tabMetaData)</code> * <p> * where id = Wicket component ID<br> * bean = the bean, or IModel containing the bean<br> * beanMetaData = the BeanMetaData for bean<br> * tabMetaData = the tab metadata<p> * May be null. */ @SuppressWarnings("serial") public BeanForm(String id, final Object bean, final BeanMetaData beanMetaData, final Class<? extends Panel> container) { super(id); this.bean = bean; this.beanMetaData = beanMetaData; this.container = container; form = new Form("f") { // Track whether the form is in submit processing. @Override public boolean process() { ++submitCnt; try { return super.process(); } finally { --submitCnt; } } }; form.setOutputMarkupId(true); add(form); String title = beanMetaData.getLabel(); form.add(new Label("title", title)); form.add(new Label("beanFormIndicatorErrorLabel", new ResourceModel("beanFormError.msg", "An error occurred on the server. Your session may have timed out."))); beanMetaData.consumeParameter(PARAM_ROWS); final HiddenField hiddenFocusField = new HiddenField<String>("focusField", new PropertyModel<String>(this, "focusField")); hiddenFocusField.add(new AbstractBehavior() { @Override public void onComponentTag(Component component, ComponentTag tag) { tag.put("id", "bfFocusField"); super.onComponentTag(component, tag); } }); form.add(hiddenFocusField); formVisitor = new FormVisitor(); createTabs(bean, beanMetaData, container); // Use a FeedbackMessageFilter to handle messages for multiple BeanForms on a page. This is because messages are stored on the session. IFeedbackMessageFilter feedbackFilter = new IFeedbackMessageFilter() { public boolean accept(FeedbackMessage message) { // If the reporter is a field and this is refreshing because of a non-Ajax form submit, it's very likely that the field has been detached // from its parent because it is in a list view. As a result, findParent doesn't return the BeanForm. Component reporter = message.getReporter(); AbstractField reporterField = (AbstractField) (reporter instanceof AbstractField ? reporter : reporter.findParent(AbstractField.class)); if (reporterField != null) { return reporterField.getBeanForm().getId().equals(BeanForm.this.getId()); } Component parent = (reporter instanceof BeanForm ? reporter : reporter.findParent(BeanForm.class)); return reporter == BeanForm.this || parent == null || parent == BeanForm.this; } }; feedback = new FeedbackPanel("feedback", feedbackFilter); feedback.setOutputMarkupId(true); form.add(feedback); createGlobalActions(); }
From source file:com.locke.library.web.panels.feedback.GlobalFeedbackPanel.java
License:Apache License
public GlobalFeedbackPanel(String id) { super(id, new IFeedbackMessageFilter() { private static final long serialVersionUID = -6916795669026332590L; public boolean accept(FeedbackMessage message) { return message.getReporter().findParent(LocalFeedbackContainer.class) == null; }// w ww. j a v a 2 s . c o m }); }
From source file:com.locke.library.web.panels.feedback.LocalFeedbackPanel.java
License:Apache License
public LocalFeedbackPanel(String id, final LocalFeedbackContainer container) { super(id, new IFeedbackMessageFilter() { private static final long serialVersionUID = -1883211501894198761L; public boolean accept(FeedbackMessage message) { return container.contains(message.getReporter(), true); }// w w w . j a v a 2 s. c om }); }
From source file:com.premiumminds.webapp.wicket.bootstrap.BootstrapControlGroupFeedback.java
License:Open Source License
@Override protected void onConfigure() { super.onConfigure(); filter = new IFeedbackMessageFilter() { private static final long serialVersionUID = -7726392072697648969L; public boolean accept(final FeedbackMessage msg) { Boolean b = visitChildren(FormComponent.class, new IVisitor<FormComponent<?>, Boolean>() { @Override//from ww w. j a v a2 s . c o m public void component(FormComponent<?> arg0, IVisit<Boolean> arg1) { if (arg0.equals(msg.getReporter())) arg1.stop(true); } }); if (b == null) return false; return b; } }; }
From source file:com.premiumminds.webapp.wicket.bootstrap.BootstrapFeedbackPopover.java
License:Open Source License
@Override protected void onInitialize() { super.onInitialize(); filter = new IFeedbackMessageFilter() { private static final long serialVersionUID = -7726392072697648969L; public boolean accept(final FeedbackMessage msg) { Boolean b = visitChildren(FormComponent.class, new IVisitor<FormComponent<?>, Boolean>() { @Override/*from w w w . j a v a 2 s .c o m*/ public void component(FormComponent<?> arg0, IVisit<Boolean> arg1) { if (arg0.equals(msg.getReporter())) arg1.stop(true); } }); if (b == null) return false; return b; } }; }
From source file:com.userweave.module.methoden.questionnaire.page.survey.AnswerPanel.java
License:Open Source License
public AnswerPanel(String id, T question, QuestionnaireSurveyContext context, Locale locale) { super(id);/*from w w w . java 2 s.c o m*/ this.selectedLocale = locale; this.context = context; final Integer questionId = question.getId(); LoadableDetachableModel questionModel = new LoadableDetachableModel() { @Override protected Object load() { return getQuestionDao().findById(questionId); } }; setDefaultModel(new CompoundPropertyModel(questionModel)); AnswerFeedbackPanel feedback = new AnswerFeedbackPanel("feedback"); feedback.setFilter(new IFeedbackMessageFilter() { @Override public boolean accept(FeedbackMessage message) { return AnswerPanel.this.contains(message.getReporter(), true); } }); add(feedback); add(new Label("text", new LocalizedPropertyModel(questionModel, "text", getLocale()))); }
From source file:de.tudarmstadt.ukp.clarin.webanno.webapp.home.page.ApplicationPageBase.java
License:Apache License
@SuppressWarnings({ "serial" })
private void commonInit() {
// getSession().setLocale(Locale.ENGLISH);
logoutPanel = new LogoutPanel("logoutPanel");
feedbackPanel = new FeedbackPanel("feedbackPanel");
feedbackPanel.setOutputMarkupId(true);
feedbackPanel.add(new AttributeModifier("class", "error"));
feedbackPanel.setFilter(new IFeedbackMessageFilter() {
@Override//from w w w . j a v a 2s . c om
public boolean accept(FeedbackMessage aMessage) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String username = auth != null ? auth.getName() : "SYSTEM";
if (aMessage.isFatal()) {
LOG.fatal(username + ": " + aMessage.getMessage());
} else if (aMessage.isError()) {
LOG.error(username + ": " + aMessage.getMessage());
} else if (aMessage.isWarning()) {
LOG.warn(username + ": " + aMessage.getMessage());
} else if (aMessage.isInfo()) {
LOG.info(username + ": " + aMessage.getMessage());
} else if (aMessage.isDebug()) {
LOG.debug(username + ": " + aMessage.getMessage());
}
return true;
}
});
versionLabel = new Label("version", SettingsUtil.getVersionString());
embeddedDbWarning = new Label("embeddedDbWarning", "USE THIS INSTALLATION FOR TESTING ONLY -- "
+ "AN EMBEDDED DATABASE IS NOT RECOMMENDED FOR PRODUCTION USE");
embeddedDbWarning.setVisible(false);
try {
String driver = repository.getDatabaseDriverName();
embeddedDbWarning.setVisible(StringUtils.contains(driver.toLowerCase(Locale.US), "hsql"));
} catch (Throwable e) {
LOG.warn("Unable to determine which database is being used", e);
}
// Override warning about embedded database.
Properties settings = SettingsUtil.getSettings();
if ("false".equalsIgnoreCase(settings.getProperty("warnings.embeddedDatabase"))) {
embeddedDbWarning.setVisible(false);
}
// Display a warning when using an unsupported browser
RequestCycle requestCycle = RequestCycle.get();
WebClientInfo clientInfo;
if (Session.exists()) {
WebSession session = WebSession.get();
clientInfo = session.getClientInfo();
} else {
clientInfo = new WebClientInfo(requestCycle);
}
ClientProperties clientProperties = clientInfo.getProperties();
browserWarning = new Label("browserWarning",
"THIS BROWSER IS NOT SUPPORTED -- " + "PLEASE USE CHROME OR SAFARI");
browserWarning.setVisible(!clientProperties.isBrowserSafari() && !clientProperties.isBrowserChrome());
// Override warning about browser.
if ("false".equalsIgnoreCase(settings.getProperty("warnings.unsupportedBrowser"))) {
browserWarning.setVisible(false);
}
boolean helpAvailable;
try {
Application.get().getResourceSettings().getLocalizer().getString("page.help.link", this);
Application.get().getResourceSettings().getLocalizer().getString("page.help", this);
helpAvailable = true;
} catch (MissingResourceException e) {
helpAvailable = false;
}
add(helpLink = new ExternalLink("helpLink", new ResourceModel("page.help.link", ""),
new ResourceModel("page.help", "")));
helpLink.setPopupSettings(new PopupSettings("_blank"));
helpLink.setVisible(helpAvailable);
add(logoutPanel);
add(feedbackPanel);
add(versionLabel);
add(embeddedDbWarning);
add(browserWarning);
}
From source file:de.tudarmstadt.ukp.csniper.webapp.page.ApplicationPageBase.java
License:Apache License
@SuppressWarnings({ "serial" })
private void commonInit() {
getSession().setLocale(Locale.ENGLISH);
logInOutPanel = new LogInOutPanel("logInOutPanel");
helpPanel = new InfoPanel("helpPanel", "page.help");
macroPanel = new InfoPanel("macroPanel", "page.macros") {
@Override// w w w.j av a 2s . co m
protected void initialize() {
super.initialize();
Map<String, String> macros = new HashMap<String, String>();
for (CqpMacro macro : CqpEngine.getMacros()) {
macros.put(macro.getName(), macro.getBodyAsHtml());
}
infoPanel.replaceWith(new ExpandableList("infoPanel", macros));
}
};
openHelp = new AjaxLink<Void>("openHelp") {
@Override
public void onClick(AjaxRequestTarget aTarget) {
helpPanel.setVisible(!helpPanel.isVisible());
aTarget.add(helpPanel);
}
};
openMacros = new AjaxLink<Void>("openMacros") {
@Override
public void onClick(AjaxRequestTarget aTarget) {
macroPanel.setVisible(!macroPanel.isVisible());
aTarget.add(macroPanel);
}
};
feedbackPanel = new FeedbackPanel("feedbackPanel");
feedbackPanel.setOutputMarkupId(true);
feedbackPanel.setFilter(new IFeedbackMessageFilter() {
@Override
public boolean accept(FeedbackMessage aMessage) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String username = auth != null ? auth.getName() : "UNKNOWN";
if (aMessage.isFatal()) {
LOG.fatal(username + ": " + aMessage.getMessage());
} else if (aMessage.isError()) {
LOG.error(username + ": " + aMessage.getMessage());
} else if (aMessage.isWarning()) {
LOG.warn(username + ": " + aMessage.getMessage());
} else if (aMessage.isInfo()) {
LOG.info(username + ": " + aMessage.getMessage());
} else if (aMessage.isDebug()) {
LOG.debug(username + ": " + aMessage.getMessage());
}
return true;
}
});
Properties props = getVersionProperties();
versionLabel = new Label("version",
props.getProperty("version") + " (" + props.getProperty("timestamp") + ")");
add(openHelp);
add(openMacros);
add(helpPanel);
add(macroPanel);
add(logInOutPanel);
add(feedbackPanel);
add(versionLabel);
}
From source file:ee.pri.rl.blog.web.page.common.message.GlobalFeedbackPanel.java
License:Open Source License
public GlobalFeedbackPanel(String id) { super(id, new IFeedbackMessageFilter() { private static final long serialVersionUID = -6916795669026332590L; public boolean accept(FeedbackMessage message) { return message.getReporter() == null; }// www . j ava2 s.c o m }); }