Android Example [B4XPages] jRDC2 + MySql CRUD + Login

Hi all:


I'm starting (at last) to work with B4XPages, so I've started to adapt the B4XPages + B4XDrawer example.
I think I’ve seen more examples with php + mysql, but no projects with Jrdc2.

Maybe the dummy data and the UI are too basic, but you can get some ideas.

What do we need?
- A mysql database. You can use XAMPP, LARAGON or any other project to set it up. See attached a sql file to import in your database. The database name will be B4X.
- B4J to create the jRDC2 server
- B4A 9.9+ to support B4XPages. As always, you should update B4A to the last versión (10.5 when this post have been write)

Steps:
- Import the sql file to you database. You can use phpMyAdmin, HeidiSQL, etc…
- Configure jRDC2 server. Open the attached B4J file and change your user and password in the config file.
- Open B4A, and change the rdcLink const in the jRDC2 class to match the IP of the computer where you’re running the jRDC2 server (B4J)
B4X:
Sub Class_Globals
    'CHANGE THE IP TO MATCH YOUR B4J SERVER
    Private const rdcLink As String = "http://192.168.1.131:8090/rdc"
End Sub
- To add, edit... we will use B4XPreferencesDialog. You should use the Form Builder to build the forms. It's important that the key values match with database's fields names, due to we will construct a map from the rs returned from the db, and it will be easier to work this way, passing this map to the B4XPreferences dialog.

I've commented the code the best I can.
If you think there are some mistakes or you know some way to improve the example, you're welcome to do it.
I've tried to make the B4J project too, but I've never used B4J and I get too many errors. If someone want to do it, we will learn something more. (or B4i)
EDIT: Updated project and now it works with B4J and B4A (maybe in B4i)

The password for all the users is: 1234 (stored as md5)

sql.Login = SELECT * FROM B4X.users WHERE `username` = ? AND `password` = md5(?)
sql.getEvents = SELECT * FROM B4X.events WHERE `month` = ? AND `id_user` = ?
sql.updateEvents = UPDATE B4X.events SET `month`=?,`event_type`=?,`description`=? WHERE `id` = ?
sql.deleteEvents = DELETE FROM B4X.events WHERE `id` = ?
sql.addEvents = INSERT INTO B4X.events(`id_user`, `month`, `event_type`, `description`, `value`) VALUES (?, ?, ?, ?, ?)
 

Attachments

  • jRDC_B4J.zip
    5.4 KB · Views: 1,283
  • sql.zip
    1.5 KB · Views: 1,295
  • Project.zip
    207.2 KB · Views: 1,516
Last edited:

Timm

Member
Hello, thank you for your great job. Please can you implement clv with jrdc(instead of static listview) to populate the drawer item. I want such idea. Thanks
 

Timm

Member
Can you please give code example of such b4xdrawer population using clv 'cos I have been trying the same way as mr Josejad sub populatedrawer(value) but not working in the drawer. Thanks
 
Top