neutrino36
(neutrino neutrino)
August 21, 2019, 11:00am
#1
Hi,
Is there any possibility when I open the User Editor screen to appear the name of the user in textField name?
Let say I have user login name: John
<layout expand="scrollBox" spacing="true">
<scrollBox id="scrollBox" spacing="true">
<form id="form" dataContainer="userDc">
<column width="250px">
<textField id="nameField" property="name"/>
gorelov
(Gleb Gorelov)
August 21, 2019, 12:52pm
#2
Hi,
You can inject the UserSession
bean, obtain the current user and set the user name value to the TextField.
Gleb
neutrino36
(neutrino neutrino)
August 21, 2019, 1:21pm
#3
So easy. Thank you!
Meantime I created a Service in order to get the user list:
TypedQuery<User> query = em.createQuery("select u.login from sec$User u", User.class);
List<User> users = query.getResultList();
Is there any possibility to extract current user from the above list?
gorelov
(Gleb Gorelov)
August 22, 2019, 7:16am
#4
Sure
TypedQuery<User> query = em.createQuery("select u from sec$User u where u.id <> ?1", User.class);
query.setParameter(1, currentUSer.getId());
List<User> users = query.getResultList();
1 Like
neutrino36
(neutrino neutrino)
August 22, 2019, 12:48pm
#5
Thank you, but currentUser stays in red.
Is there any possibility to inject it somehow?
gorelov
(Gleb Gorelov)
August 22, 2019, 12:55pm
#6
currentUser
is the name of the variable that contains the current user, e.g. obtained using the UserSession
bean.
neutrino36
(neutrino neutrino)
August 22, 2019, 12:59pm
#7
I think is:
userSessionSource.getUserSession().getId())
and why <>?1 and not =?1
gorelov
(Gleb Gorelov)
August 22, 2019, 1:24pm
#8
neutrino:
and why <>?1 and not =?1
Yeah, my mistake. Anyway it seems redundant to execute a query to obtain the current user if at the moment of execution you’ll have the current user.
1 Like