adding new mvc
Posted: Wed Sep 10, 2014 12:25 pm
Hi there, trying to add additional pages and form handling here.
I have a simple foo.html that looks like this (residing in site\src\main\webapp\WEB-INF\templates\myfolder\foo.html)
[begin]
<h1>Hi there!</h1>
<div th:if="${mystuff != null}">
My stuff:<br/>
<h2 th:text="${mystuff.data1}">mystuff data1 default value</h2>
<h2 th:text="${mystuff.data2}">mystuff data2 default value</h2>
<h2 th:text="${mystuff.data3}">mystuff data3 default value</h2>
</div>
<h1>Testing form</h1>
<form action="/myform/datapost" method="POST">
Text1 <input type="text" name="data1" /><br/>
Text2 <input type="text" name="data2" /><br/>
num3 <input type="text" name="data3" /><br/>
<input type="submit" value="submit"/>
</form>
[end]
I added the following in applicationContext-security.xml, so I am allowing things with /myform pattern. (otherwise I get an error on submit)
<sec:http pattern="/myform/**" security="none" />
My controller method looks like this, and I am able to see the data that I put into the form in that LOG line.
The MyData class is an extremely simple POJO.
@RequestMapping(value="/myform/datapost", method = RequestMethod.POST)
public ModelAndView doSomething5(@ModelAttribute("MyData")MyData data) {
LOG.info("Here is data: "+data.getData1()+","+data.getData2()+" "+data.getData3());
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("myfolder/foo");
modelAndView.addObject("mystuff", data);
return new ModelAndView("myfolder/foo");
}
My little goal is to re-display the foo.html page with the data I entered but I am getting the following...
HTTP ERROR 500
Problem accessing /myform/datapost. Reason:
Exception evaluating SpringEL expression: "customer.anonymous" (layout/partials/header:5)
Caused by:
org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "customer.anonymous" (layout/partials/header:5)
and that looks like it is because this page does not know what customer it is dealing with.
How can I get around that?
It probably has to do with configuring the authentication-manager blAuthenticationManager section?
So the general question is how can one add additional mvc to the broadleaf demo that works with the rest of site?
I have a simple foo.html that looks like this (residing in site\src\main\webapp\WEB-INF\templates\myfolder\foo.html)
[begin]
<h1>Hi there!</h1>
<div th:if="${mystuff != null}">
My stuff:<br/>
<h2 th:text="${mystuff.data1}">mystuff data1 default value</h2>
<h2 th:text="${mystuff.data2}">mystuff data2 default value</h2>
<h2 th:text="${mystuff.data3}">mystuff data3 default value</h2>
</div>
<h1>Testing form</h1>
<form action="/myform/datapost" method="POST">
Text1 <input type="text" name="data1" /><br/>
Text2 <input type="text" name="data2" /><br/>
num3 <input type="text" name="data3" /><br/>
<input type="submit" value="submit"/>
</form>
[end]
I added the following in applicationContext-security.xml, so I am allowing things with /myform pattern. (otherwise I get an error on submit)
<sec:http pattern="/myform/**" security="none" />
My controller method looks like this, and I am able to see the data that I put into the form in that LOG line.
The MyData class is an extremely simple POJO.
@RequestMapping(value="/myform/datapost", method = RequestMethod.POST)
public ModelAndView doSomething5(@ModelAttribute("MyData")MyData data) {
LOG.info("Here is data: "+data.getData1()+","+data.getData2()+" "+data.getData3());
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("myfolder/foo");
modelAndView.addObject("mystuff", data);
return new ModelAndView("myfolder/foo");
}
My little goal is to re-display the foo.html page with the data I entered but I am getting the following...
HTTP ERROR 500
Problem accessing /myform/datapost. Reason:
Exception evaluating SpringEL expression: "customer.anonymous" (layout/partials/header:5)
Caused by:
org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "customer.anonymous" (layout/partials/header:5)
and that looks like it is because this page does not know what customer it is dealing with.
How can I get around that?
It probably has to do with configuring the authentication-manager blAuthenticationManager section?
So the general question is how can one add additional mvc to the broadleaf demo that works with the rest of site?