Asking about setting currant date and time also getting the currant user in jmix

hello dev, My name is Ramadhan Ally, i m new in jmix platform, I was trying to see if i can setvalue in the textfield like when there is many session in the application and you what to get the user who is using the software and save his name. how you can do ???

also how you can set the currant time and date in the textfield. kindly I need you help

Hi Ramadhan,

See Authentication :: Jmix Documentation and the example below:

<textField id="usernameField"/>
<textField id="dateTimeField"/>
@Autowired
private CurrentAuthentication currentAuthentication;

@Autowired
private TimeSource timeSource;

@Autowired
private TextField<String> usernameField;

@Autowired
private TextField<String> dateTimeField;

@Subscribe
public void onBeforeShow(BeforeShowEvent event) {
    User user = (User) currentAuthentication.getUser();
    usernameField.setValue(user.getUsername());

    String dateTime = timeSource.now().format(DateTimeFormatter.ISO_DATE_TIME);
    dateTimeField.setValue(dateTime);
}