Author: pyaschenko
Date: 2010-11-18 03:34:56 -0500 (Thu, 18 Nov 2010)
New Revision: 20084
Modified:
trunk/examples/input-demo/src/main/webapp/examples/autocomplete.xhtml
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.ecss
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js
Log:
http://jira.jboss.com/jira/browse/RF-9672
Modified: trunk/examples/input-demo/src/main/webapp/examples/autocomplete.xhtml
===================================================================
--- trunk/examples/input-demo/src/main/webapp/examples/autocomplete.xhtml 2010-11-18
08:29:52 UTC (rev 20083)
+++ trunk/examples/input-demo/src/main/webapp/examples/autocomplete.xhtml 2010-11-18
08:34:56 UTC (rev 20084)
@@ -38,7 +38,7 @@
</script>
<input:autocomplete autofill="false" id="myAutocomplete"
clientFilterFunction="customFilterFunction"
mode="#{autoCompleteBean.mode}" minChars="2"
autocompleteMethod="#{autoCompleteBean.autocomplete}" var="country"
fetchValue="#{country.name}" showButton="true"
- value = "#{autoCompleteBean.value}"
+ value = "#{autoCompleteBean.value}" layout="list"
onchange="return onEvent.call(this, event);" onselectitem="return
onEvent.call(this, event);" onblur="return onEvent.call(this, event);"
onfocus="return onEvent.call(this, event);">
#{country.name} #{country.iso} #{country.domain}
<a4j:ajax event="change" render="output"/>
@@ -88,6 +88,29 @@
<a4j:log mode="inline"></a4j:log>
</div>
</h:form>
+ <h:form>
+ RF-9567:<br/><br/>
+ <a4j:outputPanel ajaxRendered="true"><h:messages
/></a4j:outputPanel>
+
+
+ <input:autocomplete mode="ajax" id="autocomplete"
autocompleteMethod="#{autoCompleteBean.autocomplete}"
value="#{autoCompleteBean.value}">
+ <f:validateRegex pattern="Alabama" />
+ </input:autocomplete>
+
+ <a4j:commandButton render="@form" execute="autocomplete" />
+ </h:form>
+ <h:form>
+ <input:autocomplete mode="cachedAjax" tokens=","
minChars="0"
+autofill="true" selectFirst="false" layout="table"
+autocompleteMethod="#{autoCompleteBean.autocomplete}" var="country"
fetchValue="#{country.name}">
+<h:column>
+#{country.name}
+</h:column>
+<h:column>
+#{country.iso}
+</h:column>
+</input:autocomplete>
+</h:form>
</ui:define>
</ui:composition>
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java
===================================================================
---
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java 2010-11-18
08:29:52 UTC (rev 20083)
+++
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java 2010-11-18
08:34:56 UTC (rev 20084)
@@ -64,7 +64,7 @@
public void encodeItem(FacesContext facesContext, UIComponent component) throws
IOException {
ResponseWriter writer = facesContext.getResponseWriter();
encodeItemBegin(facesContext, component);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-opt rf-au-fnt
rf-au-inp", null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-itm rf-au-opt
rf-au-fnt rf-au-inp", null);
for (UIComponent child : component.getChildren()) {
child.encodeAll(facesContext);
}
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java
===================================================================
---
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java 2010-11-18
08:29:52 UTC (rev 20083)
+++
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java 2010-11-18
08:34:56 UTC (rev 20084)
@@ -22,7 +22,7 @@
ResponseWriter responseWriter = facesContext.getResponseWriter();
responseWriter.startElement(HtmlConstants.UL_ELEMENT, component);
responseWriter.writeAttribute(HtmlConstants.ID_ATTRIBUTE,
getContainerElementId(facesContext, component), null);
- responseWriter.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
"rf-au-list-ul", null);
+ responseWriter.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
"rf-au-lst-ul", null);
}
public void encodeItemsContainerEnd(FacesContext facesContext, UIComponent component)
throws IOException {
@@ -43,7 +43,7 @@
public void encodeItem(FacesContext facesContext, UIComponent component) throws
IOException {
ResponseWriter writer = facesContext.getResponseWriter();
encodeItemBegin(facesContext, component);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-opt rf-au-fnt
rf-au-inp", null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-itm rf-au-opt
rf-au-fnt rf-au-inp", null);
for (UIComponent child : component.getChildren()) {
child.encodeAll(facesContext);
}
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java
===================================================================
---
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java 2010-11-18
08:29:52 UTC (rev 20083)
+++
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java 2010-11-18
08:34:56 UTC (rev 20084)
@@ -212,7 +212,7 @@
} else {
if (item != null) {
strategy.encodeItemBegin(facesContext, comboBox);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-opt
rf-au-fnt rf-au-inp", null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-itm
rf-au-opt rf-au-fnt rf-au-inp", null);
// TODO nick - use converter
String value = null;
if (comboBox.getItemConverter() != null) {
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java
===================================================================
---
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java 2010-11-18
08:29:52 UTC (rev 20083)
+++
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java 2010-11-18
08:34:56 UTC (rev 20084)
@@ -25,6 +25,7 @@
ResponseWriter responseWriter = facesContext.getResponseWriter();
responseWriter.startElement(HtmlConstants.TABLE_ELEMENT, component);
responseWriter.writeAttribute(HtmlConstants.ID_ATTRIBUTE,
getContainerElementId(facesContext, component), null);
+ responseWriter.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
"rf-au-tbl", null);
responseWriter.startElement(HtmlConstants.TBODY_ELEMENT, component);
}
@@ -37,6 +38,7 @@
public void encodeItemBegin(FacesContext facesContext, UIComponent component) throws
IOException {
ResponseWriter writer = facesContext.getResponseWriter();
writer.startElement(HtmlConstants.TR_ELEMENT, component);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-itm",
null);
writer.startElement(HtmlConstants.TD_ELEM, component);
}
@@ -59,10 +61,11 @@
public void encodeItem(FacesContext facesContext, UIComponent component) throws
IOException {
ResponseWriter writer = facesContext.getResponseWriter();
writer.startElement(HtmlConstants.TR_ELEMENT, component);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-itm",
null);
for (UIComponent child : component.getChildren()) {
if (child instanceof UIColumn) {
encodeItemChildBegin(facesContext, component);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-opt
rf-au-fnt rf-au-inp", null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-fnt
rf-au-inp", null);
child.encodeAll(facesContext);
encodeItemChildEnd(facesContext, component);
}
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.ecss
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.ecss 2010-11-18
08:29:52 UTC (rev 20083)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.ecss 2010-11-18
08:34:56 UTC (rev 20084)
@@ -1,5 +1,4 @@
-
-.rf-au-inp.rf-au-fnt, .rf-au-opt.rf-au-fnt{
+.rf-au-fnt{
color: '#{richSkin.generalTextColor}';
font-size: '#{richSkin.generalSizeFont}';
font-family: '#{richSkin.generalFamilyFont}';
@@ -72,22 +71,28 @@
min-height: 20px;
}
-.rf-au-opt{
+.rf-au-itm{
+ cursor: default;
padding: 2px;
- white-space: nowrap;
- cursor: default;
- list-style-type: none;
}
-.rf-au-sel{
- padding: 1px;
- width: 100%;
+.rf-au-itm-sel{
background-color: '#{richSkin.headerBackgroundColor}';
border-width: 1px;
border-style: dotted;
border-color: '#{richSkin.generalTextColor}';
+ padding: 1px;
}
+.rf-au-opt{
+ white-space: nowrap;
+ list-style-type: none;
+}
+
+.rf-au-opt-sel{
+ width: 100%;
+}
+
.rf-au-shdw{
border: 0px solid red;
display: inline-block;
@@ -141,4 +146,9 @@
.rf-au-lst-ul{
margin: 0px;
padding: 0px;
+}
+
+.rf-au-tbl{
+ border-spacing: 0px;
+
}
\ No newline at end of file
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js 2010-11-18
08:29:52 UTC (rev 20083)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js 2010-11-18
08:34:56 UTC (rev 20084)
@@ -115,8 +115,10 @@
var $super = rf.ui.Autocomplete.$super;
var defaultOptions = {
- selectedItemClass:'rf-au-sel',
- itemClass:'rf-au-opt',
+ itemClass:'rf-au-itm',
+ selectedItemClass:'rf-au-itm-sel',
+ subItemClass:'rf-au-opt',
+ selectedSubItemClass:'rf-au-opt-sel',
autofill:true,
minChars:1,
selectFirst:true,
@@ -244,7 +246,10 @@
if (this.items.length==0 || (!isOffset && this.index == index)) return;
if (this.index!=-1) {
- this.items.eq(this.index).removeClass(this.options.selectedItemClass);
+ var element = this.items.eq(this.index)
+ if
(element.removeClass(this.options.selectedItemClass).hasClass(this.options.subItemClass)){
+ element.removeClass(this.options.selectedSubItemClass);
+ }
}
if (index==undefined) {
@@ -268,7 +273,9 @@
this.index = index;
}
var item = this.items.eq(this.index);
- item.addClass(this.options.selectedItemClass);
+ if (item.addClass(this.options.selectedItemClass).hasClass(this.options.subItemClass))
{
+ item.addClass(this.options.selectedSubItemClass);
+ }
scrollToSelectedItem.call(this);
if (event &&
event.which != rf.KEYS.BACKSPACE &&