setError() - how to use it with locale?

58 views
Skip to first unread message

Francis Augusto Medeiros

unread,
Sep 26, 2023, 9:41:06 AM9/26/23
to Keycloak Dev
Hi,

I was wondering, we have the “setError()” to use when creating a form. Is there a way to use predefined messages of the theme instead, so that we could have errors in other languages?

Best,

Francis

Stan Silvert

unread,
Sep 26, 2023, 1:25:15 PM9/26/23
to Francis Augusto Medeiros, Keycloak Dev
Here is an example where we use setError() to localize a message in the admin console.  Is this what you are looking for?

--
You received this message because you are subscribed to the Google Groups "Keycloak Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keycloak-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/keycloak-dev/8EDB1F92-0ED5-4B50-BAA4-CB5CBD0F8242%40gmail.com.

Francis Augusto Medeiros

unread,
Sep 26, 2023, 2:20:52 PM9/26/23
to Stan Silvert, Keycloak Dev

Stan Silvert

unread,
Sep 26, 2023, 2:56:28 PM9/26/23
to Francis Augusto Medeiros, Keycloak Dev
We are talking about the admin console, right?  Are you doing this as part of a custom authenticator?
bd31cf00-70f4-11e9-9fb2-4f241568e586.png

Francis Augusto Medeiros

unread,
Sep 26, 2023, 3:06:10 PM9/26/23
to Stan Silvert, Keycloak Dev
It’s a custom authenticator - I modified the SecretQuestionAuthenticator so that I could do my own, and it works nice. I just would like to customize it better with errors in different languages.

Best,
Francis 

<bd31cf00-70f4-11e9-9fb2-4f241568e586.png><bd31cf00-70f4-11e9-9fb2-4f241568e586.png>

Stan Silvert

unread,
Sep 26, 2023, 3:34:28 PM9/26/23
to Francis Augusto Medeiros, Keycloak Dev
OK.  I'm not sure if this is possible with the current code because in that case everything is dynamically rendered.  I suggest that you submit an enhancement request against the admin console.

Francis Augusto Medeiros

unread,
Sep 26, 2023, 3:41:08 PM9/26/23
to Stan Silvert, Keycloak Dev
Thanks Stan!

What do you mean by «enhancement request against the admin console»? 

Best,

Francis

Francis Augusto Medeiros

unread,
Sep 26, 2023, 3:47:52 PM9/26/23
to Stan Silvert, Keycloak Dev
My main idea is:
- add some <#if> statements to the code, checking for a variable;
- set that variable on the java code

This way, I could show snippets of text and then display error messages that are configured on the theme.properties, but it’d be better to use the setError function.

On Sep 26, 2023, at 21:34, Stan Silvert <ssil...@redhat.com> wrote:

Stan Silvert

unread,
Sep 26, 2023, 4:29:37 PM9/26/23
to Francis Augusto Medeiros, Keycloak Dev
Reply all
Reply to author
Forward
0 new messages