Reputation: 241
Below is for keycloak 21. I have the below java class with a method that returns some dynamic data as "customCss" :
public class FetchCss {
private static final String API_URL = "https://localhost:10191/mydata";
public String fetchCustomCss() {
RestTemplate restTemplate = new RestTemplate();
// Construct API URL with query parameters to fetch active entry and custom_styles
String apiUrl = API_URL + "?abcd=true";
// Make GET request to fetch data
ResponseEntity<List<StyleManagerDTO>> response = restTemplate.exchange(
apiUrl,
HttpMethod.GET,
null,
new ParameterizedTypeReference<List<StyleManagerDTO>>() {});
// Extract customCss from response body
List<StyleManagerDTO> styleManagerDTOList = response.getBody();
if (styleManagerDTOList != null && !styleManagerDTOList.isEmpty()) {
StyleManagerDTO styleManagerDTO = styleManagerDTOList.get(0);
String customCss = styleManagerDTO.getCustomCss();
System.out.println("customCss : " + customCss);
return customCss;
} else {
return null;
}
}
}
i am trying to inject that data in the below freemarker code that I have for keycloak. How do I do it ?
<#import "templateLogin.ftl" as layout>
<@layout.registrationLayout displayMessage=!messagesPerField.existsError('username','password') displayInfo=realm.password && realm.registrationAllowed && !registrationDisabled??; section>
<#assign customCss = customCss!>
<!-- Print the value of customCss for debugging purposes -->
<p>Custom CSS: ${customCss}</p>
<style type="text/css">
${customCss}
</style>
.......
<Rest of the code>
Upvotes: 0
Views: 49