Class PageRenderer
java.lang.Object
com.irurueta.authserver.authorization.api.web.pages.PageRenderer
Renders a server-rendered page (a Thymeleaf template) to the
text/html answer of an operation generated from
the pages contract. The view is resolved through the application's view resolvers, in their order, with the locale
of the request, and rendered against the current request into a wrapper that captures what it writes, so everything
a template relies on keeps working: the CSRF hidden field that th:action adds, @{...} links and the
messages. Every page gets the branding as the "branding" model attribute.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BrandingProviderSupplies the branding of the pages.private final jakarta.servlet.http.HttpServletRequestThe current request, injected as a thread-bound proxy.private final jakarta.servlet.http.HttpServletResponseThe current response, injected as a thread-bound proxy.(package private) static final org.springframework.http.MediaTypeMedia type of the rendered pages.private final List<org.springframework.web.servlet.ViewResolver> View resolvers of the application, in their order. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<String> Renders a page.private org.springframework.web.servlet.ViewResolves a view through the view resolvers, in their order.private static org.springframework.web.servlet.ViewresolveWith(org.springframework.web.servlet.ViewResolver resolver, String viewName, Locale locale) Resolves a view with one resolver.
-
Field Details
-
TEXT_HTML_UTF8
static final org.springframework.http.MediaType TEXT_HTML_UTF8Media type of the rendered pages. -
viewResolvers
View resolvers of the application, in their order. -
brandingProvider
Supplies the branding of the pages. -
request
private final jakarta.servlet.http.HttpServletRequest requestThe current request, injected as a thread-bound proxy. -
response
private final jakarta.servlet.http.HttpServletResponse responseThe current response, injected as a thread-bound proxy.
-
-
Constructor Details
-
PageRenderer
public PageRenderer()
-
-
Method Details
-
render
Renders a page.- Parameters:
viewName- name of the view (the Thymeleaf template).model- model attributes of the page; the branding is added to them.- Returns:
- a
200with the page astext/html. - Throws:
IllegalStateException- if no view resolver knows the view, or the view cannot be rendered.
-
resolve
Resolves a view through the view resolvers, in their order.- Parameters:
viewName- name of the view.locale- locale of the request.- Returns:
- the view of the first resolver that knows it.
- Throws:
IllegalStateException- if no view resolver knows the view.
-
resolveWith
private static org.springframework.web.servlet.View resolveWith(org.springframework.web.servlet.ViewResolver resolver, String viewName, Locale locale) Resolves a view with one resolver.- Parameters:
resolver- the view resolver.viewName- name of the view.locale- locale of the request.- Returns:
- the view, or
nullwhen the resolver does not know it. - Throws:
IllegalStateException- if the resolver fails.
-