[seam-commits] Seam SVN: r11923 - modules/remoting/trunk/examples/model/src/main/webapp.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Thu Jan 7 02:39:41 EST 2010
Author: shane.bryzak at jboss.com
Date: 2010-01-07 02:39:41 -0500 (Thu, 07 Jan 2010)
New Revision: 11923
Modified:
modules/remoting/trunk/examples/model/src/main/webapp/model.html
Log:
added address add/remove functions
Modified: modules/remoting/trunk/examples/model/src/main/webapp/model.html
===================================================================
--- modules/remoting/trunk/examples/model/src/main/webapp/model.html 2010-01-07 07:39:07 UTC (rev 11922)
+++ modules/remoting/trunk/examples/model/src/main/webapp/model.html 2010-01-07 07:39:41 UTC (rev 11923)
@@ -10,7 +10,7 @@
<body onload="loadPeople()">
- <h1>Seam Remoting - Model Example</h1>
+ <h1>Seam Remoting - Model API Example</h1>
<script type="text/javascript" src="seam/resource/remoting/resource/remote.js"></script>
<script type="text/javascript" src="seam/resource/remoting/interface.js?personSearch"></script>
@@ -80,8 +80,6 @@
var addressDiv = document.getElementById("addresses");
clearElement(addressDiv);
addressDiv.appendChild(createLinkRow("Load addresses", "loadAddresses()"));
-
- document.getElementById("applyChanges").disabled = false;
}
function loadAddresses() {
@@ -105,8 +103,23 @@
} else {
addressDiv.appendChild(document.createTextNode("No addresses found"));
}
+
+ addressDiv.appendChild(createLinkRow("Create new address", "createAddress()"));
}
+ function createAddress() {
+ var address = Seam.createBean("org.jboss.seam.remoting.examples.model.Address");
+ address.person = model.getValue("person");
+ address.streetNo = "";
+ address.streetName = "";
+ address.suburb = "";
+ address.postCode = "";
+ address.country = "";
+ address.person.addresses.push(address);
+ var addressesDiv = document.getElementById("addresses");
+ addressesDiv.insertBefore(createAddressEditor(address), addressesDiv.lastChild);
+ }
+
function createLabel(text) {
var lbl = document.createElement("label");
lbl.appendChild(document.createTextNode(text));
@@ -122,12 +135,11 @@
return input;
}
- function apply() {
- document.getElementById("applyChanges").disabled = true;
-
- // TODO apply person changes here
-
- model.applyUpdates();
+ function apply() {
+ var action = new Seam.Action()
+ .setBeanType("org.jboss.seam.remoting.examples.model.PersonAction")
+ .setMethod("savePerson");
+ model.applyUpdates(action);
}
function createDeleteAddressLink(address, div) {
@@ -211,7 +223,7 @@
</div>
<div class="personAction">
- <button id="applyChanges" onclick="apply()" disabled="true">Apply changes</button>
+ <button id="applyChanges" onclick="apply()">Apply changes</button>
</div>
<br class="clear"/>
More information about the seam-commits
mailing list