public GravatarPanel(final String idParam, final String emailParam) {
   super(idParam);
   if (emailParam == null) {
     LOGGER.debug(new StringResourceModel("nullEmailParamLogMessage", this, null).getString());
     addDefaultGravatarImage();
   } else {
     try {
       final byte[] hash = MessageDigest.getInstance(MD5).digest(emailParam.getBytes());
       final StringBuilder hashString = new StringBuilder();
       for (final byte elementLocal : hash) {
         final String hex = Integer.toHexString(elementLocal);
         if (hex.length() == 1) {
           hashString.append(ZERO);
           hashString.append(hex.charAt(hex.length() - 1));
         } else {
           hashString.append(hex.substring(hex.length() - 2));
         }
       }
       final Image imgLocal = new Image(WICKET_ID_GRAVATAR_IMG, (IResource) null);
       imgLocal.add(
           AttributeModifierFactory.newAttributeAppenderForSrc(
               "http://www.gravatar.com/avatar/" + hashString.toString() + DOT_JPG));
       imgLocal.add(
           AttributeModifierFactory.newAttributeAppenderForAlt(
               new StringResourceModel("gravatarAlt", this, null) + emailParam + DOT));
       add(imgLocal);
     } catch (final NoSuchAlgorithmException ex) {
       LOGGER.info(
           new StringResourceModel("md5HashAlgoNotFoundLogMessage", this, null).getString(), ex);
       addDefaultGravatarImage();
     }
   }
 }
 private void addDefaultGravatarImage() {
   final Image imgLocal = new Image(WICKET_ID_GRAVATAR_IMG, (IResource) null);
   imgLocal.add(
       AttributeModifierFactory.newAttributeAppenderForSrc(
           new StringResourceModel("defaultGravatarImageHref", this, null).getString()));
   imgLocal.add(
       AttributeModifierFactory.newAttributeAppenderForAlt(
           new StringResourceModel("defaultGravatarImageAlt", this, null).getString()));
   add(imgLocal);
 }
 @Override
 protected Link<T> createPageLink(MenuLinkItem menuLink) {
   String imageSrc = menuLink.getIcon();
   // default nebo ikonu
   Image image = new Image("icon", "");
   AttributeModifier attributeModifier =
       new AttributeModifier(
           "src", new Model<String>(imageSrc == null ? "/grass/img/tags/label_16.png" : imageSrc));
   image.add(attributeModifier);
   Link<T> link = super.createPageLink(menuLink);
   link.add(image);
   return link;
 }
Beispiel #4
0
  protected Component getLoadingComponent(final String markupId) {
    Image image = new Image(markupId, PRELOADER);
    image.add(
        new VisibleEnableBehaviour() {

          @Override
          public boolean isVisible() {
            return isLoadingVisible();
          }
        });

    return image;
  }
 @Override
 public void addBehavior(Behavior behavior) {
   image.add(behavior);
 }