Author: sergeyhalipov
Date: 2008-02-21 09:59:24 -0500 (Thu, 21 Feb 2008)
New Revision: 6248
Modified:
trunk/sandbox/ui/inplaceInput/src/main/java/org/richfaces/component/UIInplaceInput.java
trunk/sandbox/ui/inplaceInput/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
trunk/ui/dataTable/pom.xml
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
trunk/ui/dataTable/src/main/templates/org/richfaces/htmlDataTable.jspx
Log:
Added inplace inputs to headers with filter.
Modified:
trunk/sandbox/ui/inplaceInput/src/main/java/org/richfaces/component/UIInplaceInput.java
===================================================================
---
trunk/sandbox/ui/inplaceInput/src/main/java/org/richfaces/component/UIInplaceInput.java 2008-02-21
14:56:02 UTC (rev 6247)
+++
trunk/sandbox/ui/inplaceInput/src/main/java/org/richfaces/component/UIInplaceInput.java 2008-02-21
14:59:24 UTC (rev 6248)
@@ -14,6 +14,13 @@
public abstract class UIInplaceInput extends UIInput {
+ /**
+ * <p>The standard component type for this component.</p>
+ */
+ public static final String COMPONENT_TYPE = "org.richfaces.InplaceInput";
+
+ public static final String VALUE_SUFFIX = "value";
+
public abstract String getDefaultLabel();
public abstract void setDefaultLabel(String label);
Modified:
trunk/sandbox/ui/inplaceInput/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
===================================================================
---
trunk/sandbox/ui/inplaceInput/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java 2008-02-21
14:56:02 UTC (rev 6247)
+++
trunk/sandbox/ui/inplaceInput/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java 2008-02-21
14:59:24 UTC (rev 6248)
@@ -64,7 +64,7 @@
throw new NullPointerException("component " +
inplaceInput.getClientId(context) + " client id is NULL" );
}
- clientId = clientId + "value";
+ clientId = clientId + UIInplaceInput.VALUE_SUFFIX;
Map request = context.getExternalContext().getRequestParameterMap();
if (request.containsKey(clientId)) {
String newValue = (String)request.get(clientId);
Modified: trunk/ui/dataTable/pom.xml
===================================================================
--- trunk/ui/dataTable/pom.xml 2008-02-21 14:56:02 UTC (rev 6247)
+++ trunk/ui/dataTable/pom.xml 2008-02-21 14:59:24 UTC (rev 6248)
@@ -48,5 +48,15 @@
<version>3.2.0-SNAPSHOT</version>
</dependency>
-->
+ <dependency>
+ <groupId>org.richfaces.sandbox.ui</groupId>
+ <artifactId>inplaceInput</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.1</version>
+ </dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
Modified:
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
---
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2008-02-21
14:56:02 UTC (rev 6247)
+++
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2008-02-21
14:59:24 UTC (rev 6248)
@@ -22,28 +22,27 @@
package org.richfaces.renderkit;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import javax.el.ELContext;
import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.component.UIDataAdaptor;
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.resource.InternetResource;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.iterators.FilterIterator;
import org.richfaces.component.Column;
import org.richfaces.component.Row;
import org.richfaces.component.UIDataTable;
+import org.richfaces.component.UIInplaceInput;
import org.richfaces.model.Ordering;
/**
@@ -54,6 +53,8 @@
private static final String SORT_FILTER_PARAMETER = "fsp";
+ private UIInplaceInput filterValueInput = null;
+
/**
* Encode all table structure - colgroups definitions, caption, header,
* footer
@@ -232,12 +233,8 @@
ajaxFunction.addParameter(eventOptions);
StringBuffer buffer = new StringBuffer();
ajaxFunction.appendScript(buffer);
- writer.startElement(HTML.INPUT_ELEM, column);
- writer.writeAttribute(HTML.TYPE_ATTR, "text", null);
- writer.writeAttribute(HTML.NAME_ATTRIBUTE, column.getClientId(context) +
SORT_FILTER_PARAMETER, null);
- writer.writeAttribute(HTML.value_ATTRIBUTE,
column.getAttributes().get("filterValue"), null);
- writer.writeAttribute(HTML.onchange_ATTRIBUTE, buffer.toString(), null);
- writer.endElement(HTML.INPUT_ELEM);
+
+ encodeInplaceInput(context, column, buffer);
}
}
writer.endElement(element);
@@ -527,7 +524,8 @@
column.setSortOrder(Ordering.UNSORTED);
}
}
- String filterValue = map.get(children.getClientId(context) +
SORT_FILTER_PARAMETER);
+ String filterValue = map.get(children.getClientId(context) + SORT_FILTER_PARAMETER
+
+ UIInplaceInput.VALUE_SUFFIX);
if (filterValue != null) {
column.setFilterValue(filterValue);
}
@@ -538,4 +536,16 @@
.addComponentToAjaxRender(component);
}
}
+
+ protected void encodeInplaceInput(FacesContext context, UIComponent column, StringBuffer
buffer)
+ throws IOException {
+ if (null == filterValueInput) {
+ filterValueInput = (UIInplaceInput)
context.getApplication().createComponent(UIInplaceInput.COMPONENT_TYPE);
+ filterValueInput.setId(column.getId() + SORT_FILTER_PARAMETER);
+ column.getParent().getChildren().add(filterValueInput);
+ }
+ filterValueInput.getAttributes().put("onviewactivated", buffer.toString());
+ filterValueInput.setValue(column.getAttributes().get("filterValue"));
+ renderChild(context, filterValueInput);
+ }
}
\ No newline at end of file
Modified: trunk/ui/dataTable/src/main/templates/org/richfaces/htmlDataTable.jspx
===================================================================
--- trunk/ui/dataTable/src/main/templates/org/richfaces/htmlDataTable.jspx 2008-02-21
14:56:02 UTC (rev 6247)
+++ trunk/ui/dataTable/src/main/templates/org/richfaces/htmlDataTable.jspx 2008-02-21
14:59:24 UTC (rev 6248)
@@ -13,7 +13,11 @@
component="org.richfaces.component.UIDataTable"
<h:styles>css/table.xcss</h:styles>
- <h:scripts>new org.ajax4jsf.javascript.AjaxScript()</h:scripts>
+ <h:scripts>
+ new org.ajax4jsf.javascript.AjaxScript(),
+ new org.ajax4jsf.javascript.PrototypeScript(),
+ /org/richfaces/renderkit/html/scripts/inplaceinput.js
+ </h:scripts>
<f:clientid var="clientId"/>
<table id="#{clientId}"
class="dr-table rich-table #{component.attributes['styleClass']}"
style="#{component.attributes['style']}"