You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk> on 2008/10/16 09:20:58 UTC

Shared resource, wrong usage?

Hi

Im trying to use shared resources. I load them in 
wicketapplication.init, a similar approach works for me in 1.3, however 
in 1.4m3 I get null resources when I grab them from shared resources.

I can see that the resource are actually bound when I call bind..

The code:


    public static void LoadImages() {

        for (IconType iconType : IconType.values()) {

            ResourceReference consertIconRef = new ResourceReference(
                    Icons.class, iconType.getName());
            consertIconRef.bind(WicketApplication.get());
            log.debug("binding icon to:" + iconType.getName());
            
WicketApplication.get().getSharedResources().add(iconType.getName(),
                    consertIconRef.getResource());

        }

    }

    public static Image getImageForIcon(String id, IconType iconType) {
        log.debug("getting image for:" + iconType.getName());
        Resource resource = 
WicketApplication.get().getSharedResources().get(
                iconType.getName());
        if (resource == null) {
            log.error("got null resource for :" + iconType.getName());
        }

        return new Image(id, resource);
    }

-- 
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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