Created
October 13, 2016 16:02
-
-
Save odrotbohm/918da1a29d686d49a617973201311233 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<div th:text="${viewModel.yourDescriptiveMethod()}">placeholder</div> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequiredArgsConstructor | |
public class ViewModel { | |
private final @NonNull YourService service; | |
public boolean yourDescriptiveMethod() { | |
return service.someMethod() | |
} | |
// … more methods | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Controller | |
@RequiredArgsConstructor | |
class YourController { | |
private final YourService service; | |
// Available in all views rendered by that controller | |
@ModelAttribute | |
public ViewModel viewModel() { | |
return new ViewModel(service); | |
} | |
// … request mappings | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment