Author: sergeyhalipov
Date: 2007-07-25 13:37:52 -0400 (Wed, 25 Jul 2007)
New Revision: 1848
Modified:
trunk/ui/suggestionbox/src/main/config/component/suggestionbox.xml
trunk/ui/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/templates/table.jspx
Log:
http://jira.jboss.com/jira/browse/RF-450
Modified: trunk/ui/suggestionbox/src/main/config/component/suggestionbox.xml
===================================================================
--- trunk/ui/suggestionbox/src/main/config/component/suggestionbox.xml 2007-07-25 14:31:16
UTC (rev 1847)
+++ trunk/ui/suggestionbox/src/main/config/component/suggestionbox.xml 2007-07-25 17:37:52
UTC (rev 1848)
@@ -112,7 +112,8 @@
<classname>java.lang.String</classname>
<description>
A comma-delimited list of CSS style classes that is applied to popup
table rows. A space separated list of classes may also be specified for any individual
row. The styles are applied, in turn, to each row in the table. For example, if the list
has two elements, the first style class in the list is applied to the first row, the
second to the second row, the first to the third row, the second to the fourth row, etc.
In other words, we keep iterating through the list until we reach the end, and then we
start at the beginning again
- </description>
+ </description>
+ <defaultvalue>""</defaultvalue>
</property>
<property>
@@ -315,6 +316,14 @@
<name>rows</name>
<classname>java.lang.String</classname>
<description>rows</description>
+ </property>
+ <property>
+ <name>nothingLabel</name>
+ <classname>java.lang.String</classname>
+ <description>
+ "nothingLabel" is inserted to popup list if the autocomplete
returns empty list.
+ It isn't selectable and list is closed as always after click on it and nothing is
put to input.
+ </description>
</property>
</component>
</components>
Modified:
trunk/ui/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java
===================================================================
---
trunk/ui/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java 2007-07-25
14:31:16 UTC (rev 1847)
+++
trunk/ui/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java 2007-07-25
17:37:52 UTC (rev 1848)
@@ -265,6 +265,10 @@
public abstract int getZindex();
public abstract void setZindex(int zindex);
+
+ public abstract String getNothingLabel();
+
+ public abstract void setNothingLabel(String nothingLabel);
/* (non-Javadoc)
* @see javax.faces.component.UIData#broadcast(javax.faces.event.FacesEvent)
Modified:
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
===================================================================
---
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-07-25
14:31:16 UTC (rev 1847)
+++
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-07-25
17:37:52 UTC (rev 1848)
@@ -744,4 +744,29 @@
return style.toString();
}
+
+ public void insertNothingLabel(final FacesContext context,
+ final UIComponent component) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ UISuggestionBox suggestionBox = (UISuggestionBox)component;
+ final String startHtml =
+ "<tr id=\"" + suggestionBox.getClientId(context) +
"NothingLabel\" class=\"dr-sb-int rich-sb-int " +
suggestionBox.getRowClasses() +
+ "\" style=\"display: none;\">" +
+ "<td nowrap=\"nowrap\" class=\"dr-sb-cell-padding
rich-sb-cell-padding\" style=\"" + this.cellPadding(context, component) +
"\">";
+ final String endHtml = "</td></tr>";
+
+ UIComponent nothingLabelFacet = component.getFacet("nothingLabel");
+ if(null != nothingLabelFacet && nothingLabelFacet.isRendered()) {
+ writer.write(startHtml);
+ renderChild(context, nothingLabelFacet);
+ writer.write(endHtml);
+ }
+ else if (null != suggestionBox.getNothingLabel() &&
+ !"".equals(suggestionBox.getNothingLabel())) {
+ writer.write(startHtml);
+ writer.write(suggestionBox.getNothingLabel());
+ writer.write(endHtml);
+ }
+
+ }
}
Modified:
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
===================================================================
---
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2007-07-25
14:31:16 UTC (rev 1847)
+++
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2007-07-25
17:37:52 UTC (rev 1848)
@@ -95,6 +95,8 @@
if (options.popupClass)
Element.addClassName(document.getElementsByClassName("dr-sb-ext-decor-3",
this.update)[0], options.popupClass);
+
+ this.onNothingLabelClick = this.hideNLabel.bindAsEventListener(this);
},
onBoxKeyPress: function(event) {
@@ -162,6 +164,7 @@
if (Element.getStyle(this.update, 'display')
== 'none') this.options.onShow(this.element, this.update,
this.options);
this.disableSubmit();
+
},
hide: function() {
@@ -179,6 +182,16 @@
this.hasFocus = false;
this.active = false;
},
+
+ hideNLabel: function(event) {
+ var TRs = document.getElementsByClassName("dr-sb-int", this.update);
+ var nothingLabel = TRs[TRs.length - 1];
+ if (/NothingLabel/.test(nothingLabel.id)) {
+ Element.hide(nothingLabel);
+ Event.stopObserving(nothingLabel, "click", this.onNothingLabelClick);
+ this.hide();
+ }
+ },
startIndicator: function() {
if (this.options.indicator) Element.show(this.options.indicator);
@@ -469,6 +482,7 @@
}
}
}
+
this.prevIndex = this.index;
if (this.hasFocus) {
this.show();
@@ -600,6 +614,16 @@
this.prevIndex = -1;
this.render();
}
+
+ var TRs = document.getElementsByClassName("dr-sb-int", this.update);
+ var nothingLabel = TRs[TRs.length - 1];
+ if (/NothingLabel/.test(nothingLabel.id)) {
+ if (this.entryCount < 1) {
+ Element.show(nothingLabel);
+ Event.observe(nothingLabel, "click", this.onNothingLabelClick);
+ this.show();
+ }
+ }
},
addObservers: function(element) {
Modified:
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/templates/table.jspx
===================================================================
---
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/templates/table.jspx 2007-07-25
14:31:16 UTC (rev 1847)
+++
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/templates/table.jspx 2007-07-25
17:37:52 UTC (rev 1848)
@@ -60,7 +60,10 @@
<u:insertChild/></td>
</u:insertChildren>
</tr>
- </u:insertChildren>
+ </u:insertChildren>
+
+ <f:call name="insertNothingLabel" />
+
</tbody>
</table>
</f:template>