Hi, sorry. I need a way to get the base64 data of the image into a Java Object. That I can save it into the database. I do not known a way to use the Wicket-Model concept.
On submit, wicket save all datas from the elements with a wicket:id attribute into the models. But in my case wicket does not known that in the div a img element will append. The img tag will add dynamically into the html. Have Wicket provided a chance to get the encoded image into a Java Object? I'm not a JavaEE expert, so I do not known how I get this info from client site to the java server site. I hope I could be better described the problem. Thanks Christopher Am 07.10.2015 um 09:29 schrieb Martin Grigorov: > Hi, > > What is the issue exactly? > I see no problem for this (assuming you use modern browser that supports > all used JS APIs). > > There is no Wicket involved so I don't expect any problems caused by Wicket. > > Martin Grigorov > Wicket Training and Consulting > https://twitter.com/mtgrigorov > > On Wed, Oct 7, 2015 at 8:58 AM, Christopher Auth <[email protected]> wrote: > >> Hi, >> >> I have a problem, that I need to load a html element during submit, that >> have not a 'wicket:id' attribute. >> >> It is possible to do that? >> >> In the html tree in the browser I add a new 'img' element with >> javascript to a div. This element has not a wicket:id. But I need the >> base64 encoded file in the img-tag. >> >> >> >> The HTML that Wicket used: >> >> <div class="editablediv" id="editablediv" contenteditable></div> >> <script type="text/javascript"> >> if (document.addEventListener) { >> document.addEventListener('paste', onPasteTriggered, false); >> } >> >> /*Called whenever a paste event has occured*/ >> function onPasteTriggered(e) { >> if (typeof e.clipboardData != 'undefined') { >> var copiedData = e.clipboardData.items[0]; //Get the >> clipboard data >> >> /*If the clipboard data is of type image, read the data*/ >> if (copiedData.type.indexOf("image") == 0) { >> var imageFile = copiedData.getAsFile(); >> >> /*We will use HTML5 FileReader API to read the image file*/ >> var reader = new FileReader(); >> >> reader.onload = function (evt) { >> var result = evt.target.result; //base64 encoded image >> >> /*Create an image element and append it to the >> content editable div*/ >> var img = document.createElement("img"); >> img.src = result; >> >> document.getElementById("editablediv").appendChild(img); >> }; >> >> /*Read the image file*/ >> reader.readAsDataURL(imageFile); >> } >> } >> } >> </script> >> >> >> The HTML from Browser after paste the image: >> >> <div contenteditable="" id="editablediv" class="editablediv"><img alt="" >> >> src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAt0AAAJSCAYAAAAf0Xn.../fic+YIIIAAAggggAAC3RH4f57viSsFn9zlAAAAAElFTkSuQmCC"></div> >> >> >> >> Thanks >> >> Christopher >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
