sure, it depends on how general you end up making it. i think we have sufficient infrastructure in wicket already, so maybe what is needed the most is a wiki example that is far less complicated then the one philip posted and a thin wrapper around our dynamic resource that streams a file from some folder.

let me know once you are done and we will see where we are

-Igor


On 5/5/06, Vincent Jenks < [EMAIL PROTECTED]> wrote:
Once I do, is this something that should be added to Wicket?  Using the uploader for what I'm doing, which I'd imagine would be fairly common, sort of sucks w/o the other half of it....the ability to call those images from non-web folders.


On 5/5/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote:
so what you need is something that maps to some url and when invoked streams the image back to the user.

i see two possible ways to do this

one:
use a separate servlet to do this

two:
use a wicket shared resource

in both approaches the code will be 90% identical

what you need is to somehow tell this servlet or wicket resource which file to stream, this is what you pass in as a parameter
ie: www.server.com/myimageservlet?4

this can tell the servlet that you want to stream c:\\app\\images\\img4.gif

same goes for the wicket resource

you have a resource reference which builds the url that will hit the resource ( urlfor(resourcerefence) ), but you still need to tell it which image you want served

so the entire process once you registered a resource and obtained a reference to it goes like this

<img wicket:id="img"/>

String url="" // base resource url
url="">
WebMarkupContainer img=new WebMarkupContainer("img");
img.add(new SimpleAttributeModifier("src", "url");

or encapsulate this whole thing into a reusable component so you can just do

add(new StoredImage("img", imagenum));


-Igor


On 5/5/06, Vincent Jenks <[EMAIL PROTECTED] > wrote:
Obviously not...or we wouldn't be having this conversation.  It's a folder outside of the webroot.

I'd have a list of strings, basically, to the effect of:

C:\\app\\images\\img1.gif
C:\\app\\images\\img2.gif
C:\\app\\images\\img3.gif
C:\\app\\images\\img4.gif

I may just start storing them as blobs in the DB...they won't change often so I can cache them.  I'm running short on time and starting to bite my nails!  :D


On 5/5/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote:
hmm
is the static location accessible from the web?!?!?!?

-Igor



On 5/5/06, Vincent Jenks <[EMAIL PROTECTED] > wrote:
I guess I'm still a little lost here.  Why would I need to use a querystring to build the string?  Do I? I'm thinking not.

I'm not generating thumbnails...my version of this is much, much, much smaller.  I'm uploading images to a pre-defined, static location.  That part works great, no problems there.  I'm then pulling them from that static location to display them.

I know that static path on disk where the images are located and I know the name ahead of time (looping through a ListItem in a ListView from EJB3 entities in a List).

How is the id querystring param relevant?  Can't I just pass the path + img_name.gif into the urlFor() and be done w/ it?

I'm probably just over-complicating this...

On 5/5/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote:
this is already described in philip's wiki article under download image section

what you want is a stripped down version of the image resource:

public class ImageResource extends DynamicWebResource
{
// CONSTANTS

public static final Log logger = LogFactory.getLog(ImageResource.class);

private static final long serialVersionUID = 1L;

// CONSTRUCTORS

public ImageResource()





   {

super();
}

public ImageResource(Locale local)
{
super(local);
}

// METHODS

// MEMBERS

@Override
protected ResourceState getResourceState()






{
ValueMap params = getParameters();

String imageId=params.get("id");
byte[] data="" style="color: rgb(255, 0, 0);">loadImageData(id);
Date lastModified=





getImageLastMod(id);

ImageResourceState state =
new ImageResourceState(Time.valueOf(lastModified));
state.setContentType
(imageEntry.getContentType




());
state.setData(imageService.getImage(imageEntry));

return state;
}

class ImageResourceState extends ResourceState
{
// CONSTRUCTORS


ImageResourceState(Time lastModified)




{
super();
this.lastModified = lastModified;
}

// MEMBERS

private String contentType;


@Override
public String getContentType()




{
return contentType;
}
void setContentType(String contentType)
{
this.contentType

= contentType;
}

private byte[] data;


@Override

public byte[] getData()
{
return data;
}
void setData(byte[] data)
{
this.data = ""> }

@Override





public int getLength()

{
return data.length;
}

private Time lastModified;
@Override
public Time lastModifiedTime()
{


return lastModified;


}

// METHODS
}
}
then you register this as a shared resource and get a resource reference. then when you want to build a url for an image you do this

ResourceReference imageResource=...
String url="">
hope this clears it up some more.

-Igor



hope this clears it up some more.


On 5/5/06, Vincent Jenks <[EMAIL PROTECTED]> wrote:
Hi Philip,

Thanks so much for the sample code and wiki entry...it makes a lot of sense, however, it is a little bit of overkill for the app I built.  You gave me a bazooka to take to a gun-fight!

Really, what it comes down to is; I need to turn the byte array I'm pulling out of the file system and turn it into an image.  The upload I already had one of my devs build was working fine and I'm not sure (for now anyways) we need your full-on image service.

I'm googling around to see if I can figure out how to simply turn the byte array into an image I can display on a page...not something I'm familiar with.  I couldn't gather from your example how this would be done, either.

Thanks for the help!

On 5/2/06, Philip A. Chapman < [EMAIL PROTECTED]> wrote:
How was it?  Do I need to make any edits to make it easier to understand?


On Mon, 2006-05-01 at 11:28 -0600, Vincent Jenks wrote:
I'll read through this, thanks a ton!

On 5/1/06, Philip A. Chapman < [EMAIL PROTECTED]> wrote:
Sorry for the delay, but I spent the time to create a wiki page so that hopefully others can benefit from what little I have to say on the subject:

http://www.wicket-wiki.org.uk/wiki/index.php/UploadDownload


On Mon, 2006-05-01 at 08:01 -0700, Igor Vaynberg wrote:
yes, thats it.

basically you would create a that resource that takes the filename/fileid/whatever off the url and streams the file. there is an example of this, i will ask one of my friends to post it here. stay tuned.

-Igor


On 5/1/06, Vincent Jenks < [EMAIL PROTECTED]> wrote:
Did you mean to say DynamicWebResource?

On 4/21/06, Johan Compagner <[EMAIL PROTECTED]> wrote:
> you could save those images to a DB or to a working dir on the server.
> Then have a DynamicByteArrayResource or the 1.2 one: WebDynamicResource to
> load the image from the location you stored the image.
>
> johan
>
>
> On 4/21/06, Steve Knight < [EMAIL PROTECTED]> wrote:
> >
> > I am creating a form that will allow users to upload image files that will
> be displayed on other pages.  How should I go about uploading the images so
> that they can be used in Wicket Image components on the other pages?  The
> upload part is not problem, I just don't know where I should put them.
> >
> > On my view pages, I am using ThumbnailImageResource which takes a
> WebResource in it's contructor to find the image.  Where should I save the
> images to make this work?
> >
> > Thanks.
> >
> >
> > Steve
> >
> >
> >
>
>


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmdlnk&kid0709&bid&3057&dat1642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-- 
Philip A. Chapman

Desktop and Web Application Development:
Java, .NET, PostgreSQL, MySQL, MSSQL
Linux, Windows 2000, Windows XP

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQBEVjqCAdpynRSGw3URAiqOAKCDsSpRHf8WQ8EGaneJoAGS4WD5bwCfaYED
Kb0kHbQYO8P7wOBWUVGWw7I=
=x7ml
-----END PGP SIGNATURE-----



-- 
Philip A. Chapman

Desktop and Web Application Development:
Java, .NET, PostgreSQL, MySQL, MSSQL
Linux, Windows 2000, Windows XP

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQBEV4M6AdpynRSGw3URAhkvAJ4tHqn2wYOd9LuuD43MWsGhnGGgxACffIoB
EKdVHMEHbsM6PC+E9nkwcFw=
=GFH9
-----END PGP SIGNATURE-----










Reply via email to