views:

30

answers:

1

How can I write the freemarker templates like this:

<#import "spring.ftl" as s>

<@s.form path="object" action="/new.do" method="POST">
    <@s.formInput "name"/> <!-- I want this resolved as "object.name" -->
    <!--
        100s of other properties...
      -->
</@s.form>

instead of this:

<#import "spring.ftl" as s>

<form action="/new.do" method="POST">
    <@s.formInput "object.name"/>
    <!--
        100s of other properties...
      -->
</form>
A: 

You can bind the object like this:

<@s.bind "object"/>

Then you can use your first example

<@s.formInput "name"/>
Daniel Moura
ok, I'm gonna try...
Xan
It doesn't work. I got a"Method public org.springframework.web.servlet.support.BindStatus org.springframework.web.servlet.support.RequestContext.getBindStatus(java.lang.String) throws java.lang.IllegalStateException."I noticed that in the formInput macro it calls bind with the given path again, replacing the previous one, I suppose...I'm using the spring.ftl provided with spring-webmvc-3.0.3.RELEASE.jarThanks for any further suggestion. ;)
Xan