Example usage for org.springframework.web.servlet.support BindStatus getExpression

List of usage examples for org.springframework.web.servlet.support BindStatus getExpression

Introduction

In this page you can find the example usage for org.springframework.web.servlet.support BindStatus getExpression.

Prototype

@Nullable
public String getExpression() 

Source Link

Document

Return a bind expression that can be used in HTML forms as input name for the respective field, or null if not field-specific.

Usage

From source file:org.hdiv.web.servlet.view.freemarker.FreeMarkerMacroTests.java

public void testExposeSpringMacroHelpers() throws Exception {
    FreeMarkerView fv = new FreeMarkerView() {
        @Override// w  w w  . j ava2 s. com
        protected void processTemplate(Template template, SimpleHash fmModel, HttpServletResponse response)
                throws TemplateException {
            Map model = fmModel.toMap();
            assertTrue(
                    model.get(FreeMarkerView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE) instanceof RequestContext);
            RequestContext rc = (RequestContext) model
                    .get(FreeMarkerView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE);
            BindStatus status = rc.getBindStatus("tb.name");
            assertEquals("name", status.getExpression());
            assertEquals("juergen", status.getValue());
        }
    };
    fv.setUrl(TEMPLATE_FILE);
    fv.setApplicationContext(wac);
    fv.setExposeSpringMacroHelpers(true);

    Map model = new HashMap();
    model.put("tb", new TestBean("juergen", 99));
    fv.render(model, request, response);
}