Example usage for org.apache.wicket.markup.html.image NonCachingImage setOutputMarkupId

List of usage examples for org.apache.wicket.markup.html.image NonCachingImage setOutputMarkupId

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.image NonCachingImage setOutputMarkupId.

Prototype

public final Component setOutputMarkupId(final boolean output) 

Source Link

Document

Sets whether or not component will output id attribute into the markup.

Usage

From source file:com.userweave.components.imageUpload.IconUploadPanel.java

License:Open Source License

private NonCachingImage getImage(int width, int height) {
    NonCachingImage image = new NonCachingImage("image", new DynamicImageResource() {
        private static final long serialVersionUID = 1L;

        @Override//ww  w.j a  v  a 2s. c  o  m
        protected byte[] getImageData(Attributes attributes) {
            byte[] imageData = imageUpload.getImageData();
            if (imageData != null) {
                return imageData;
            } else {
                return new byte[] {};
            }
        }
    });

    if ((height > 0) && (width > 0)) {
        image.add(new AttributeModifier("style", new Model<String>(
                "width: " + Integer.toString(width) + "px;" + "height: " + Integer.toString(height) + "px;")));
    }

    image.setOutputMarkupId(true);

    return image;
}

From source file:org.projectforge.web.wicket.flowlayout.ImageUploadPanel.java

License:Open Source License

private NonCachingImage createImage() {
    NonCachingImage img = new NonCachingImage("image", new AbstractReadOnlyModel<DynamicImageResource>() {
        @Override//from   w  ww.  j ava  2  s.co m
        public DynamicImageResource getObject() {
            final DynamicImageResource dir = new DynamicImageResource() {
                @Override
                protected byte[] getImageData(final Attributes attributes) {
                    byte[] result = file.getObject();
                    if (result == null || result.length < 1) {
                        try {
                            result = IOUtils.toByteArray(
                                    getClass().getClassLoader().getResource("images/noImage.png").openStream());
                        } catch (final IOException ex) {
                            log.error("Exception encountered " + ex, ex);
                        }
                    }
                    return result;
                }
            };
            dir.setFormat("image/png");
            return dir;
        }
    });
    img.setOutputMarkupId(true);
    img.add(new AttributeModifier("height", Integer.toString(200)));
    return img;
}

From source file:org.sakaiproject.sitestats.tool.wicket.components.AjaxLazyLoadImage.java

License:Educational Community License

private Image createImage(final String id, final byte[] imageData) {
    NonCachingImage chartImage = new NonCachingImage(id) {
        private static final long serialVersionUID = 1L;

        @Override/*from  w  w  w  . j a va2s.c  om*/
        protected IResource getImageResource() {
            return new DynamicImageResource() {
                private static final long serialVersionUID = 1L;

                @Override
                protected byte[] getImageData(IResource.Attributes attributes) {
                    return imageData;
                }

                // adapted from https://cwiki.apache.org/confluence/display/WICKET/JFreeChart+and+wicket+example
                @Override
                protected void configureResponse(AbstractResource.ResourceResponse response,
                        IResource.Attributes attributes) {
                    super.configureResponse(response, attributes);

                    response.setCacheDuration(Duration.NONE);
                    response.setCacheScope(CacheScope.PRIVATE);
                }
            };
        }
    };
    chartImage.setOutputMarkupId(true);
    chartImage.setOutputMarkupPlaceholderTag(true);
    return chartImage;
}

From source file:org.xaloon.wicket.component.captcha.CaptchaPanel.java

License:Apache License

public void setupCaptcha(AjaxRequestTarget target, IModel<String> model) {
    model.setObject(randomString(DEFAULT_MIN, DEFAULT_MAX));
    CaptchaImageResource captchaImageResource = new CaptchaImageResource(model.getObject());
    NonCachingImage imgCaptcha = new NonCachingImage("captchaImage", captchaImageResource) {
        /**//ww w .j av  a 2s  .c  o  m
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);

            String url = tag.getAttributes().getString("src");
            url = url.replaceAll("&", "&amp;");
            tag.put("src", url);
            tag.put("alt", "captcha");
        }
    };
    imgCaptcha.setOutputMarkupId(true); // required for AjaxFallbackLink
    addOrReplace(imgCaptcha);
    if (target != null) {
        target.addComponent(imgCaptcha);
    }
}