|
From: <sim...@us...> - 2007-05-14 23:09:39
|
Revision: 293
http://svn.sourceforge.net/zkforge/?rev=293&view=rev
Author: simon_massey
Date: 2007-05-14 16:09:40 -0700 (Mon, 14 May 2007)
Log Message:
-----------
better input validation.
Modified Paths:
--------------
trunk/foodToGo/src/main/webapp/zul/add-menu-item.zul
trunk/foodToGo/src/main/webapp/zul/add-restaurant.zul
trunk/foodToGo/src/main/webapp/zul/index.zul
Modified: trunk/foodToGo/src/main/webapp/zul/add-menu-item.zul
===================================================================
--- trunk/foodToGo/src/main/webapp/zul/add-menu-item.zul 2007-05-14 21:53:46 UTC (rev 292)
+++ trunk/foodToGo/src/main/webapp/zul/add-menu-item.zul 2007-05-14 23:09:40 UTC (rev 293)
@@ -46,8 +46,10 @@
<label id="priceLabel" value="Price:"/><decimalbox id="price" format="#,##0.##" constraint="no zero, no empty"/></vbox>
<button label="Add">
<attribute name="onClick"><![CDATA[
+ // if they type in the name then click on the add then the validator
+ // for price does not fire so give a hint that the input field is
+ // not valid
if( !price.isValid() ) {
- // not sure why the no zero, no empty constraint is not working so set the label red....
priceLabel.style = "color: red";
} else {
priceLabel.style = "color: black";
Modified: trunk/foodToGo/src/main/webapp/zul/add-restaurant.zul
===================================================================
--- trunk/foodToGo/src/main/webapp/zul/add-restaurant.zul 2007-05-14 21:53:46 UTC (rev 292)
+++ trunk/foodToGo/src/main/webapp/zul/add-restaurant.zul 2007-05-14 23:09:40 UTC (rev 293)
@@ -22,18 +22,19 @@
<zscript>
<![CDATA[
doAdd(String name, String type){
- //alert(name+" "+type);
restaurant = new net.chrisrichardson.foodToGo.domain.Restaurant();
restaurant.name = name;
restaurant.type = type;
restaurantFacadeSpringBean.saveRestaurant(restaurant);
+ reload = Path.getComponent("//main-page/main-window/reload");
+ Events.postEvent(Events.ON_CLICK, reload, null);
}
]]>
</zscript>
<vbox>
- <label id="RestaurantNameLabel" value="Restaurant Name:" />
- <textbox id="name" value="" />
- <label id="RestaurantTypeLabel" value="Restaurant Type:" />
+ <label id="restaurantNameLabel" value="Restaurant Name:" />
+ <textbox id="name" value="" constraint="no empty"/>
+ <label id="restaurantTypeLabel" value="Restaurant Type:" />
<listbox id="typeselect" mold="select" rows="1">
<listitem label="--- Please Select ---" value="" />
<listitem label="Italian" value="Italian"></listitem>
@@ -43,7 +44,18 @@
<listitem label="Thai" value="Thai"></listitem>
</listbox>
</vbox>
- <button label="Add"
- onClick="doAdd(name.value,typeselect.selectedItem.value);win.detach()" />
+ <button label="Add">
+ <attribute name="onClick"><![CDATA[
+ if( name.isValid() && typeselect.selectedIndex > 0 ) {
+ doAdd(name.value, typeselect.selectedItem.value);
+ win.detach();
+ }
+ if (typeselect.selectedIndex < 1) {
+ restaurantTypeLabel.style = "color: red;";
+ } else {
+ restaurantTypeLabel.style = "color: black;";
+ }
+ ]]></attribute>
+ </button>
<button label="Cancel" onClick="win.detach()" />
</window>
\ No newline at end of file
Modified: trunk/foodToGo/src/main/webapp/zul/index.zul
===================================================================
--- trunk/foodToGo/src/main/webapp/zul/index.zul 2007-05-14 21:53:46 UTC (rev 292)
+++ trunk/foodToGo/src/main/webapp/zul/index.zul 2007-05-14 23:09:40 UTC (rev 293)
@@ -81,6 +81,7 @@
// force the included menu item frame to be rerendered. the timestamp means that
// we wont be given a cached version of the page
+ // TODO this is ugly and we should find a better way
now = (new java.util.Date()).getTime();
menuItemInclude.setSrc("./menu-items.zul?now="+now);
]]></attribute>
@@ -94,7 +95,7 @@
<button id="reload" label="Reload">
<attribute name="onClick"><![CDATA[
model = restaurantsListBox.model;
- model.removeAll(restaurants);
+ model.clear();
restaurants = restaurantFacadeSpringBean.listRestaurants().getRestaurants();
model.addAll(restaurants);
]]></attribute>
@@ -161,6 +162,7 @@
restaurant.name = selected.name;
restaurant.type = selected.type;
restaurantFacadeSpringBean.saveRestaurant(restaurant);
+ Events.sendEvent(reload,event);
}
]]></attribute>
</button>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|