0

I'm trying to use a JGrowlFeedbackPanel component in my project. It's a wicket adoption of the JGrowl plugin (JQuery). I got it from a maven's repository.

ResourceReference cssMenuRef = new ResourceReference(HomePage.class, "style_menu.css");
add(CSSPackageResource.getHeaderContribution(cssMenuRef));

JGrowlFeedbackPanel feedbackPanel = new JGrowlFeedbackPanel("feedbackPanel", new ErrorLevelFeedbackMessageFilter(FeedbackMessage.WARNING));
add(feedbackPanel);
Options errorOptions = new Options();
errorOptions.set("header", "Error"); //works
errorOptions.set("sticky", true); //works
errorOptions.set("position", "center"); //doesn't work
errorOptions.set("theme", "feedback"); //doesn't work
error("TEST!");
feedbackPanel.setErrorMessageOptions(errorOptions);

.feedback {
color: #ff0000;
background-color: #FFFFFF !important ; 
width: 400px;
}

I'd like to change jGrowl's defaut position and color, but they don't change at all. I can use the !important declaration in my css file, but I think it's not a good idea. I will appreciate any suggestions. Thanks!

Lin
  • 3
  • 3

2 Answers2

0

For the position, jGrowl clearly says in it's documentation:

This must be changed in the defaults before the startup method is called.

Link: jGrowl

-> According to the sourcecode I have found here : JGrowlFeedbackMessage.java and here: JGrowlFeedbackPanel.java This may not work the way it is done since you will have to go inside the "jquery.jgrowl.js" to modify the position default...

Also I do not understand why the jGrowl options can't be completely extended in JS.

Maybe a better advise would be to use jquery notifier, build your own panel and wrap the call to trigger notifications via the target.appendJavaScript() method. Example for wicket6:

    public void showExpiringNotification(final String title, final String message, final int expiringSpeed) {
      AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class);
      if (target != null) {
        target.appendJavaScript("$('#container').notify('create','error',{title: '" + title + "', text: '" + message
                + "' },{expires: " + expiringSpeed + "})");
      }
    }

If needed I might give a more detailed example on my blog...

chris polzer
  • 3,219
  • 3
  • 28
  • 44
0

I've noticed two things today once I integrated with WicketStuff's jGrowl panel.

  1. It always misses my first message unless I first call $.jGrowl() before any feedback messages are to be shown on the page. This is only affected in IE10, see https://github.com/stanlemon/jGrowl/issues/17
  2. The Options class that comes with it likes to put single quotes around the options if you pass them as strings. So make sure you use new Interger(x) or some other type of object.

Otherwise this is a nice UI addition.

Paul Bors
  • 105
  • 6