|
From: <sim...@us...> - 2007-05-22 23:09:08
|
Revision: 310
http://svn.sourceforge.net/zkforge/?rev=310&view=rev
Author: simon_massey
Date: 2007-05-22 16:09:07 -0700 (Tue, 22 May 2007)
Log Message:
-----------
updated sample code comments
Modified Paths:
--------------
trunk/foodToGo/src/main/webapp/zul/index.zul
trunk/foodToGo/src/main/webapp/zul/load-dummy-data.zs
trunk/foodToGo/src/main/webapp/zul/restaurant-macro.zs
trunk/foodToGo/src/main/webapp/zul/restaurant.zul
Modified: trunk/foodToGo/src/main/webapp/zul/index.zul
===================================================================
--- trunk/foodToGo/src/main/webapp/zul/index.zul 2007-05-22 22:49:29 UTC (rev 309)
+++ trunk/foodToGo/src/main/webapp/zul/index.zul 2007-05-22 23:09:07 UTC (rev 310)
@@ -42,15 +42,15 @@
<listcell/>
</listitem>
<attribute name="onSelect">
- <!-- load the full restaurant with the listbox it's menu items from the database -->
+ <!-- load the full restaurant with it's menu items from the database -->
<![CDATA[
- // selectedRestaurant.id calls getId() on this sparcely loaded Restaurant POJO
+ // selectedRestaurant.id calls getId() on the sparcely loaded Restaurant POJO bound to the selected item
restaurant = restaurantFacadeSpringBean.loadRestaurant(""+selectedRestaurant.id).getRestaurant();
- // cache the loaded POJO on an attribute of the page for use later
+ // cache the loaded POJO on an attribute of the page for later use
spaceScope.put("restaurant", restaurant);
- // get the list of menu item pojos from our fully loaded restaurant POJO
+ // get the list of menu item pojos from our fully loaded restaurant pojo
rebuildMenuGrid(restaurant);
]]>
</attribute>
@@ -75,7 +75,7 @@
<!--
Databind the restaurant pojo loaded from the database to the <restaurant/> macro component.
We bind the macro attribute "name" to "restaurant.name" and "type" to "restaurant.type"
- see restaurant-macro.zs for details of how this are rendered
+ see restaurant-macro.zs for details of how these are rendered
-->
<a:bind
name="restaurant.name;save-when:self.onNameChange;access:both"
@@ -86,24 +86,30 @@
<caption label="Menu Items" />
<grid>
<zscript>
- rebuildMenuGrid(restaurant){
- // clear the current menu item grid rows
- menuItemRows.children.clear();
-
- menuItems = restaurant.menuItems;
-
- index = 0;
-
- // create the new menu item grid elements. this is sort of like the innerHTML DOM trick
- for( Iterator i = menuItems.iterator(); i.hasNext(); ){
- menuItem = i.next();
- spaceScope.put("index", index);
- spaceScope.put("name", menuItem.name);
- spaceScope.put("price", menuItem.price);
- Executions.createComponents("menu-item.zul", menuItemRows, spaceScope);
- index++;
- }
- }
+ <!--
+ This function will programmatically re-render each menu item
+ applying menu-item.zul to each menu item
+ -->
+ <![CDATA[
+ rebuildMenuGrid(restaurant){
+ // clear the current menu item grid rows
+ menuItemRows.children.clear();
+
+ // get the menu item pojos
+ menuItems = restaurant.menuItems;
+
+ // create the new menu item grid elements. this is sort of like the innerHTML DOM trick
+ index = 0;
+ for( Iterator i = menuItems.iterator(); i.hasNext(); ){
+ menuItem = i.next();
+ spaceScope.put("index", index); // the index of the <row> within <rows>
+ spaceScope.put("name", menuItem.name); // data from our pojo
+ spaceScope.put("price", menuItem.price); // data from our pojo
+ Executions.createComponents("menu-item.zul", menuItemRows, spaceScope);
+ index++;
+ }
+ }
+ ]]>
</zscript>
<rows id="menuItemRows"/>
</grid>
Modified: trunk/foodToGo/src/main/webapp/zul/load-dummy-data.zs
===================================================================
--- trunk/foodToGo/src/main/webapp/zul/load-dummy-data.zs 2007-05-22 22:49:29 UTC (rev 309)
+++ trunk/foodToGo/src/main/webapp/zul/load-dummy-data.zs 2007-05-22 23:09:07 UTC (rev 310)
@@ -16,6 +16,8 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+// this code just checks if the database is empty and if it is saves some dummy
+// data into it
if( 0 == restaurants.size() ) {
//If the database was empty create some sample data
menuList = new java.util.ArrayList();
Modified: trunk/foodToGo/src/main/webapp/zul/restaurant-macro.zs
===================================================================
--- trunk/foodToGo/src/main/webapp/zul/restaurant-macro.zs 2007-05-22 22:49:29 UTC (rev 309)
+++ trunk/foodToGo/src/main/webapp/zul/restaurant-macro.zs 2007-05-22 23:09:07 UTC (rev 310)
@@ -16,8 +16,12 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+
import org.zkoss.zk.ui.*;
import org.zkoss.zul.*;
+
+// we could have just compiled this as a Java file and put it on the classpath
+// but doing it in beanshell is quick and easy to prototpe with
public class RestaurantMacro extends HtmlMacroComponent {
/*
Modified: trunk/foodToGo/src/main/webapp/zul/restaurant.zul
===================================================================
--- trunk/foodToGo/src/main/webapp/zul/restaurant.zul 2007-05-22 22:49:29 UTC (rev 309)
+++ trunk/foodToGo/src/main/webapp/zul/restaurant.zul 2007-05-22 23:09:07 UTC (rev 310)
@@ -22,10 +22,10 @@
<label id="RestaurantNameLabel" value="Restaurant Name:" />
<textbox id="namebox">
<attribute name="onChange">
- <!-- delegate event to the Macro Component -->
- <![CDATA[
- Events.sendEvent(spaceOwner, new Event("onNameChange", spaceOwner));
- ]]>
+ <!-- delegate event to the Macro Component itself see restaurant-marco.zs -->
+ <![CDATA[
+ Events.sendEvent(spaceOwner, new Event("onNameChange", spaceOwner));
+ ]]>
</attribute>
</textbox>
</row>
@@ -33,7 +33,10 @@
<label id="RestaurantTypeLabel" value="Restaurant Type:" />
<listbox id="typeselect" mold="select" rows="1">
<attribute name="onSelect">
- Events.sendEvent(spaceOwner, new Event("onTypeChange", spaceOwner));
+ <!-- delegate event to the Macro Component itself see restaurant-marco.zs -->
+ <![CDATA[
+ Events.sendEvent(spaceOwner, new Event("onTypeChange", spaceOwner));
+ ]]>
</attribute>
<listitem
label="- - - Please Select - - -" value="" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|