Quantcast

How to return a fragment with "complex" parameter from @Controller?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to return a fragment with "complex" parameter from @Controller?

migueldeblas
This post was updated on .
This is my "code":

I have this template:

<div th:fragment="result(field)">  // field is a custom class passing in model.
<div th:each="fiield: ${entity.getAllFields()}"
     <div th:replace="result(field)">  // OK!
     </div>
</div>
It works perfectly.

I need to refresh the view via ajax(jquery load) with controller information. (filter/sorting/pagination).
I create this method controller but I need to add a no-String parameter to result fragment.

@Override
@RequestMapping(value = { "/{id}/{fieldName})
public String detailRefresh(@PathVariable long id, Model model, @PathVariable String fieldName) {
  FieldDescriptor field = Entity.getFieldByName(fieldName);  // FieldDescriptor is a custom class.
  model.addAttributes("whateverdates",....);
  return "/fragment :: result" + ¿?¿?¿?¿?; // I need to add the 'field' object as result parameter fragment.
}

How do I add a field object to fragment template?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to return a fragment with "complex" parameter from @Controller?

migueldeblas
I think it's impossible.
The solution, pass the field object in model with the same "field" name.
Loading...