Author: nbelaevski
Date: 2008-08-21 15:09:08 -0400 (Thu, 21 Aug 2008)
New Revision: 10171
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/suggestionBox/examples/custom.xhtml
Log:
Started implementation of JS objects in suggestion demo
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/suggestionBox/examples/custom.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/suggestionBox/examples/custom.xhtml 2008-08-21
19:08:43 UTC (rev 10170)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/suggestionBox/examples/custom.xhtml 2008-08-21
19:09:08 UTC (rev 10171)
@@ -5,6 +5,23 @@
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
+ <div id="myDiv"></div>
+
+ <script type="text/javascript">
+ function processObjectsChange(suggestionBox) {
+ var items = suggestionBox.getSelectedItems();
+ if (items) {
+ var html = items.collect(function(i) {
+ return i.name;
+ }).join('<br />');
+
+ myDiv.innerHTML = html;
+ } else {
+ myDiv.innerHTML = "";
+ }
+ }
+ </script>
+
<h:form id="suggestionbox_form">
<p>
@@ -22,7 +39,9 @@
height="#{suggestionBox.height}"
shadowDepth="#{suggestionBox.shadowDepth}"
cellpadding="#{suggestionBox.cellpadding}"
- nothingLabel="No capitals found" columnClasses="center">
+ nothingLabel="No capitals found" columnClasses="center"
+ usingSuggestObjects="true"
+ onobjectchange="processObjectsChange(suggestion)">
<h:column>
<h:graphicImage value="#{result.stateFlag}" />
</h:column>