Hi!
I need to display more than a hundred pictures on the page (about 100kb -
300kb), i but I got the error about heap. I read that the reason of this
error could be serialization of the page, but I don't know, how to solve
this.

TestMultipleImages.html:
/<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns:wicket="http://wicket.apache.org";>
<head>
</head>
<body>

        <form wicket:id="form">
                <input wicket:id="uploadField" type="file" multiple />
                <button>SUMBIT</button>
        </form>

          
        

</body>
</html>/

TestMultipleImages.java:
/public class TestMultipleImages extends WebPage {
        private FileUploadField uploadField;
        private Form<String> form;

        private static List<BufferedImage> images = new 
ArrayList<BufferedImage>();

        @Override
        protected void onBeforeRender() {
                removeAll();

                RepeatingView imageRepeater = new 
RepeatingView("imageRepeater");
                add(imageRepeater);
                for (BufferedImage image : images) {
                        WebMarkupContainer container = new
WebMarkupContainer(imageRepeater.newChildId());
                        imageRepeater.add(container);

                        BufferedDynamicImageResource resource = new
BufferedDynamicImageResource();
                        resource.setImage(image);

                        container.add(new Image("image", resource));
                }

                form = new Form<String>("form") {
                        @Override
                        protected void onSubmit() {
                                for (FileUpload fileUpload : 
uploadField.getModelObject()) {
                                        byte[] bytes = fileUpload.getBytes();

                                        ByteArrayInputStream bais = new 
ByteArrayInputStream(bytes);
                                        BufferedImage readedImage = null;
                                        try {
                                                readedImage = 
ImageIO.read(bais);
                                                bais.close();
                                        } catch (IOException e) {
                                                e.printStackTrace();
                                        }
                                        images.add(readedImage);
                                }
                                
                                super.onSubmit();
                        }
                };
                
                uploadField = new FileUploadField("uploadField");
                uploadField.setModel(new ListModel<FileUpload>());
                form.add(uploadField);
                add(form);

                super.onBeforeRender();
        }
}/




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/OutOfMemoryError-Java-heap-space-when-i-try-to-upload-and-show-a-hundred-100kb-pics-tp4661159.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to