Re: Given a resource URI, how to find out which group it belongs to in wro4j

Showing 1-7 of 7 messages
Re: Given a resource URI, how to find out which group it belongs to in wro4j Alex Objelean 6/14/12 12:01 AM
The WroModel can be accessed using WroModelFactory. 
You can inspect the model by iterating on available groups collections and find if a particular resource is part of the group. 
If you find it useful, the WroModel will be added a new method: List<Group> getGroupsOfResource(Resource resource);  

Alex

On Thursday, June 14, 2012 4:05:44 AM UTC+3, doncar...@gmail.com wrote:
I would like to know which group/groups has got a particular resource  n it. For eg: I want to know which Group consists the resource with the uri - http:/static.com/static/foo.css
Re: Given a resource URI, how to find out which group it belongs to in wro4j .? 6/19/12 6:03 PM
Thank you. It would be easier with an api instead. Will update you how it goes. Thanks again.
Re: Given a resource URI, how to find out which group it belongs to in wro4j Alex Objelean 6/20/12 6:59 AM
Ok, I'll add a new method which will expose this information in WroModel.

Cheers,
Alex
Re: Given a resource URI, how to find out which group it belongs to in wro4j .? 6/21/12 6:13 PM
Hi,

How can I access the WroModel from a spring bean ? I was using the following code and it is erroring out saying "No context associated with CURRENT request cycle!";

      ServletContextAttributeHelper helper =  new ServletContextAttributeHelper(m_context);
        WroManagerFactory wroManagerFactory = helper.getManagerFactory();
        WroManager wroManager = wroManagerFactory.create();    // This is the line where error is occuring !


        WroModelFactory wroModelFactory = wroManager.getModelFactory();
        WroModel wroModel = wroModelFactory.create();
        Collection<Group> groups = wroModel.getGroups();
        for (Group group : groups) {
            List<Resource> resources = group.getResources();
            for (Resource resource : resources) {
                m_map.put(resource.getUri(), group.getName());
            }
        }

Thank you.
Re: Given a resource URI, how to find out which group it belongs to in wro4j Alex Objelean 6/22/12 1:29 AM
Every operation performed by wro4j requires to access the Context object (the one which contains details about current request). The model can be inspected only during the request. You can find more details on this page: http://code.google.com/p/wro4j/wiki/WroServletContextListener  (@see AddWroContextFilter to web.xml section).

It is possible to access the model outside the request filter, but it won't be the same instance used by wro4j. You can build it using XmlModelFactory and loading from the location where the wro.xml is stored or GroovyModelFactory for loading wro.groovy file. Find more about model on wiki: http://code.google.com/p/wro4j/wiki/WroModel

Cheers,
Alex
Re: [wro4j] Re: Given a resource URI, how to find out which group it belongs to in wro4j Martin Grigorov 6/22/12 1:33 AM
Hi,

Making your bean request or session scoped should help.
> --
> You received this message because you are subscribed to the Google Groups
> "wro4j" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/wro4j/-/2eHl9TJQc4UJ.
> To post to this group, send email to wr...@googlegroups.com.
> To unsubscribe from this group, send email to
> wro4j+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/wro4j?hl=en.
Re: [wro4j] Re: Given a resource URI, how to find out which group it belongs to in wro4j Alex Objelean 6/22/12 1:40 AM
That's true, but you still have to map WroFilter to /* or similar in order to make the Context available.

Alex