B4J Question [SOLVED]Login with PreferencesDialog

StarinschiAndrei

Active Member
Licensed User
Longtime User
Hi everyone,
Can anybody advice me how can i solve the following situation ? I would like to use PreferencesDialog for user login , if the username and password are incorrect go back and wait until the data are are correct.

login:
Sub AppStart (Form1 As Form, Args() As String)
    m_login.Initialize
    MainForm = Form1
    jRDC2Utils.Intitialize("http://localhost:17178/rdc")
    'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    MainForm.RootPane.LoadLayout("1")
    MainForm.Show
    MenuBar.Visible=False
    prefdialog.Initialize(MainForm.RootPane, "USER LOGIN", 400dip, 200dip)
    prefdialog.LoadFromJson(File.ReadString(File.DirAssets,"logIn.json"))
    '*****
    Wait For (prefdialog.ShowDialog(m_login, "OK", "CANCEL")) Complete (Result As Int)
    If Result=xui.DialogResponse_Positive Then
        Dim cmd As DBCommand=jRDC2Utils.CreateCommand("get_user_info",Array As String(m_login.Get("user"),m_login.Get("pass")))
        Wait For(jRDC2Utils.ExecuteQuery(cmd)) complete(res As DBResult)
        If res.Rows.Size=1 Then
            MenuBar.Visible=True
        Else
            Return    ' RETURN TO *****
        End If
    Else
        ExitApplication
    End If
 
Last edited:
Using SetEventsListener

Sub AppStart (Form1 As Form, Args() As String)
m_login.Initialize
MainForm = Form1
jRDC2Utils.Intitialize("http://localhost:17178/rdc")
'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.RootPane.LoadLayout("1")
MainForm.Show
MenuBar.Visible=False
prefdialog.Initialize(MainForm.RootPane, "USER LOGIN", 400dip, 200dip)
prefdialog.LoadFromJson(File.ReadString(File.DirAssets,"logIn.json"))
'*****
prefdialog.SetEventsListener(me,"prefitem")
Wait For (prefdialog.ShowDialog(m_login, "OK", "CANCEL")) Complete (Result As Int)
If Result=xui.DialogResponse_Positive Then
MenuBar.Visible=True
Else
ExitApplication
End If

sub prefitem_IsValid(m_login as map) as Boolean
Dim cmd As DBCommand=jRDC2Utils.CreateCommand("get_user_info",Array As String(m_login.Get("user"),m_login.Get("pass")))
Wait For(jRDC2Utils.ExecuteQuery(cmd)) complete(res As DBResult)
If res.Rows.Size=1 Then
return True
Else
ScrollToItemWithError("User")
Return false
End If
end sub
 
Upvote 0
Top