[jboss-cvs] jboss-seam/examples/seambay/view ...
Shane Bryzak
sbryzak at redhat.com
Wed Jul 4 01:40:11 EDT 2007
User: sbryzak2
Date: 07/07/04 01:40:11
Modified: examples/seambay/view sell.xhtml sell2.xhtml
Added: examples/seambay/view sell2.js
Log:
load the categories with remoting
Revision Changes Path
1.4 +0 -1 jboss-seam/examples/seambay/view/sell.xhtml
(In the diff below, changes in quantity of whitespace are not shown.)
Index: sell.xhtml
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seambay/view/sell.xhtml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- sell.xhtml 4 Jul 2007 02:09:20 -0000 1.3
+++ sell.xhtml 4 Jul 2007 05:40:11 -0000 1.4
@@ -36,7 +36,6 @@
<h:inputText id="title" value="#{auctionAction.auction.title}" required="true" class="itemDescription"/>
<div class="validationError"><h:message for="title"/></div>
</div>
-
</s:validateAll>
<div class="navBar">
1.3 +14 -5 jboss-seam/examples/seambay/view/sell2.xhtml
(In the diff below, changes in quantity of whitespace are not shown.)
Index: sell2.xhtml
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seambay/view/sell2.xhtml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- sell2.xhtml 4 Jul 2007 02:09:20 -0000 1.2
+++ sell2.xhtml 4 Jul 2007 05:40:11 -0000 1.3
@@ -25,18 +25,20 @@
</div>
<div class="sellSubHeader">
- Find the category that most closely matches the item you're selling
+ Select the category that most closely matches the item you're selling
</div>
<h:form>
<div class="category">
- <div class="categoryList">
- Loading categories...
+ <div>
+ <select id="rootCategory" class="categoryList" size="8" onchange="selectCategory(this)">
+ <option>Loading categories...</option>
+ </select>
</div>
</div>
- <!--h:inputHidden id="categoryId" value="#{auctionAction.categoryId}" /-->
+ <h:inputHidden id="categoryId" value="#{auctionAction.categoryId}" />
<div class="navBar">
<div class="navBarLeft">
@@ -61,5 +63,12 @@
</div>
<script type="text/javascript" src="sell2.js"></script>
+
+ <s:remote include="categoryAction"/>
+
+ <script type="text/javascript">
+ // Make a remoting call to load the categories
+ Seam.Remoting.eval(CATEGORY_EXPR, loadCategories);
+ </script>
</body>
</html>
1.1 date: 2007/07/04 05:40:11; author: sbryzak2; state: Exp;jboss-seam/examples/seambay/view/sell2.js
Index: sell2.js
===================================================================
// We put this constant here because facelets would otherwise interpret it as an EL expression
var CATEGORY_EXPR = "#{allCategories}";
var categories;
function loadCategories(result)
{
categories = result;
var catList = document.getElementById("rootCategory");
catList.options.length = 0;
for (var i = 0; i < categories.length; i++)
{
var cat = categories[i];
if (cat.getParent() == null)
{
var option = new Option(cat.getName() + (isParent(cat) ? " >" : ""), cat.getCategoryId());
var idx = catList.options.length;
catList.options[idx] = option;
}
}
}
function isParent(category)
{
if (category.isParent)
return category.isParent;
for (var i = 0; i < categories.length; i++)
{
if (categories[i].getParent() == category)
{
category.isParent = true;
return true;
}
}
category.isParent = false;
return false;
}
function getSelectedOption(ctl)
{
for (var i = 0; i < ctl.options.length; i++)
{
if (ctl.options[i].selected)
return ctl.options[i];
}
return null;
}
function selectCategory(ctl)
{
var opt = getSelectedOption(ctl);
document.getElementById("categoryId").value = opt.value;
}
More information about the jboss-cvs-commits
mailing list