Save changes in the matrix

Well, the matrix displays the data stored in database, but it would be better to define access rights and save them.

Saving all the rows into the groupaccess table will rely on the SqlTransaction object. It allows us to prepare a series of SQL statements and execute them on the server in a transaction.

Our save() method will delete all the rows in the groupaccess table, and do as many inserts as there are checkboxes checked.

I added, near the SqlQuery objects, a SqlTransaction, like this:


			<core:SqlTransaction id="saveTransaction" 

The save method looks like this :

			 * Saves the matrix into the database
			public function save():void
				//clear previous commands prepared
				//Delete all rows
				saveTransaction.addCommand("Delete from groupaccess");
				//Then, insert one row per checked checkbox
				for each(var chk:CheckBox in this.checkboxList)
					saveTransaction.addCommand("insert into groupaccess (gid, mid) values (?, ?)",
				//This will send all the statements to the server, 
				//who will execute them in a transaction:


I adapted a bit the rest of the code and added some utility methods. You can check the working program there.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <p> <pre>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
This question is for testing whether you are a human visitor and to prevent automated spam submissions.