Author: nbelaevski
Date: 2010-07-21 09:32:16 -0400 (Wed, 21 Jul 2010)
New Revision: 18175
Modified:
root/examples-sandbox/trunk/components/combobox-demo/src/main/webapp/index.xhtml
root/ui-sandbox/inputs/trunk/combobox/src/main/java/org/richfaces/component/AbstractComboBox.java
root/ui-sandbox/inputs/trunk/combobox/src/main/java/org/richfaces/renderkit/ComboBoxRendererBase.java
Log:
Added fetchValue draft support
Modified:
root/examples-sandbox/trunk/components/combobox-demo/src/main/webapp/index.xhtml
===================================================================
---
root/examples-sandbox/trunk/components/combobox-demo/src/main/webapp/index.xhtml 2010-07-21
13:01:03 UTC (rev 18174)
+++
root/examples-sandbox/trunk/components/combobox-demo/src/main/webapp/index.xhtml 2010-07-21
13:32:16 UTC (rev 18175)
@@ -17,7 +17,7 @@
block text block text block text block text block text block text
block text block
- <combo:comboBox autocompleteMethod="#{testBean.autocomplete}"
var="country">
+ <combo:comboBox autocompleteMethod="#{testBean.autocomplete}"
var="country" fetchValue="#{country.name}">
#{country.name} #{country.iso} #{country.domain}
</combo:comboBox>
Modified:
root/ui-sandbox/inputs/trunk/combobox/src/main/java/org/richfaces/component/AbstractComboBox.java
===================================================================
---
root/ui-sandbox/inputs/trunk/combobox/src/main/java/org/richfaces/component/AbstractComboBox.java 2010-07-21
13:01:03 UTC (rev 18174)
+++
root/ui-sandbox/inputs/trunk/combobox/src/main/java/org/richfaces/component/AbstractComboBox.java 2010-07-21
13:32:16 UTC (rev 18175)
@@ -68,6 +68,10 @@
@Attribute(literal = true)
public abstract String getVar();
+ //TODO nick - el-only?
+ @Attribute(literal = false)
+ public abstract Object getFetchValue();
+
public String resolveClientId(FacesContext facesContext, UIComponent
contextComponent, String metaComponentId) {
if (ITEMS_META_COMPONENT_ID.equals(metaComponentId)) {
return getClientId(facesContext) +
MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR + metaComponentId;
Modified:
root/ui-sandbox/inputs/trunk/combobox/src/main/java/org/richfaces/renderkit/ComboBoxRendererBase.java
===================================================================
---
root/ui-sandbox/inputs/trunk/combobox/src/main/java/org/richfaces/renderkit/ComboBoxRendererBase.java 2010-07-21
13:01:03 UTC (rev 18174)
+++
root/ui-sandbox/inputs/trunk/combobox/src/main/java/org/richfaces/renderkit/ComboBoxRendererBase.java 2010-07-21
13:32:16 UTC (rev 18175)
@@ -22,7 +22,9 @@
package org.richfaces.renderkit;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import javax.el.ELException;
@@ -35,10 +37,12 @@
import javax.faces.context.PartialViewContext;
import javax.faces.context.ResponseWriter;
+import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.AbstractComboBox;
import org.richfaces.component.MetaComponentResolver;
+import com.google.common.base.Predicates;
import com.google.common.collect.Iterators;
/**
@@ -147,7 +151,7 @@
responseWriter.endElement(HTML.LI_ELEMENT);
}
- protected void encodeItems(FacesContext facesContext, UIComponent component) throws
IOException {
+ protected void encodeItems(FacesContext facesContext, UIComponent component,
List<Object> fetchValues) throws IOException {
AbstractComboBox comboBox = (AbstractComboBox) component;
encodeItemsContainerBegin(facesContext, component);
@@ -163,6 +167,7 @@
setVar(facesContext, comboBox.getVar(), nextItem);
encodeItem(facesContext, comboBox, nextItem);
+ fetchValues.add(comboBox.getFetchValue());
}
setVar(facesContext, comboBox.getVar(), savedVar);
@@ -211,10 +216,17 @@
throws IOException {
if (AbstractComboBox.ITEMS_META_COMPONENT_ID.equals(metaComponentId)) {
+ List<Object> fetchValues = new ArrayList<Object>();
+
PartialResponseWriter partialWriter =
context.getPartialViewContext().getPartialResponseWriter();
partialWriter.startUpdate(getContainerElementId(context, component));
- encodeItems(context, component);
+ encodeItems(context, component, fetchValues);
partialWriter.endUpdate();
+
+ if (!fetchValues.isEmpty() && Iterators.find(fetchValues.iterator(),
Predicates.notNull()) != null) {
+ Map<String, Object> dataMap =
AjaxContext.getCurrentInstance(context).getResponseComponentDataMap();
+ dataMap.put(component.getClientId(context), fetchValues);
+ }
} else {
throw new IllegalArgumentException(metaComponentId);
}
Show replies by date