matiwinnetou / spring-soy-view

Google Closure Templates integration with Spring MVC
Apache License 2.0
16 stars 9 forks source link

Support standard URL-based View Resolution Behavior #12

Closed phasebash closed 10 years ago

phasebash commented 11 years ago

In a vanilla Spring/JSP configuration using the InternalResourceViewResolver, requests mapped to Controllers returning POJOs or Map<String, Object> will have their views resolved to JSPs on the file system in the given prefix using the same path structure as the request.

Example Controller:

    @RequestMapping(value = "/test/bar", method = RequestMethod.GET)
    public Map<String, Object> testBar() {
        return Collections.emptyMap();
    }

Example Config:

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/pages/"/>
        <property name="suffix" value=".jsp"/>
        <property name="order" value="100"/>
    </bean>

A request for http://localhost:8080/test/bar will resolve to a JSP in /WEB-INF/pages/test/bar.jsp. The "viewName" in this case is "/test/bar".

For spring-soy-view, a mapping to a Template within a namespace will be necessary. In the simplest case, the forward slashes could be mapped to periods.

Other UrlBasedViewResolver properties will need to be respected as well (prefix, suffix, etc).

phasebash commented 11 years ago

I can take care of this, but I need your input on how you'd prefer this to be done.

matiwinnetou commented 11 years ago

Yes, this is very interesting, I overlooked this. In our application we are not using InternalResourceViewResolver.

I think the idea which you suggest is a good one, mapping slashes to dots.

If you have an idea how to do this, create a pull request and I will merge this into the code base. We can review and work together on your fork as well.

phasebash commented 11 years ago

That sounds great. I've done this locally on a fork, and currently support prefix, suffix and other superclass properties. Luckily, it was actually simple to do.

When I'm comfortable with it (and have more unit tests) I'll push it up and will let you know.

matiwinnetou commented 11 years ago

This is appreciated. Once it is there, I will review it and let you know. We will integrate it at some point.

matiwinnetou commented 10 years ago

Hi,

Did you have some time to take a look this, I would appreciate if you could contribute this to the next release...

phasebash commented 10 years ago

Sure, I'll make a pull request today.

phasebash commented 10 years ago

https://github.com/mati1979/spring-soy-view/pull/14

Thanks! And thanks again for putting together this incredibly complete Soy implementation for Spring.

matiwinnetou commented 10 years ago

Merged to master.