On Mon, Dec 5, 2022 at 3:01 PM Joachim Lindenberg <guacam...@lindenberg.one>
wrote:

> Hello Mike,
>
>
>
> I modified my code to show an addition filed using that exception, however
> the result is not exactly what I was looking for.
>
> With code like…
>
>
>
>    *static* *final* String *backupserver* = "backup-server-to-connect-to";
>
>     *private* *static* Field *BACKUPSERVER* = *null*;
>
>     *private* *static* CredentialsInfo *SERVER_USERNAME_PASSWORD* = *null*
> ;
>
> …
>
>       *if* (*BACKUPSERVER* == *null*) *BACKUPSERVER* = *new* EnumField(
> *backupserver*, *getBackupServerCollection*());
>
>       *if* (*SERVER_USERNAME_PASSWORD* == *null*)
> *SERVER_USERNAME_PASSWORD* =
>
>             *new* CredentialsInfo(Arrays.*asList*(
>
>                  *BACKUPSERVER*,
>
>                   CredentialsInfo.*USERNAME*,
>
>                   CredentialsInfo.*PASSWORD*
>
>               ));
>
>       *throw* *new* GuacamoleInsufficientCredentialsException ("server,
> user & password required", *SERVER_USERNAME_PASSWORD*);
>
>
>
> … I get a drop down with the content
> LOGIN.FIELD_OPTION_BACKUP_SERVER_TO_CONNECT_TO_BACKUP2_LINDENBERG_ONE in
> the UI.
>
> Looks like the client application takes my field name and values,
> concatenates them, and probably also tries to translate them, whereas I
> want to use the Values in EnumField as provided. How can I achieve that?
>

You cannot do this with EnumField. All of the standard field types included
with Guacamole that allow you to specify possible values will expect
translation strings for each of those possible values. You would have to
define your own custom field type if you cannot provide translation strings
for the possible values ahead of time.

Is there some other UI element more appropriate?
>
>
>
> Also while the exception provides an easy way to define fields, the
> Credentials type does not reflect that. I figured out I have to use
> something like
>
> credentials.getRequest().getParameter(*backupserver*))
>
> correct?
>

Yes, convenience functions are provided only for username and password. You
need to use the generic getParameter() for anything more specialized.

- Mike

Reply via email to