Front with thymeleaf

Hi, if i can’t use polymer on the front there is possible way to create views with thymeleaf pages integrated with CUBA ?


You can use the traditional Spring MVC approach for front-end using our portal module. It supports both Thymeleaf and FreeMarker templates with standard Spring MVC controllers.

Create a portal module using Studio - Manage modules.

1 Like

Ok, nice. I have one last question. If I have an entity created in CUBA Studio and this entity has attributes what should I do to show these on the thymeleaf template? There is any example or docs?

Take a look at the generated portal files: web/WEB-INF/templates/index.html:

    <ul th:each="user: ${users}">
        <li th:text="${user.login}"></li>

It prints list of Users returned from PortalController:

public class PortalController {

    protected DataService dataService;

    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String index(Model model) {
        if (PortalSessionProvider.getUserSession().isAuthenticated()) {
            LoadContext l = new LoadContext(User.class);
            l.setQueryString("select u from sec$User u");
            model.addAttribute("users", dataService.loadList(l));
        return "index";

Yes but when I create custom controller like this, it doesn’t work and redirect me to login page. I removed “if” and still doesn’t work. I don’t want any user account, just portal website available to all anynomous users.

Check portal-security-spring.xml config, all the Spring Security settings including anonymous pages are there.