Now all work!!! :) Thanks a lot for supporting and patience!! If I have time, I try one solution you described to me
regards Daniele 2009/1/24 gregor <[email protected]>: > > I think you understand the problem now. > > If you wish to continue trying to get round this (i.e. continue to use > the Image newPhoto = new Image("category/photoName) approach) then you > will have to search around the Internet to see if someone has a good > solution for it (that also works in GWT hosted mode BTW!). Remember, > what you are doing is trying to use a very simple method to read the > new dynamically added photos (just by short relative URL) instead of > using a more robust persistence mechanism The public folder is not > designed to handle dynamic data like that, it's meant for static HTML, > CSS, js, image files etc. so you are hitting problems. There may be a > way to do it, I don't know. Someone must have tried before I suppose. > > The alternative is to create a more robust mechanism for storing your > photo albums, setting it up automatically when you deploy the > application. One way to do this is to follow these steps: > > 1) Place your "start up" example albums in, say, \src\albums. When you > deploy to real Tomcat copy this folder to WEB-INF\classes\album. This > means it is in the classpath for both development and deployment. > 2) Add an override init() method to your LoadPhotoFromAlbum RPC > servlet (or any other sevlet you always call before that). In this > method examine if you have already created the real photo album on > disk (i.e. you have preciously run the application on this server), > and if not copy the start up album to set it up. In a real Tomcat > instance you can specify a start up servlet in web.xml to do this, but > you can't (easily) do this in GWT hosted mode). Because you put the > the start up albums in classes\albums & src\albums, you can get at > them using \albums. > 3) You need a relative disk location to store the photo album that is > separate from your web application folders but still portable. You > can, for example, place it relative to your Tomcat instance > directories. To get the directory paths you can examine System > properties. This, for example, works for JBoss, Tomcat and GWT hosted > mode Tomcat: > > private static String getSystemBaseDir() { > // try JBoss > String dir = System.getProperty("jboss.server.home.dir"); > if (dir!=null) { > log.info("Using JBoss: " + dir); > return dir + File.separator + "data"; > } > // try Tomcat > dir = System.getProperty("catalina.home"); > if (dir!=null) { > log.info("Using Tomcat: " + dir); > return dir; > } > // otherwise GWT hosted mode default > dir = System.getProperty("user.dir"); > log.info("Using default dir: " + dir); > return dir; > } > > use this to create and subsequently query your album directory > structure under the main Tomcat home directory, but not under the > webapps directory, or your own application's directory. If in any > doubt about which system properties are available, just put this in a > servlet: > > Properties props = System.getProperties(); > props.list(System.out); > > 4) Use a Filedownload HttpServlet to get the images instead of using > Image(url) thatreads the photo file and writes it to the servlet > response output stream. Search this group for examples of that, and > there are many examples on the net. > > This will definitely work, and it will also work in GWT hosted mode, > Tomcat, and any other servlet container or application server you add > support for in that getSystemBaseDir() method. > > regards > gregor > > > > > > On Jan 24, 12:24 pm, Daniele <[email protected]> wrote: >> Nothing works!!! >> >> For Gregory: >> Application see new photo uploaded when I click on refresh button on >> gwt browser implementation. >> >> Maybe I have understanding problem. >> >> Images uploaded necessarily go on public directory because client >> don't have access to other directory on server or local machine, ok? >> When application starting, it's copy all file present on public >> directory and put it on public directory of gwt compilation output >> (usually call com.package.modulename). >> I think error probabilly is on UPLOAD_DIRECTORY path on server side. >> Whats proper path for UPLOAD_DIRECTORY?? >> If I set UPLOAD_DIRECTORY= "images/album/" application give me an >> error (resource not found or similar)...if I set >> UPLOAD_DIRECTORY="src/com/webphotogallery/public/album/" I go into >> error because this directory it's not seen by application when run, >> but only when I click on reload button.. >> >> My idea are correct? >> >> Daniele >> >> (SORRY FOR MY ENGLISH!!! :) Many words are generated by Google Translate! :) >> ) >> >> 2009/1/23, Daniele <[email protected]>: >> >> > I try. >> >> > P.S. >> > If solution work, it's not important if are better or not :)!!! >> >> > 2009/1/23, [email protected] <[email protected]>: >> >> >> I had a similar problem. >> >> >> The problem I have is caused by cacheing of the images which can be >> >> circumvented with the following hack. >> >> >> img.setUrl( the_normal_url + "?" + String.valueOf(Math.Random() ) ); >> >> >> Why does it work, the browser sees it as a new url so does not use the >> >> cached image, the server ignores everything after the question mark so >> >> returns the image you are after. >> >> >> There must be a better solution than this, if you know one please post >> >> here! >> >> >> good luck. >> >> >> On Jan 22, 2:48 pm, gregor <[email protected]> wrote: >> >>> Hi Danielle, >> >> >>> I might have twigged what the problem is if you are getting this >> >>> problem in hosted mode. In hosted mode, the GWT dev shell creates a >> >>> temporary Tomcat instance, but it does not seem to copy the public or >> >>> client folders to that instance, only the servlets and server side >> >>> stuff. I think it just reads the client and public folders from your >> >>> source tree and loads them internally so it can run the browser >> >>> simulation via Java (so you can debug your client in Java etc). It >> >>> will only pick up the new image if you click refresh. >> >> >>> If it does not pick it up if you click refresh, but does if you >> >>> recompile, you have a more difficult problem. You need to be quite >> >>> certain on this point. You can check this yourself by creating an >> >>> Image in client for a file name that does not exist and running hosted >> >>> mode. It won't find it, and if you copy the image file to /public >> >>> whist it is still running it still won't find it. But if you hit >> >>> refresh it will. >> >> >>> Gregor >> >> >>> On Jan 21, 7:28 pm, gregor <[email protected]> wrote: >> >> >>> > OK, say I have test project com.willow.sandbox.Sandbox.gwt.xml >> >> >>> > I run project in hosted mode and URL in the hosted mode browser when I >> >>> > run it is: >> >> >>> > http://localhost:8888/com.willow.sandbox.SandBox/SandBox.html >> >> >>> > I manually put an image in >> >>> > c:\....\src\com\willow\sandbox\public\images >> >>> > \star.gif >> >> >>> > I display this image in panel like so in my test GWT application: >> >> >>> > someWidget.add(new Image(images/star.gif); >> >> >>> > I run application again and It works fine. Now, still in same hosted >> >>> > mode session, I select "compile/browse". This displays my application >> >>> > in my system default browser, but as part of that process it also >> >>> > compiles all the javascirpt, HTML files etc and sets up the public >> >>> > folder - including my image, start.gif This also works, so I close >> >>> > this browser tab for now. >> >> >>> > I know open new browser tab and enter this URL (but I do *not* stop >> >>> > the hosted mode run - this won't work if you do that because the GWT >> >>> > hosted mode Tomcat will be also stopped): >> >> >>> > http://localhost:8888/com.willow.sandbox.SandBox/images/star.gif >> >> >>> > So my system browser finds and displays the star.gif image no problem! >> >> >>> > If you follow these steps (using your own paths for the URL of >> >>> > course), since we have already proved that the new image file has been >> >>> > correctly saved (because String[] photoList = photo.list(); picked it >> >>> > up), then you should be able to display the new image in your system >> >>> > browser, thus proving beyond reasonable doubt it is really there. >> >> >>> > That will further isolate your problem to either some error in your >> >>> > client side code (however unlikely that may seem since it works when >> >>> > you reboot), or something weird going on with browser caching. >> >> >>> > regards >> >>> > gregor >> >> >>> > On Jan 21, 5:27 pm, Daniele <[email protected]> wrote: >> >> >>> > > I don't understand.. >> >> >>> > > 2009/1/20, gregor <[email protected]>: >> >> >>> > > > There's something weird about this. Have you tried (while the >> >>> > > > image >> >>> > > > is >> >>> > > > in "limbo", i.e. just after you've saved it) copying exactly the >> >>> > > > same >> >>> > > > URL string as your GWT client code produces into your browser/new >> >>> > > > browser tab? >> >> >>> > > > On Jan 20, 12:31 pm, Daniele <[email protected]> wrote: >> >>> > > >> Yes. >> >>> > > >> Error is not introduced when I make the refresh through the >> >>> > > >> push-button or reboot application. >> >>> > > >> I am becoming crazy for this bug!!! :) >> >> >>> > > >> Daniele. >> >> >>> > > >> 2009/1/20, gregor <[email protected]>: >> >> >>> > > >> > Have you tried hitting the refresh button rather than >> >>> > > >> > recompiling/ >> >>> > > >> > deploying the application after loading new image. Does this >> >>> > > >> > make >> >>> > > >> > a >> >>> > > >> > difference? >> >> >>> > > >> > On Jan 20, 8:59 am, Daniele <[email protected]> wrote: >> >>> > > >> >> Image saving on folder and String[] photo are ok! I write >> >>> > > >> >> array >> >>> > > >> >> on a >> >>> > > >> >> file when click on widget album after uploading and image name >> >>> > > >> >> it's >> >>> > > >> >> present. >> >>> > > >> >> In development shell, appears this message when I open a album >> >>> > > >> >> widget >> >>> > > >> >> after uploading of image: >> >> >>> > > >> >> Resource not found wpimg/album/Sport/image1.jpg. Could a file >> >>> > > >> >> missing >> >>> > > >> >> from the public path or a <servlet> tag misconfigured??? >> >> >>> > > >> >> Obviously when I reload application, this message disappear. >> >> >>> > > >> >> Daniele >> >> >>> > > >> >> 2009/1/19, Daniele <[email protected]>: >> >> >>> > > >> >> > I try! >> >> >>> > > >> >> > 2009/1/18, gregor <[email protected]>: >> >> >>> > > >> >> >> so if you place a debug point here: >> >> >>> > > >> >> >> private static final long serialVersionUID = 403L; >> >> >>> > > >> >> >> public String[] getImageName(String category) { >> >> >>> > > >> >> >> File photo = new >> >>> > > >> >> >> File("src/com/webphotogallery/public/ >> >>> > > >> >> >> wpgimg/album/" >> >>> > > >> >> >> + category); >> >>> > > >> >> >> //File photo = new File("wpgimg/album/" + >> >>> > > >> >> >> category); >> >> >>> > > >> >> >> String[] photoList = photo.list(); >> >> >>> > > >> >> >> return photoList; <<<<<<<< DEBUG >> >>> > > >> >> >> } >> >> >>> > > >> >> >> Does the new image appear in the photoList array? >> >> >>> > > >> >> >> On Jan 18, 3:32 pm, Daniele <[email protected]> wrote: >> >>> > > >> >> >>> File are saved into a folder that I choose. >> >>> > > >> >> >>> I look into a folder when application make a upload call. >> >>> > > >> >> >>> But image doesn't appear when open a album widget... >> >> >>> > > >> >> >>> 2009/1/14, Daniele <[email protected]>: >> >> >>> > > >> >> >>> > I try some. >> >>> > > >> >> >>> > Thanks. >> >> >>> > > >> >> >>> > Daniele. >> >> >>> > > >> >> >>> > 2009/1/14, gregor <[email protected]>: >> >> >>> > > >> >> >>> >> There's nothing obviously wrong with this, and the fact >> >>> > > >> >> >>> >> that the >> >>> > > >> >> >>> >> uploaded photo appears when you restart server supports >> >>> > > >> >> >>> >> that. >> >>> > > >> >> >>> >> Next >> >>> > > >> >> >>> >> obvious thing to eliminate may be to check exactly >> >>> > > >> >> >>> >> where >> >>> > > >> >> >>> >> on your >> >>> > > >> >> >>> >> disk >> >>> > > >> >> >>> >> the uploaded photo is actually written to. Perhaps it >> >>> > > >> >> >>> >> is >> >>> > > >> >> >>> >> not >> >>> > > >> >> >>> >> where >> >>> > > >> >> >>> >> you >> >>> > > >> >> >>> >> expect, and what is happening is that it is being >> >>> > > >> >> >>> >> copied >> >>> > > >> >> >>> >> over to >> >>> > > >> >> >>> >> the >> >>> > > >> >> >>> >> "right" location as part of your deployment/hosted mode >> >>> > > >> >> >>> >> running >> >>> > > >> >> >>> >> procedure when you restart server. If you upload a >> >>> > > >> >> >>> >> photo >> >>> > > >> >> >>> >> and >> >>> > > >> >> >>> >> then >> >>> > > >> >> >>> >> check where it goes while the app is still running, you >> >>> > > >> >> >>> >> should >> >>> > > >> >> >>> >> be >> >>> > > >> >> >>> >> able >> >>> > > >> >> >>> >> to confirm that one way or another. >> >> >>> > > >> >> >>> >> On Jan 14, 1:52 pm, Daniele <[email protected]> >> >>> > > >> >> >>> >> wrote: >> >>> > > >> >> >>> >>> Code of upload >> >> >>> > > >> >> >>> >>> [CODE] >> >>> > > >> >> >>> >>> package com.webphotogallery.server; >> >> >>> > > >> >> >>> >>> import java.io.File; >> >>> > > >> >> >>> >>> import java.io.IOException; >> >>> > > >> >> >>> >>> import java.io.PrintWriter; >> >>> > > >> >> >>> >>> import java.util.Iterator; >> >>> > > >> >> >>> >>> import java.util.List; >> >> >>> > > >> >> >>> >>> import javax.servlet.ServletException; >> >>> > > >> >> >>> >>> import javax.servlet.http.HttpServlet; >> >> ... >> >> read more ยป > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
