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

50 vistas
Ir al primer mensaje no leído

Alex Objelean

no leída,
14 jun 2012, 3:01:49 a.m.14/6/12
para wr...@googlegroups.com
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

.?

no leída,
19 jun 2012, 9:03:58 p.m.19/6/12
para wr...@googlegroups.com
Thank you. It would be easier with an api instead. Will update you how it goes. Thanks again.

Alex Objelean

no leída,
20 jun 2012, 9:59:05 a.m.20/6/12
para wr...@googlegroups.com
Ok, I'll add a new method which will expose this information in WroModel.

Cheers,
Alex

.?

no leída,
21 jun 2012, 9:13:37 p.m.21/6/12
para wr...@googlegroups.com
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.

Alex Objelean

no leída,
22 jun 2012, 4:29:49 a.m.22/6/12
para wr...@googlegroups.com
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

Martin Grigorov

no leída,
22 jun 2012, 4:33:36 a.m.22/6/12
para wr...@googlegroups.com
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.

Alex Objelean

no leída,
22 jun 2012, 4:40:55 a.m.22/6/12
para wr...@googlegroups.com
That's true, but you still have to map WroFilter to /* or similar in order to make the Context available.

Alex
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos