You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ryan LaHue <ry...@gmail.com> on 2009/04/13 18:38:51 UTC

ResourceReferences not working as expected

I'm having trouble getting ResourceReferences to work for some reason, and
was hoping somebody could give me some pointers.  I'm using wicket 1.4.

As a simple test I added a new page and put a "test.png" image in the same
directory in my project.  My structure is like so:
project
|--src
|----mypkg
|------test
|--------TestResource.java
|--------test.png
|--public_html
|----images
|------test.png

Java class: mypkg.test.TestResource.java
...
    ResourceReference ref = new ResourceReference(TestResource.class,
"test.png");
    System.out.println("Valid resource: " + (ref.getResource() != null));
...

This always returns false.  I also tried putting the "test.png" in my
public_html/images directory but no luck.  I don't seem to have any luck
getting these Resources to load correctly, so I've had to resort to
hardcoding my javascript references into my html files.  Anybody have any
suggestions?  I've verified that all the files are being copied to my output
classes folder.

Re: ResourceReferences not working as expected

Posted by mallet <ry...@gmail.com>.
Igor, you were right after all.  There was an IDE exclusion on of my script's
dependent files so it was not being copied over, causing my script to crash
and appear not to be working.  I thought I had verified they were all making
it over but I missed one.  Sincerest apologies for taking up your time. 
Thanks for your generous help once again.


igor.vaynberg wrote:
> 
> make sure whatever ide/tools you use copies non java resources into
> the compiled classpath.
> 
> -igor
> 
> On Mon, Apr 13, 2009 at 9:38 AM, Ryan LaHue <ry...@gmail.com>
> wrote:
>> I'm having trouble getting ResourceReferences to work for some reason,
>> and
>> was hoping somebody could give me some pointers.  I'm using wicket 1.4.
>>
>> As a simple test I added a new page and put a "test.png" image in the
>> same
>> directory in my project.  My structure is like so:
>> project
>> |--src
>> |----mypkg
>> |------test
>> |--------TestResource.java
>> |--------test.png
>> |--public_html
>> |----images
>> |------test.png
>>
>> Java class: mypkg.test.TestResource.java
>> ...
>>    ResourceReference ref = new ResourceReference(TestResource.class,
>> "test.png");
>>    System.out.println("Valid resource: " + (ref.getResource() != null));
>> ...
>>
>> This always returns false.  I also tried putting the "test.png" in my
>> public_html/images directory but no luck.  I don't seem to have any luck
>> getting these Resources to load correctly, so I've had to resort to
>> hardcoding my javascript references into my html files.  Anybody have any
>> suggestions?  I've verified that all the files are being copied to my
>> output
>> classes folder.
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/ResourceReferences-not-working-as-expected-tp23024914p23026833.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ResourceReferences not working as expected

Posted by Igor Vaynberg <ig...@gmail.com>.
make sure whatever ide/tools you use copies non java resources into
the compiled classpath.

-igor

On Mon, Apr 13, 2009 at 9:38 AM, Ryan LaHue <ry...@gmail.com> wrote:
> I'm having trouble getting ResourceReferences to work for some reason, and
> was hoping somebody could give me some pointers.  I'm using wicket 1.4.
>
> As a simple test I added a new page and put a "test.png" image in the same
> directory in my project.  My structure is like so:
> project
> |--src
> |----mypkg
> |------test
> |--------TestResource.java
> |--------test.png
> |--public_html
> |----images
> |------test.png
>
> Java class: mypkg.test.TestResource.java
> ...
>    ResourceReference ref = new ResourceReference(TestResource.class,
> "test.png");
>    System.out.println("Valid resource: " + (ref.getResource() != null));
> ...
>
> This always returns false.  I also tried putting the "test.png" in my
> public_html/images directory but no luck.  I don't seem to have any luck
> getting these Resources to load correctly, so I've had to resort to
> hardcoding my javascript references into my html files.  Anybody have any
> suggestions?  I've verified that all the files are being copied to my output
> classes folder.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ResourceReferences not working as expected

Posted by mallet <ry...@gmail.com>.
Thanks for the responses.

Jeremy: That's really strange... when I put the ResourceReference inside the
image constructor it did work for the png image.  I still not having any
luck getting my javascript and .swf files to load, but I will continue
trying.

Igor: I made sure the IDE is copying all my filetypes into the classes
folder, so that doesn't seem to be the problem in this case.

I will update this topic if I figure out what I'm doing wrong.


Jeremy Thomerson-5 wrote:
> 
> Have you tried using it in an img tag rather than println?  I.e.:
> 
> add(new Image("img", ref));
> 
>  
> 
> --
> Jeremy Thomerson
> http://www.wickettraining.com
> 
> 
> 
> On Mon, Apr 13, 2009 at 11:38 AM, Ryan LaHue <ry...@gmail.com>
> wrote:
> 
>> I'm having trouble getting ResourceReferences to work for some reason,
>> and
>> was hoping somebody could give me some pointers.  I'm using wicket 1.4.
>>
>> As a simple test I added a new page and put a "test.png" image in the
>> same
>> directory in my project.  My structure is like so:
>> project
>> |--src
>> |----mypkg
>> |------test
>> |--------TestResource.java
>> |--------test.png
>> |--public_html
>> |----images
>> |------test.png
>>
>> Java class: mypkg.test.TestResource.java
>> ...
>>    ResourceReference ref = new ResourceReference(TestResource.class,
>> "test.png");
>>    System.out.println("Valid resource: " + (ref.getResource() != null));
>> ...
>>
>> This always returns false.  I also tried putting the "test.png" in my
>> public_html/images directory but no luck.  I don't seem to have any luck
>> getting these Resources to load correctly, so I've had to resort to
>> hardcoding my javascript references into my html files.  Anybody have any
>> suggestions?  I've verified that all the files are being copied to my
>> output
>> classes folder.
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/ResourceReferences-not-working-as-expected-tp23024914p23026294.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ResourceReferences not working as expected

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Have you tried using it in an img tag rather than println?  I.e.:

add(new Image("img", ref));

<img wicket:id="img" />

--
Jeremy Thomerson
http://www.wickettraining.com



On Mon, Apr 13, 2009 at 11:38 AM, Ryan LaHue <ry...@gmail.com> wrote:

> I'm having trouble getting ResourceReferences to work for some reason, and
> was hoping somebody could give me some pointers.  I'm using wicket 1.4.
>
> As a simple test I added a new page and put a "test.png" image in the same
> directory in my project.  My structure is like so:
> project
> |--src
> |----mypkg
> |------test
> |--------TestResource.java
> |--------test.png
> |--public_html
> |----images
> |------test.png
>
> Java class: mypkg.test.TestResource.java
> ...
>    ResourceReference ref = new ResourceReference(TestResource.class,
> "test.png");
>    System.out.println("Valid resource: " + (ref.getResource() != null));
> ...
>
> This always returns false.  I also tried putting the "test.png" in my
> public_html/images directory but no luck.  I don't seem to have any luck
> getting these Resources to load correctly, so I've had to resort to
> hardcoding my javascript references into my html files.  Anybody have any
> suggestions?  I've verified that all the files are being copied to my
> output
> classes folder.
>