How to pass values from Java to the FTL-based pages?
525 views
Skip to first unread message
DP
unread,
Dec 23, 2022, 9:52:55 AM12/23/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Keycloak User
Hello!
Imagine I want to display some values generated in my Java classes to the pages based on Freemarker (FTL) templates.
That is, let's say I have the following code:
final Response response = smsCodeForm .setAttribute("myText", "12") .createForm("some-form.ftl"); context.challenge(response);
I want the value of myText ("12") to appear in the form rendered based on the some-form.ftl file.
I tried putting
<p>${msg('myText')}</p>
but it produces an empty text.
<p>${myText}</p> results in an error (property not defined).
What do I need to do
a) in my Java code and b) the FTL template
in order to display values generated in Java in that form?
Thanks in advance
Dmitrii Pisarenko
Łukasz Dywicki
unread,
Jan 3, 2023, 12:51:55 PM1/3/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to keyclo...@googlegroups.com
Hello Dmitrii,
The ${msg('myText')} macro is used for i18n lookups, hence it will not
work unless you provision proper translation resources.
Other part of your code, assuming that smsCodeForm is created by
authenticationFlowContext.form() call looks good. I've used this
approach with Keycloak 15, it should work up to 18. Quarkus distribution
which is, as far I know, default since 18th release should not amend that.