JBoss Rich Faces SVN: r16519 - branches/community/3.3.X/samples/richfaces-demo/functional-test.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-03-03 02:36:05 -0500 (Wed, 03 Mar 2010)
New Revision: 16519
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/pom.xml
branches/community/3.3.X/samples/richfaces-demo/functional-test/profiles.jboss-qa.xml
Log:
RFPL-426 rf-demo ftest - pom.xml: jboss6x enabled configuration
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/pom.xml
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/pom.xml 2010-03-03 07:32:38 UTC (rev 16518)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/pom.xml 2010-03-03 07:36:05 UTC (rev 16519)
@@ -426,6 +426,61 @@
</plugins>
</build>
</profile>
+ <!-- Container: JBoss AS 6.X -->
+ <profile>
+ <id>container-jboss6x</id>
+ <activation>
+ <property>
+ <name>containerId</name>
+ <value>jboss6x</value>
+ </property>
+ </activation>
+ <properties>
+ <container.home>${project.build.directory}/installs/jboss-${container.version}/${container.unflatted.dir}</container.home>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <version>1.0.1-alpha-2</version>
+ <executions>
+ <execution>
+ <id>undeploy-container</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>undeploy</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <configuration>
+ <home>${container.home}/server/default</home>
+ <type>existing</type>
+ <properties>
+ <cargo.jboss.configuration>default</cargo.jboss.configuration>
+ <cargo.rmi.port>1099</cargo.rmi.port>
+ </properties>
+ </configuration>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>container-jboss6x-installation</id>
+ <activation>
+ <property>
+ <name>containerId</name>
+ <value>jboss6x</value>
+ </property>
+ </activation>
+ <properties>
+ <container.version>6.0.0.M2</container.version>
+ <container.unflatted.dir>jboss-6.0.0.20100216-M2</container.unflatted.dir>
+ <container.installer.url>http://downloads.sourceforge.net/project/jboss/JBoss/JBoss-${container.ve...</container.installer.url>
+ </properties>
+ </profile>
<!-- Container: JBoss AS 5.X -->
<profile>
<id>container-jboss5x</id>
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/profiles.jboss-qa.xml
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/profiles.jboss-qa.xml 2010-03-03 07:32:38 UTC (rev 16518)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/profiles.jboss-qa.xml 2010-03-03 07:36:05 UTC (rev 16519)
@@ -121,6 +121,10 @@
<jboss5x.version>5.1.0.GA</jboss5x.version>
<jboss5x.installer.url.unix>file:/qa/tools/src/jboss/jboss-5.1.0.GA.zip</jboss5x.installer.url.unix>
<jboss5x.installer.url.windows>file:t:\src\jboss\jboss-5.1.0.GA.zip</jboss5x.installer.url.windows>
+ <jboss6x.version>6.0.0.M2</jboss6x.version>
+ <jboss6x.unflatted.dir>jboss-6.0.0.M2</jboss6x.unflatted.dir>
+ <jboss6x.installer.url.unix>file:/qa/tools/src/jboss/jboss-6.0.0.M2.zip</jboss6x.installer.url.unix>
+ <jboss6x.installer.url.windows>file:t:\src\jboss\jboss-6.0.0.M2.zip</jboss6x.installer.url.windows>
<tomcat6x.version>6.0.18</tomcat6x.version>
<tomcat6x.installer.url.unix>file:/qa/tools/src/apache/apache-tomcat-6.0.18.zip</tomcat6x.installer.url.unix>
<tomcat6x.installer.url.windows>file:t:\src\apache\apache-tomcat-6.0.18.zip</tomcat6x.installer.url.windows>
@@ -168,6 +172,21 @@
</properties>
</profile>
<profile>
+ <id>container-jboss6x-installation</id>
+ <activation>
+ <property>
+ <name>containerId</name>
+ <value>jboss6x</value>
+ </property>
+ </activation>
+ <properties>
+ <container.version>${jboss6x.version}</container.version>
+ <container.unflatted.dir>${jboss6x.unflatted.dir}</container.unflatted.dir>
+ <container.installer.url.unix>${jboss6x.installer.url.unix}</container.installer.url.unix>
+ <container.installer.url.windows>${jboss6x.installer.url.windows}</container.installer.url.windows>
+ </properties>
+ </profile>
+ <profile>
<id>container-installation-unix</id>
<activation>
<os>
14 years, 2 months
JBoss Rich Faces SVN: r16518 - branches/community/3.3.X/samples/richfaces-demo/functional-test.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-03-03 02:32:38 -0500 (Wed, 03 Mar 2010)
New Revision: 16518
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/pom.xml
Log:
RFPL-284 - rf-demo ftest - pom.xml: default definition of firefoxProfileTemplate points to maven root directory - caused copying all of the directory data to /tmp/customProfile*
Modified: branches/community/3.3.X/samples/richfaces-demo/functional-test/pom.xml
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/functional-test/pom.xml 2010-03-03 00:08:19 UTC (rev 16517)
+++ branches/community/3.3.X/samples/richfaces-demo/functional-test/pom.xml 2010-03-03 07:32:38 UTC (rev 16518)
@@ -69,7 +69,6 @@
<selenium.port>8444</selenium.port>
<selenium.debug>false</selenium.debug>
<selenium.maximize>false</selenium.maximize>
- <firefoxProfileTemplate></firefoxProfileTemplate>
<demo.deployable>${demo.deployable.directory}/${demo.deployable.file}</demo.deployable>
<demo.deployable.directory>${project.build.directory}</demo.deployable.directory>
<demo.deployable.file>richfaces-demo.war</demo.deployable.file>
14 years, 2 months
JBoss Rich Faces SVN: r16517 - in branches/community/3.3.X/ui/message/src: main/java/org/richfaces/renderkit/html and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-03-02 19:08:19 -0500 (Tue, 02 Mar 2010)
New Revision: 16517
Modified:
branches/community/3.3.X/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java
branches/community/3.3.X/ui/message/src/main/java/org/richfaces/renderkit/html/HtmlRichMessagesRenderer.java
branches/community/3.3.X/ui/message/src/test/java/org/richfaces/component/UIMessagesTest.java
Log:
RESOLVED - issue RF-8432: messages: messages not rendered if not ajaxRendered but explicitly reRendered and level used
https://jira.jboss.org/jira/browse/RF-8432
Modified: branches/community/3.3.X/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java
===================================================================
--- branches/community/3.3.X/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java 2010-03-02 18:52:59 UTC (rev 16516)
+++ branches/community/3.3.X/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java 2010-03-03 00:08:19 UTC (rev 16517)
@@ -52,7 +52,6 @@
private String forVal = null;
private boolean updated = false;
- private boolean ajaxRendered = true;
private List<FacesMessageWithId> renderedMessages;
/**
@@ -99,14 +98,6 @@
return updated;
}
- public boolean isAjaxRendered() {
- return ajaxRendered;
- }
-
- public void setAjaxRendered(boolean ajaxRendered) {
- this.ajaxRendered = ajaxRendered;
- }
-
public Iterator<FacesMessage> getMessages(FacesContext context) {
String forInputId = getFor();
if (null == this.renderedMessages || null != forInputId) {
@@ -181,8 +172,7 @@
Iterator<FacesMessage> messages = context.getMessages(forId);
while (messages.hasNext()) {
FacesMessage message = messages.next();
- if (severenities.size() == 0 || severenities.contains("ALL")
- || isApplicableMessage(severenities, message)) {
+ if (isApplicableMessage(severenities, message)) {
renderedMessages.add(new FacesMessageWithId(forId, message));
}
}
@@ -198,10 +188,11 @@
if (severenities.size() == 0 || severenities.contains("ALL")) {
return true;
}
- AjaxContext ac = AjaxContext.getCurrentInstance(FacesContext.getCurrentInstance());
- if(ac.isAjaxRequest() && !this.isAjaxRendered()){
- return false;
- }
+// AjaxContext ac = AjaxContext.getCurrentInstance(FacesContext.getCurrentInstance());
+ // https://jira.jboss.org/jira/browse/RF-8432
+// if(ac.isAjaxRequest() && !this.isAjaxRendered()){
+// return false;
+// }
Severity severity = message.getSeverity();
for (Object key : FacesMessage.VALUES_MAP.keySet()) {
Severity sev = (Severity) FacesMessage.VALUES_MAP.get(key);
@@ -220,6 +211,10 @@
super.encodeBegin(context);
}
+ public abstract boolean isAjaxRendered();
+
+ public abstract void setAjaxRendered(boolean ajaxRendered);
+
public abstract String getLevel();
public abstract void setLevel(String level);
@@ -237,13 +232,12 @@
public Object saveState(FacesContext context) {
if (values == null) {
- values = new Object[4];
+ values = new Object[3];
}
values[0] = super.saveState(context);
values[1] = this.forVal;
- values[2] = this.ajaxRendered;
- values[3] = saveAttachedState(context, getRenderedMessages());
+ values[2] = saveAttachedState(context, getRenderedMessages());
return (values);
}
@@ -254,9 +248,8 @@
values = (Object[]) state;
super.restoreState(context, values[0]);
forVal = (String) values[1];
- ajaxRendered = (Boolean) values[2];
setRenderedMessages((List<FacesMessageWithId>) restoreAttachedState(
- context, values[3]));
+ context, values[2]));
}
/**
Modified: branches/community/3.3.X/ui/message/src/main/java/org/richfaces/renderkit/html/HtmlRichMessagesRenderer.java
===================================================================
--- branches/community/3.3.X/ui/message/src/main/java/org/richfaces/renderkit/html/HtmlRichMessagesRenderer.java 2010-03-02 18:52:59 UTC (rev 16516)
+++ branches/community/3.3.X/ui/message/src/main/java/org/richfaces/renderkit/html/HtmlRichMessagesRenderer.java 2010-03-03 00:08:19 UTC (rev 16517)
@@ -44,23 +44,11 @@
UIRichMessages uiMessages = (UIRichMessages)component;
String layout = null;
- String forIds = null;
- String forClientId = uiMessages.getFor();
- if(null != forClientId){
- forIds = forClientId;
- }
- if(uiMessages.isGlobalOnly()){
- if(null == forClientId){
- forIds = "";
- }else{
- throw new FacesException("The rich:messages component must specify only one of 'for' or 'globalOnly' atribbute");
- }
- }
Iterator<FacesMessage> messagesIter = uiMessages.getMessages(context);
boolean isDisplayNone = !messagesIter.hasNext();
boolean isWroteTable = false;
layout = (String)uiMessages.getAttributes().get("layout");
- if((layout != null) && (layout.equals("table"))){
+ if("table".equals(layout)){
writer.startElement("table", uiMessages);
getUtils().writeAttribute(writer,HTML.id_ATTRIBUTE ,uiMessages.getClientId(context));
@@ -70,13 +58,15 @@
writer.startElement("tbody", uiMessages);
isWroteTable = true;
- }else if((layout != null) && (layout.equals("list"))){
+ } else if("list".equals(layout)){
isWroteTable = false;
writer.startElement(HTML.DL_ELEMENT, uiMessages);
getUtils().writeAttribute(writer,HTML.id_ATTRIBUTE ,uiMessages.getClientId(context));
renderComponentOuterStyles(uiMessages, context, writer, isDisplayNone);
+ } else {
+ throw new FacesException("unknown messages layout "+layout);
}
// messagesIter = getMessageIterator(context, forIds, component);
Modified: branches/community/3.3.X/ui/message/src/test/java/org/richfaces/component/UIMessagesTest.java
===================================================================
--- branches/community/3.3.X/ui/message/src/test/java/org/richfaces/component/UIMessagesTest.java 2010-03-02 18:52:59 UTC (rev 16516)
+++ branches/community/3.3.X/ui/message/src/test/java/org/richfaces/component/UIMessagesTest.java 2010-03-03 00:08:19 UTC (rev 16517)
@@ -56,6 +56,17 @@
public void setMinLevel(String level) {
this.minLevel = level;
}
+
+ @Override
+ public boolean isAjaxRendered() {
+ return true;
+ }
+
+ @Override
+ public void setAjaxRendered(boolean ajaxRendered) {
+ // TODO Auto-generated method stub
+
+ }
}
private static final String INPUT_ID = "input";
14 years, 2 months
JBoss Rich Faces SVN: r16516 - in root/ui-sandbox/trunk/components/datascroller/ui/src/main/resources/META-INF/resources: css and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-03-02 13:52:59 -0500 (Tue, 02 Mar 2010)
New Revision: 16516
Added:
root/ui-sandbox/trunk/components/datascroller/ui/src/main/resources/META-INF/resources/css/
root/ui-sandbox/trunk/components/datascroller/ui/src/main/resources/META-INF/resources/css/datascroller.css
root/ui-sandbox/trunk/components/datascroller/ui/src/main/resources/META-INF/resources/script/
root/ui-sandbox/trunk/components/datascroller/ui/src/main/resources/META-INF/resources/script/datascroller.js
Log:
add styles, scripts
Added: root/ui-sandbox/trunk/components/datascroller/ui/src/main/resources/META-INF/resources/css/datascroller.css
===================================================================
--- root/ui-sandbox/trunk/components/datascroller/ui/src/main/resources/META-INF/resources/css/datascroller.css (rev 0)
+++ root/ui-sandbox/trunk/components/datascroller/ui/src/main/resources/META-INF/resources/css/datascroller.css 2010-03-02 18:52:59 UTC (rev 16516)
@@ -0,0 +1,70 @@
+.ds_container{
+ white-space : nowrap;
+ display : inline-block;
+ font-size : 11px/*generalSizeFont*/;
+ padding : 1px;
+ font-family : verdana/*generalFamilyFont*/;
+ background : #ffffff/*background-color - tableBackgroundColor*/;
+}
+
+.ds_container_decor{
+ border : 1px solid #A6A6A6/*tableBorderColor*/;
+}
+
+.ds_button{
+ cursor : pointer;
+ padding : 2px 10px 3px 10px;
+ border : 1px solid #A6A6A6/*tableBorderColor*/;
+ display : inline-block;
+ background : url(images/bg_btn.png) top left repeat-x #C0D1E7/*gradient - from headerGradientColor to headerBackgroundColor, background-color - headerBackgroundColor*/;
+ font-size : 11px/*generalSizeFont*/;
+ font-family : verdana/*generalFamilyFont*/;
+ color : #000000/*generalTextColor*/;
+}
+
+.ds_left{
+ margin-right : 1px;
+}
+
+.ds_right{
+ margin-left : 1px;
+}
+
+.ds_digital{
+ cursor : pointer;
+ width : 2em;
+ text-align : center;
+ margin-left : 1px;
+ margin-right : 1px;
+ padding : 2px 2px 3px 2px;
+ border : 1px solid transparent;
+ border-top : 1px solid #A6A6A6/*tableBorderColor*/;
+ background : url(images/bg_field.png) top left repeat-x/*gradient - from additionalBackgroundColor to tableBackgroundColor, background-color - tableBackgroundColor*/;
+ display : inline-block;
+ font-size : 11px/*generalSizeFont*/;
+ font-family : verdana/*generalFamilyFont*/;
+ color : #000000/*generalTextColor*/;
+}
+
+.ds_over{
+ border : 1px solid #A6A6A6/*tableBorderColor*/;
+ background : url(images/bg_field.png) top left repeat-x #FFFFFF; /*gradient - from additionalBackgroundColor to tableBackgroundColor, background-color - tableBackgroundColor*/;
+}
+
+.ds_press{
+ border : 1px solid #A6A6A6/*tableBorderColor*/;
+ background : #ECF3FA; /*background-color - additionalBackgroundColor*/;
+}
+
+.ds_current{
+ cursor : default;
+ font-weight : bold;
+ border : 1px solid transparent;
+ border-bottom : 1px solid #A6A6A6/*tableBorderColor*/;
+ background : none;
+}
+
+.ds_disabled{
+ color : #A6A6A6/*tableBorderColor*/;
+ cursor : default;
+}
\ No newline at end of file
Added: root/ui-sandbox/trunk/components/datascroller/ui/src/main/resources/META-INF/resources/script/datascroller.js
===================================================================
--- root/ui-sandbox/trunk/components/datascroller/ui/src/main/resources/META-INF/resources/script/datascroller.js (rev 0)
+++ root/ui-sandbox/trunk/components/datascroller/ui/src/main/resources/META-INF/resources/script/datascroller.js 2010-03-02 18:52:59 UTC (rev 16516)
@@ -0,0 +1,55 @@
+(function (jQuery, richfaces) {
+
+ richfaces.ui = richfaces.ui || {};
+
+ richfaces.ui.DataScroller = function(id, options) {
+ this.id = id;
+ this.options = options;
+ this.init(options);
+ };
+
+ jQuery.extend(richfaces.ui.DataScroller.prototype, ( function () {
+
+ return {
+ init: function(options) {
+ RichFaces.Event.bindById(this.id, 'rich:datascroller:onscroll', this.submitFunction, this);
+ },
+
+ submitFunction: function(event) {
+ alert(test);
+ },
+
+ switchToPage: function(page) {
+ if (typeof page != 'undefined' && page != null) {
+ RichFaces.Event.callHandlerById(this.id, 'rich:datascroller:onscroll', {'page': page});
+ }
+ },
+
+ next: function() {
+ this.switchToPage("next");
+ },
+
+ previous: function() {
+ this.switchToPage("previous");
+ },
+
+ first: function() {
+ this.switchToPage("first");
+ },
+
+ last: function() {
+ this.switchToPage("last");
+ },
+
+ fastForward: function() {
+ this.switchToPage("fastforward");
+ },
+
+ fastRewind: function() {
+ this.switchToPage("fastrewind");
+ }
+ }
+
+ })());
+
+})(jQuery, window.RichFaces);
\ No newline at end of file
14 years, 2 months
JBoss Rich Faces SVN: r16515 - in root/ui-sandbox/trunk/components/datascroller/ui/src/main: java/org/richfaces/component and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-03-02 13:51:43 -0500 (Tue, 02 Mar 2010)
New Revision: 16515
Modified:
root/ui-sandbox/trunk/components/datascroller/ui/src/main/config/faces-config.xml
root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/RenderPhaseDataScrollerVisitor.java
root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/UIDataScroller.java
root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/html/HtmlDataScroller.java
root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/renderkit/ControlsState.java
root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/taglib/DatascrollerTagHandler.java
root/ui-sandbox/trunk/components/datascroller/ui/src/main/templates/datascroller.template.xml
Log:
UIDatascroller isn't abstract class, extend template
Modified: root/ui-sandbox/trunk/components/datascroller/ui/src/main/config/faces-config.xml
===================================================================
--- root/ui-sandbox/trunk/components/datascroller/ui/src/main/config/faces-config.xml 2010-03-01 18:30:39 UTC (rev 16514)
+++ root/ui-sandbox/trunk/components/datascroller/ui/src/main/config/faces-config.xml 2010-03-02 18:51:43 UTC (rev 16515)
@@ -33,13 +33,4 @@
<cdk:generate xmlns:cdk="http://richfaces.org/cdk/extensions">false</cdk:generate>
</component-extension>
</component>
-
- <render-kit>
- <render-kit-id>HTML_BASIC</render-kit-id>
- <renderer>
- <component-family>org.richfaces.DataScroller</component-family>
- <renderer-type>org.richfaces.DataScrollerRenderer</renderer-type>
- <renderer-class>org.richfaces.renderkit.html.DataScrollerRenderer</renderer-class>
- </renderer>
- </render-kit>
</faces-config>
\ No newline at end of file
Modified: root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/RenderPhaseDataScrollerVisitor.java
===================================================================
--- root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/RenderPhaseDataScrollerVisitor.java 2010-03-01 18:30:39 UTC (rev 16514)
+++ root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/RenderPhaseDataScrollerVisitor.java 2010-03-02 18:51:43 UTC (rev 16515)
@@ -99,9 +99,9 @@
if (component instanceof UIDataScroller && isRendered(state.components)) {
UIDataScroller datascroller = (UIDataScroller) component;
- UIData dataTable = datascroller.getDataTable();
+ //UIData dataTable = datascroller.getDataTable();
- state.connections.addConnection(dataTable, datascroller);
+ // state.connections.addConnection(dataTable, datascroller);
}
}
Modified: root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/UIDataScroller.java
===================================================================
--- root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/UIDataScroller.java 2010-03-01 18:30:39 UTC (rev 16514)
+++ root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/UIDataScroller.java 2010-03-02 18:51:43 UTC (rev 16515)
@@ -1,5 +1,6 @@
package org.richfaces.component;
+import java.io.Serializable;
import java.util.Map;
import javax.el.ELException;
@@ -25,46 +26,34 @@
import org.slf4j.Logger;
-public abstract class UIDataScroller extends UIComponentBase implements DataScrollerSource {
+public class UIDataScroller extends UIComponentBase implements DataScrollerSource {
public static final String COMPONENT_TYPE = "org.richfaces.DataScroller";
+ public static final String COMPONENT_FAMILY = "org.richfaces.DataScroller";
+
private static final Logger log = RichfacesLogger.COMPONENTS.getLogger();
-
+
+ protected enum PropertyKeys {
+ boundaryControls, data, fastControls, fastStep, forComponent, handleValue, inactiveStyle, selectStyle,
+ inactiveStyleClass, selectStyleClass, scrollerListener, lastPageMode, maxPages, pageIndexVar, pagesVar, renderIfSinglePage,
+ style, styleClass, stepControls
+ }
+
+ protected enum Facets {
+ first, last, fastforward, fastrewind, first_disabled, last_disabled, fastforward_disabled, fastrewind_disabled
+ }
- public static final String LAST_PAGE_MODE_FULL = "full";
+ protected enum PageMode {
+ full, part //part - prev short
+ }
+
- public static final String LAST_PAGE_MODE_SHORT = "short";
-
-
- public static final String FIRST_FACET_NAME = "first";
-
- public static final String LAST_FACET_NAME = "last";
-
- public static final String NEXT_FACET_NAME = "next";
-
- public static final String PREVIOUS_FACET_NAME = "previous";
-
- public static final String FAST_FORWARD_FACET_NAME = "fastforward";
-
- public static final String FAST_REWIND_FACET_NAME = "fastrewind";
-
- public static final String FIRST_DISABLED_FACET_NAME = "first_disabled";
-
- public static final String LAST_DISABLED_FACET_NAME = "last_disabled";
-
- public static final String NEXT_DISABLED_FACET_NAME = "next_disabled";
-
- public static final String PREVIOUS_DISABLED_FACET_NAME = "previous_disabled";
-
- public static final String FAST_FORWARD_DISABLED_FACET_NAME = "fastforward_disabled";
-
- public static final String FAST_REWIND_DISABLED_FACET_NAME = "fastrewind_disabled";
-
-
+//TODO: anton - fix
private Integer page;
+
public void addScrollerListener(DataScrollerListener listener) {
addFacesListener(listener);
}
@@ -87,88 +76,32 @@
FacesContext context = getFacesContext();
- MethodExpression scrollerListener = getScrollerListener();
+ MethodExpression scrollerListener = (MethodExpression)getAttributes().get(PropertyKeys.scrollerListener); //getScrollerListener();
if (scrollerListener != null) {
scrollerListener.invoke(context.getELContext(), new Object[]{event});
}
}
}
-
+
- public abstract MethodExpression getScrollerListener();
-
- public abstract void setScrollerListener(MethodExpression scrollerListener);
-
- public abstract void setFor(String f);
-
- public abstract String getFor();
-
- public abstract int getFastStep();
-
- public abstract void setFastStep(int FastStep);
-
- public abstract int getMaxPages();
-
- public abstract void setMaxPages(int maxPages);
-
- public abstract String getSelectedStyleClass();
-
- public abstract void setSelectedStyleClass(String selectedStyleClass);
-
- public abstract String getSelectedStyle();
-
- public abstract void setSelectedStyle(String selectedStyle);
-
- public abstract String getStyleClass();
-
- public abstract void setStyleClass(String styleClass);
-
- public abstract String getStyle();
-
- public abstract void setStyle(String styleClass);
-
- public abstract String getBoundaryControls();
-
- public abstract void setBoundaryControls(String boundaryControls);
-
- public abstract String getFastControls();
-
- public abstract void setFastControls(String fastControls);
-
- public abstract String getStepControls();
-
- public abstract void setStepControls(String stepControls);
-
- public abstract String getInactiveStyleClass();
-
- public abstract void setInactiveStyleClass(String inactiveStyleClass);
-
- public abstract String getInactiveStyle();
-
- public abstract void setInactiveStyle(String inactiveStyle);
-
- public abstract String getLastPageMode();
-
- public abstract void setLastPageMode(String lastPageMode);
-
/**
* Finds the dataTable which id is mapped to the "for" property
*
* @return the dataTable component
*/
- public UIData getDataTable() {
- String forAttribute = getFor();
+ public UIComponent getDataTable() {
+ String forAttribute = (String)getStateHelper().get(PropertyKeys.forComponent);
UIComponent forComp;
if (forAttribute == null) {
forComp = this;
while ((forComp = forComp.getParent()) != null) {
- if (forComp instanceof UIData) {
- setFor(forComp.getId());
- return (UIData) forComp;
+ if (forComp instanceof UIData || forComp instanceof UIDataAdaptor) {
+ getStateHelper().put(PropertyKeys.forComponent, forComp.getId());
+ return forComp;
}
}
throw new FacesException("could not find dataTable for datascroller " + this.getId());
@@ -179,19 +112,19 @@
if (forComp == null) {
throw new IllegalArgumentException("could not find dataTable with id '" + forAttribute + "'");
- } else if (!(forComp instanceof UIData)) {
+ } else if (!(forComp instanceof UIData) || !(forComp instanceof UIDataAdaptor)) {
throw new IllegalArgumentException( "component with id '" + forAttribute
- + "' must be of type " + UIData.class.getName()
+ + "' must be of type " + UIData.class.getName() + " or " + UIDataAdaptor.class
+ ", not type "
+ forComp.getClass().getName());
}
- return (UIData) forComp;
+ return forComp;
}
-
+
private int getFastStepOrDefault() {
- int step = getFastStep();
+ int step = (Integer)getStateHelper().get(PropertyKeys.fastStep);
return step <= 0 ? 1 : step;
}
@@ -202,25 +135,19 @@
int newPage = 1;
int pageCount = getPageCount();
-
- if (FIRST_FACET_NAME.equals(facetName)) {
- newPage = 1;
- } else if (PREVIOUS_FACET_NAME.equals(facetName)) {
- newPage = getPage() - 1;
- } else if (NEXT_FACET_NAME.equals(facetName)) {
- newPage = getPage() + 1;
- } else if (LAST_FACET_NAME.equals(facetName)) {
- newPage = pageCount > 0 ? pageCount : 1;
- } else if (FAST_FORWARD_FACET_NAME.equals(facetName)) {
- newPage = getPage() + getFastStepOrDefault();
- } else if (FAST_REWIND_FACET_NAME.equals(facetName)) {
- newPage = getPage() - getFastStepOrDefault();
- } else {
- try {
- newPage = Integer.parseInt(facetName.toString());
- } catch (NumberFormatException e) {
- throw new FacesException(e.getLocalizedMessage(), e);
- }
+
+ switch (Facets.valueOf(facetName)) {
+ case first : newPage = 1; break;
+ case last : newPage = pageCount > 0 ? pageCount : 1; break;
+ case fastforward : newPage = getPage() + getFastStepOrDefault(); break;
+ case fastrewind : newPage = getPage() - getFastStepOrDefault(); break;
+ default:
+ try {
+ newPage = Integer.parseInt(facetName.toString());
+ } catch (NumberFormatException e) {
+ throw new FacesException(e.getLocalizedMessage(), e);
+ }
+ break;
}
if (newPage >= 1 && newPage <= pageCount) {
@@ -230,13 +157,13 @@
}
}
- public int getPageCount(UIData data) {
+ public int getPageCount(UIComponent data) {
int rowCount = getRowCount(data);
int rows = getRows(data);
return getPageCount(data, rowCount, rows);
}
- public int getPageCount(UIData data, int rowCount, int rows) {
+ public int getPageCount(UIComponent data, int rowCount, int rows) {
int pageCount;
if (rows > 0) {
pageCount = rows <= 0 ? 1 : rowCount / rows;
@@ -258,8 +185,8 @@
return getPageCount(getDataTable());
}
- public int getRowCount(UIData data) {
- int rowCount = data.getRowCount();
+ public int getRowCount(UIComponent data) {
+ int rowCount = (Integer)data.getAttributes().get("rowCount");
if (rowCount >= 0) {
return rowCount;
}
@@ -278,9 +205,9 @@
return getRowCount(getDataTable());
}
- public int getRows(UIData data) {
+ public int getRows(UIComponent data) {
int row = 0;
- row = data.getRows();
+ row = (Integer)data.getAttributes().get("rows");
if (row == 0) {
row = getRowCount(data);
}
@@ -290,45 +217,42 @@
// facet getter methods
public UIComponent getFirst() {
- return getFacet(FIRST_FACET_NAME);
+ return getFacet(Facets.first.toString());
}
public UIComponent getLast() {
- return getFacet(LAST_FACET_NAME);
+ return getFacetByKey(Facets.last);
}
- public UIComponent getNext() {
- return getFacet(NEXT_FACET_NAME);
- }
-
public UIComponent getFastForward() {
- return getFacet(FAST_FORWARD_FACET_NAME);
+ return getFacetByKey(Facets.fastforward);
}
public UIComponent getFastRewind() {
- return getFacet(FAST_REWIND_FACET_NAME);
+ return getFacetByKey(Facets.fastrewind);
}
- public UIComponent getPrevious() {
- return getFacet(PREVIOUS_FACET_NAME);
+ private UIComponent getFacetByKey(Object key) {
+ return getFacet(key.toString());
}
-
+
private static boolean isRendered(UIComponent component) {
UIComponent c = component;
while (c != null) {
if (!c.isRendered()) {
return false;
}
-
c = c.getParent();
}
return true;
}
+
+
public void setupFirstRowValue() {
- UIData dataTable = getDataTable();
+ UIComponent dataTable = getDataTable();
if (isRendered()) {
int rowCount = getRowCount(dataTable);
int rows = getRows(dataTable);
@@ -358,16 +282,15 @@
if (isRendered(dataTable)) {
int first;
- String lastPageMode = getLastPageMode();
+ String lastPageMode = (String)getStateHelper().get(PropertyKeys.lastPageMode);
+
if (lastPageMode == null) {
- lastPageMode = LAST_PAGE_MODE_SHORT;
- } else if (!LAST_PAGE_MODE_SHORT.equals(lastPageMode) &&
- !LAST_PAGE_MODE_FULL.equals(lastPageMode)) {
-
+ lastPageMode = PageMode.part.toString();
+ } else if (!PageMode.part.equals(lastPageMode) && !PageMode.full.equals(lastPageMode)) {
throw new IllegalArgumentException("Illegal value of 'lastPageMode' attribute: '" + lastPageMode + "'");
}
- if (page != pageCount || LAST_PAGE_MODE_SHORT.equals(lastPageMode)) {
+ if (page != pageCount || PageMode.part.equals(lastPageMode)) {
first = (page - 1) * rows;
} else {
first = rowCount - rows;
@@ -376,7 +299,7 @@
}
}
- dataTable.setFirst(first);
+ dataTable.getAttributes().put("first", first);
}
}
}
@@ -415,10 +338,10 @@
}
private void updateModel(int newPage) {
- UIData dataTable = getDataTable();
+ UIComponent dataTable = getDataTable();
if (isRendered(dataTable)) {
- dataTable.setFirst((newPage - 1) * getRows(dataTable));
+ dataTable.getAttributes().put("first", (newPage - 1) * getRows(dataTable));
}
Map<String, Object> attributes = dataTable.getAttributes();
@@ -474,14 +397,14 @@
static class BinarySearch {
- public static int search(UIData data) {
- int rowIndex = data.getRowIndex();
+ public static int search(UIComponent data) {
+ int rowIndex = (Integer)data.getAttributes().get("rowIndex");
try {
int n = 1;
int k = 2;
for (; ;) {
- data.setRowIndex(k - 1);
- if (data.isRowAvailable()) {
+ data.getAttributes().put("rowIndex", k-1);
+ if ((Boolean)data.getAttributes().get("rowAvailable")) {
n = k;
k = k * 2;
} else {
@@ -491,22 +414,22 @@
while (n < k) {
int kk = Math.round((n + k) / 2) + 1;
- data.setRowIndex(kk - 1);
- if (data.isRowAvailable()) {
+ data.getAttributes().put("rowIndex", kk-1);
+ if ((Boolean)data.getAttributes().get("rowAvailable")) {
n = kk;
} else {
k = kk - 1;
}
}
-
- data.setRowIndex(k - 1);
- if (data.isRowAvailable()) {
+
+ data.getAttributes().put("rowIndex", k-1);
+ if ((Boolean)data.getAttributes().get("rowAvailable")) {
return k;
} else {
return 0;
}
} finally {
- data.setRowIndex(rowIndex);
+ data.getAttributes().put("rowIndex",rowIndex);
}
}
}
@@ -536,4 +459,8 @@
page = null;
}
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
}
Modified: root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/html/HtmlDataScroller.java
===================================================================
--- root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/html/HtmlDataScroller.java 2010-03-01 18:30:39 UTC (rev 16514)
+++ root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/html/HtmlDataScroller.java 2010-03-02 18:51:43 UTC (rev 16515)
@@ -6,157 +6,120 @@
public class HtmlDataScroller extends UIDataScroller{
- public static final String COMPONENT_FAMILY = "org.richfaces.DataScroller";
-
- protected enum PropertyKeys {
- boundaryControls, data, fastControls, fastStep, forComponent, handleValue, inactiveStyle, selectStyle,
- inactiveStyleClass, selectStyleClass, scrollerListener, lastPageMode, maxPages, pageIndexVar, pagesVar, renderIfSinglePage,
- style, styleClass, stepControls
- }
-
- @Override
public String getBoundaryControls() {
- return (String)getStateHelper().eval(PropertyKeys.boundaryControls);
+ return (String)getStateHelper().eval(PropertyKeys.boundaryControls, "show");
}
- @Override
public String getFastControls() {
- return (String)getStateHelper().eval(PropertyKeys.fastControls);
+ return (String)getStateHelper().eval(PropertyKeys.fastControls, "show");
}
- @Override
public int getFastStep() {
return (Integer)getStateHelper().eval(PropertyKeys.fastStep, 0);
}
- @Override
public String getFor() {
return (String)getStateHelper().eval(PropertyKeys.forComponent);
}
- @Override
public String getInactiveStyle() {
return (String)getStateHelper().eval(PropertyKeys.inactiveStyle);
}
- @Override
public String getInactiveStyleClass() {
return (String)getStateHelper().eval(PropertyKeys.inactiveStyleClass);
}
- @Override
public String getLastPageMode() {
return (String)getStateHelper().eval(PropertyKeys.lastPageMode);
}
- @Override
public int getMaxPages() {
return (Integer)getStateHelper().eval(PropertyKeys.maxPages,0);
}
- @Override
public String getSelectedStyle() {
return (String)getStateHelper().eval(PropertyKeys.selectStyle);
}
- @Override
public String getSelectedStyleClass() {
return (String)getStateHelper().eval(PropertyKeys.selectStyleClass);
}
- @Override
public String getStepControls() {
return (String)getStateHelper().eval(PropertyKeys.selectStyleClass);
}
- @Override
public String getStyle() {
return (String)getStateHelper().eval(PropertyKeys.selectStyle);
}
- @Override
public String getStyleClass() {
return (String)getStateHelper().eval(PropertyKeys.selectStyleClass);
}
- @Override
public MethodExpression getScrollerListener() {
return (MethodExpression)getStateHelper().eval(PropertyKeys.scrollerListener);
}
- @Override
public void setBoundaryControls(String boundaryControls) {
getStateHelper().put(PropertyKeys.boundaryControls, boundaryControls);
}
- @Override
public void setFastControls(String fastControls) {
getStateHelper().put(PropertyKeys.fastControls, fastControls);
}
- @Override
public void setFastStep(int fastStep) {
getStateHelper().put(PropertyKeys.fastStep, fastStep);
}
- @Override
public void setFor(String f) {
getStateHelper().put(PropertyKeys.forComponent, f);
}
- @Override
public void setInactiveStyle(String inactiveStyle) {
getStateHelper().put(PropertyKeys.inactiveStyle, inactiveStyle);
}
- @Override
public void setInactiveStyleClass(String inactiveStyleClass) {
getStateHelper().put(PropertyKeys.inactiveStyleClass, inactiveStyleClass);
}
- @Override
public void setLastPageMode(String lastPageMode) {
getStateHelper().put(PropertyKeys.inactiveStyle, lastPageMode);
}
- @Override
public void setMaxPages(int maxPages) {
getStateHelper().put(PropertyKeys.maxPages, maxPages);
}
- @Override
public void setSelectedStyle(String selectedStyle) {
getStateHelper().put(PropertyKeys.selectStyle, selectedStyle);
}
- @Override
public void setSelectedStyleClass(String selectedStyleClass) {
getStateHelper().put(PropertyKeys.selectStyleClass, selectedStyleClass);
}
- @Override
public void setStepControls(String stepControls) {
getStateHelper().put(PropertyKeys.stepControls, stepControls);
}
- @Override
public void setStyle(String style) {
getStateHelper().put(PropertyKeys.style, style);
}
- @Override
public void setStyleClass(String styleClass) {
getStateHelper().put(PropertyKeys.styleClass, styleClass);
}
- @Override
public void setScrollerListener(MethodExpression scrollerListener) {
getStateHelper().put(PropertyKeys.scrollerListener, scrollerListener);
}
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
+ public boolean isRenderIfSinglePage() {
+ return true;
}
}
Modified: root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/renderkit/ControlsState.java
===================================================================
--- root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/renderkit/ControlsState.java 2010-03-01 18:30:39 UTC (rev 16514)
+++ root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/renderkit/ControlsState.java 2010-03-02 18:51:43 UTC (rev 16515)
@@ -32,13 +32,13 @@
private boolean lastRendered = true;
private boolean lastEnabled = true;
-
+/*
private boolean previousRendered = true;
private boolean previousEnabled = true;
private boolean nextRendered = true;
private boolean nextEnabled = true;
-
+*/
private boolean fastRewindRendered = true;
private boolean fastRewindEnabled = true;
@@ -47,30 +47,33 @@
private boolean controlsSeparatorRendered = false;
- public boolean isFirstRendered() {
+
+ public boolean getFirstRendered() {
return firstRendered;
}
public void setFirstRendered(boolean firstRendered) {
this.firstRendered = firstRendered;
}
- public boolean isFirstEnabled() {
+ public boolean getFirstEnabled() {
return firstEnabled;
}
public void setFirstEnabled(boolean firstEnabled) {
this.firstEnabled = firstEnabled;
}
- public boolean isLastRendered() {
+ public boolean getLastRendered() {
return lastRendered;
}
public void setLastRendered(boolean lastRendered) {
this.lastRendered = lastRendered;
}
- public boolean isLastEnabled() {
+ public boolean getLastEnabled() {
return lastEnabled;
}
public void setLastEnabled(boolean lastEnabled) {
this.lastEnabled = lastEnabled;
}
+
+ /*
public boolean isPreviousRendered() {
return previousRendered;
}
@@ -94,26 +97,26 @@
}
public void setNextEnabled(boolean nextEnabled) {
this.nextEnabled = nextEnabled;
- }
- public boolean isFastRewindRendered() {
+ }*/
+ public boolean getFastRewindRendered() {
return fastRewindRendered;
}
public void setFastRewindRendered(boolean fastRewindRendered) {
this.fastRewindRendered = fastRewindRendered;
}
- public boolean isFastRewindEnabled() {
+ public boolean getFastRewindEnabled() {
return fastRewindEnabled;
}
public void setFastRewindEnabled(boolean fastRewindEnabled) {
this.fastRewindEnabled = fastRewindEnabled;
}
- public boolean isFastForwardRendered() {
+ public boolean getFastForwardRendered() {
return fastForwardRendered;
}
public void setFastForwardRendered(boolean fastForwardRendered) {
this.fastForwardRendered = fastForwardRendered;
}
- public boolean isFastForwardEnabled() {
+ public boolean getFastForwardEnabled() {
return fastForwardEnabled;
}
public void setFastForwardEnabled(boolean fastForwardEnabled) {
Modified: root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
===================================================================
--- root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-03-01 18:30:39 UTC (rev 16514)
+++ root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-03-02 18:51:43 UTC (rev 16515)
@@ -23,54 +23,57 @@
import java.io.IOException;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
import javax.faces.component.UIParameter;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.render.Renderer;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.event.AjaxEvent;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.UIDataScroller;
import org.richfaces.event.DataScrollerEvent;
+@ResourceDependencies( {@ResourceDependency(library = "javax.faces", name = "jsf-uncompressed.js"),
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name="richfaces-queue.js"),
+ @ResourceDependency(name = "script/datascroller.js"),
+ @ResourceDependency(name = "css/datascroller.css")})
public class DataScrollerBaseRenderer extends Renderer {
public void doDecode(FacesContext context, UIComponent component) {
- Map paramMap = getParamMap(context);
+ Map <String, String> paramMap = context.getExternalContext().getRequestParameterMap();
+
String clientId = component.getClientId(context);
String param = (String) paramMap.get(clientId);
+
if (param != null) {
- UIDataScroller scroller = (UIDataScroller) component;
+
+ UIDataScroller scroller = (UIDataScroller) component;
int newPage = scroller.getPageForFacet(param);
int page = scroller.getPage();
+
if (newPage != 0 && newPage != page) {
- DataScrollerEvent event = new DataScrollerEvent(scroller,
- String.valueOf(page), param, newPage);
- event.queue();
-
+ new DataScrollerEvent(scroller,String.valueOf(page), param, newPage).queue();
}
-
- if (AjaxRendererUtils.isAjaxRequest(context)) {
- AjaxContext.getCurrentInstance(context)
- .addAreasToProcessFromComponent(context, component);
- }
-
- new AjaxEvent(component).queue();
}
}
- public ControlsState getControlsState(FacesContext context,
- UIDataScroller datascroller, int pageIndex, int pageCount) {
+ public ControlsState getControlsState(FacesContext context, UIComponent component) {
+
+
+ int fastStep = (Integer)component.getAttributes().get("fastStep");
+ int pageIndex = (Integer)component.getAttributes().get("page");
+ int pageCount = (Integer)component.getAttributes().get("pageCount");
+
int minPageIdx = 1;
int maxPageIdx = pageCount;
- int fastStep = datascroller.getFastStep();
+
if (fastStep <= 1) {
fastStep = 1;
}
@@ -100,9 +103,10 @@
}
boolean isAuto;
- String boundaryControls = datascroller.getBoundaryControls();
- String stepControls = datascroller.getStepControls();
- String fastControls = datascroller.getFastControls();
+
+ String boundaryControls = (String)component.getAttributes().get("boundaryControls");
+ String stepControls = (String)component.getAttributes().get("stepControls");
+ String fastControls = (String)component.getAttributes().get("fastControls");
if ((isAuto = "auto".equals(boundaryControls)) || "show".equals(
boundaryControls)) {
@@ -118,8 +122,8 @@
controlsState.setLastRendered(false);
}
- if ((isAuto = "auto".equals(stepControls)) || "show".equals(
- stepControls)) {
+ /*
+ if ((isAuto = "auto".equals(stepControls)) || "show".equals(stepControls)) {
if (isAuto) {
controlsState.setPreviousRendered(useFirst);
controlsState.setNextRendered(useLast);
@@ -130,7 +134,7 @@
} else {
controlsState.setPreviousRendered(false);
controlsState.setNextRendered(false);
- }
+ }*/
if ((isAuto = "auto".equals(fastControls)) || "show".equals(
fastControls)) {
@@ -146,7 +150,7 @@
controlsState.setFastRewindRendered(false);
}
- UIComponent controlsSeparatorFacet = datascroller.getFacet("controlsSeparator");
+ UIComponent controlsSeparatorFacet = component.getFacet("controlsSeparator");
if (controlsSeparatorFacet != null && controlsSeparatorFacet.isRendered()) {
controlsState.setControlsSeparatorRendered(true);
}
@@ -154,22 +158,20 @@
return controlsState;
}
- public void renderPager(FacesContext context, UIComponent component, int pageIndex, int count)
- throws IOException {
- ResponseWriter out = context.getResponseWriter();
- UIDataScroller scroller = (UIDataScroller) component;
- int currentPage = pageIndex;
-
- int maxPages = scroller.getMaxPages();
- if (maxPages <= 1) {
- maxPages = 1;
- }
+ public void renderPager(FacesContext context,ResponseWriter out, UIComponent component) throws IOException {
- int pageCount = count;
+ int currentPage = (Integer)component.getAttributes().get("page");
+ int maxPages = (Integer)component.getAttributes().get("maxPages");
+ int pageCount = (Integer)component.getAttributes().get("pageCount");
+
if (pageCount <= 1) {
return;
}
-
+
+ if (maxPages <= 1) {
+ maxPages = 1;
+ }
+
int delta = maxPages / 2;
int pages;
@@ -191,127 +193,92 @@
String styleClass;
String style;
if (isCurrentPage) {
- styleClass = scroller.getSelectedStyleClass();
- style = scroller.getSelectedStyle();
+ styleClass = (String)component.getAttributes().get("selectedStyleClass");
+ style = (String)component.getAttributes().get("selectedStyle");
} else {
- styleClass = scroller.getInactiveStyleClass();
- style = scroller.getInactiveStyle();
+ styleClass = (String)component.getAttributes().get("inactiveStyleClass");
+ style = (String)component.getAttributes().get("inactiveStyle");
}
if (styleClass==null){
styleClass="";
}
- out.startElement("td", component);
+ out.startElement(HTML.SPAN_ELEM, component);
if (isCurrentPage) {
- out.writeAttribute("class", "rich-datascr-act "+
- styleClass, null);
+ out.writeAttribute(HTML.CLASS_ATTRIBUTE, "ds_digital ds_current "+styleClass, null);
} else {
- out.writeAttribute("class", "rich-datascr-inact "+
- styleClass, null);
- out.writeAttribute("onclick", getOnClick(Integer.toString(i + 1)), null);
+ out.writeAttribute(HTML.CLASS_ATTRIBUTE, "ds_digital "+styleClass, null);
+
+ out.writeAttribute(HTML.ONMOUSEOVER_ATTRIBUTE, "this.className='ds_digital ds_over'", null);
+ out.writeAttribute(HTML.ONMOUSEOUT_ATTRIBUTE, "this.className='ds_digital'", null);
+ out.writeAttribute(HTML.ONMOUSEUP_ATTRIBUTE, "this.className='ds_digital ds_over'", null);
+ out.writeAttribute(HTML.ONMOUSEDOWN_ATTRIBUTE, "this.className='ds_digital ds_press'", null);
+
+ out.writeAttribute(HTML.ONCLICK_ATTRIBUTE, getOnClick(Integer.toString(i + 1)), null);
}
- if (null != style) out.writeAttribute("style", style, null);
+
+ if (null != style) {
+ out.writeAttribute(HTML.STYLE_ATTRIBUTE, style, null);
+ }
out.writeText(Integer.toString(i + 1), null);
- //renderChild(context, link);
- out.endElement("td");
+ out.endElement(HTML.SPAN_ELEM);
}
-
}
+
+
public Object getOnClick(String string) {
- return "Event.fire(this, 'rich:datascroller:onscroll', {'page': '" + string + "'});";
+ return "Event.fire(this, 'rich:datascroller:onscroll', {'page': '" + string + "'});";
}
- public void renderPages(FacesContext context, UIComponent component, int pageIndex, int count)
- throws IOException {
- UIDataScroller scroller = (UIDataScroller) component;
+ public void renderPages(FacesContext context, UIComponent component, int pageIndex, int count) throws IOException {
int currentPage = pageIndex;
int pageCount = count;
if (pageCount <= 1) {
pageCount = 1;
}
- String varName = (String) scroller.getAttributes().get("pageIndexVar");
+ String varName = (String) component.getAttributes().get("pageIndexVar");
if (varName != null && varName.length() > 0) {
- context.getExternalContext()
- .getRequestMap().put(varName, new Integer(currentPage));
+ //TODO: anton - fix
+ context.getExternalContext().getRequestMap().put(varName, new Integer(currentPage));
}
- varName = (String) scroller.getAttributes().get("pagesVar");
+ varName = (String) component.getAttributes().get("pagesVar");
if (varName != null && varName.length() > 0) {
- context.getExternalContext()
- .getRequestMap().put(varName, new Integer(pageCount));
+ //TODO: anton - fix
+ context.getExternalContext().getRequestMap().put(varName, new Integer(pageCount));
}
}
- private Map getParamMap(FacesContext context) {
- return context.getExternalContext().getRequestParameterMap();
- }
-
- //get UIParameter's Map
- protected Map getParameters(FacesContext context, UIComponent component){
- Map parameters = new HashMap();
+ //get UIParameter's Map
+ protected Map <String, Object> getParameters(FacesContext context, UIComponent component){
+ Map <String,Object> parameters = new HashMap<String, Object>();
if(component instanceof UIDataScroller){
- UIDataScroller datascroller = (UIDataScroller)component;
- List children = datascroller.getChildren();
- for (Iterator iterator = children.iterator(); iterator.hasNext();) {
- UIComponent child = (UIComponent) iterator.next();
- if(child instanceof UIParameter) {
+
+ UIDataScroller datascroller = (UIDataScroller)component;
+ List <UIComponent> children = datascroller.getChildren();
+
+ for (UIComponent child: children) {
+ if(child instanceof UIParameter) {
UIParameter param = (UIParameter)child;
String name = param.getName();
if (name != null) {
parameters.put(name, param.getValue());
}
}
- }
- }
-
+ }
+ }
return parameters;
}
- /**
+
public String getSubmitFunction(FacesContext context, UIComponent component) {
- JSFunctionDefinition definition = new JSFunctionDefinition("event");
-
- JSFunction function = AjaxRendererUtils.buildAjaxFunction(component,
- context);
- Map eventOptions = AjaxRendererUtils.buildEventOptions(context,
- component, true);
- Map parameters = (Map) eventOptions.get("parameters");
-
- Map params = getParameters(context,component);
- if(!params.isEmpty()){
- parameters.putAll(params);
- }
-
- parameters.put(component.getClientId(context), new JSLiteral("event.memo.page"));
-
- function.addParameter(eventOptions);
- StringBuffer buffer = new StringBuffer();
- function.appendScript(buffer);
- buffer.append("; return false;");
-
- String onPageChange = (String) component.getAttributes().get("onpagechange");
- if (onPageChange != null && onPageChange.length() != 0) {
- JSFunctionDefinition onPageChangeDef = new JSFunctionDefinition("event");
- onPageChangeDef.addToBody(onPageChange);
- onPageChangeDef.addToBody("; return true;");
-
- definition.addToBody("if (");
- definition.addToBody(onPageChangeDef.toScript());
- definition.addToBody("(event)) {");
- definition.addToBody(buffer.toString());
- definition.addToBody("}");
- } else {
- definition.addToBody(buffer.toString());
+// TODO: anton - add
+ return null;
}
-
- return definition.toScript();
- }
- */
- /** Creates HtmlAjaxCommandLink sets its id, value and reRender and UIParameter */
public boolean getRendersChildren() {
return true;
}
Modified: root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/taglib/DatascrollerTagHandler.java
===================================================================
--- root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/taglib/DatascrollerTagHandler.java 2010-03-01 18:30:39 UTC (rev 16514)
+++ root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/taglib/DatascrollerTagHandler.java 2010-03-02 18:51:43 UTC (rev 16515)
@@ -44,14 +44,14 @@
private static final MetaRule pageRule = new MetaRule() {
- public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
- if ("page".equals(name)) {
- return new PageMapper(attribute);
- } else {
- return null;
- }
- }
-
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
+ if ("page".equals(name)) {
+ return new PageMapper(attribute);
+ } else {
+ return null;
+ }
+ }
+
};
private static final class PageMapper extends Metadata {
@@ -72,17 +72,17 @@
UIDataScroller datascroller = (UIDataScroller) instance;
ValueExpression ve = page.getValueExpression(ctx, int.class);
if (ve.isLiteralText()) {
- Integer value = (Integer) ve.getValue(ctx.getFacesContext().getELContext());
- datascroller.setPage(value);
+ Integer value = (Integer) ve.getValue(ctx.getFacesContext().getELContext());
+ datascroller.setPage(value);
} else {
- datascroller.setValueExpression("page", ve);
+ datascroller.setValueExpression("page", ve);
}
}
}
public DatascrollerTagHandler(ComponentConfig config) {
- super(config);
+ super(config);
}
protected MetaRuleset createMetaRuleset(Class type) {
Modified: root/ui-sandbox/trunk/components/datascroller/ui/src/main/templates/datascroller.template.xml
===================================================================
--- root/ui-sandbox/trunk/components/datascroller/ui/src/main/templates/datascroller.template.xml 2010-03-01 18:30:39 UTC (rev 16514)
+++ root/ui-sandbox/trunk/components/datascroller/ui/src/main/templates/datascroller.template.xml 2010-03-02 18:51:43 UTC (rev 16515)
@@ -5,33 +5,80 @@
xmlns:javaee="http://java.sun.com/xml/ns/javaee">
<cc:interface>
- <cdk:class>org.richfaces.renderkit.html.GenerateDataScrollerRenderer</cdk:class>
+ <cdk:class>org.richfaces.renderkit.html.DataScrollerRenderer</cdk:class>
<cdk:superclass>org.richfaces.renderkit.DataScrollerBaseRenderer</cdk:superclass>
<cdk:component-family>org.richfaces.DataScroller</cdk:component-family>
- <cdk:renderer-type>org.richfaces.GeneratedDataScroller</cdk:renderer-type>
+ <cdk:renderer-type>org.richfaces.DataScrollerRenderer</cdk:renderer-type>
</cc:interface>
<cc:implementation>
- <span id="" class="ds_container !ds_container_decor"><!-- Now decor is disabled !!! -->
+
+
+ <cdk:object type="org.richfaces.renderkit.ControlsState" name="controlsState" value="#{getControlsState(facesContext,component)}" />
+
+ <span id="#{clientId}" class="ds_container !ds_container_decor"><!-- Now decor is disabled !!! -->
+ <c:if test="#{controlsState.firstRendered}">
+ <c:choose>
+ <c:when test="#{controlsState.firstEnabled}">
+ <span class="ds_button ds_left" onmousedown="this.className='ds_button ds_left ds_over'" onmouseup="this.className='ds_button ds_left'" onmouseout="this.className='ds_button ds_left'" onclick="#{getOnClick('first')}">
+ ««
+ </span>
+ </c:when>
+ <c:otherwise>
+ <span class="ds_button ds_left ds_disabled">
+ ««
+ </span>
+ </c:otherwise>
+ </c:choose>
+ </c:if>
- <span class="ds_button ds_left ds_disabled">
- ««
- </span>
- <span class="ds_button ds_left ds_disabled">
- «
- </span>
+ <c:if test="#{controlsState.fastRewindRendered}">
+ <c:choose>
+ <c:when test="#{controlsState.fastRewindEnabled}">
+ <span class="ds_button ds_left" onmousedown="this.className='ds_button ds_left ds_over'" onmouseup="this.className='ds_button ds_left'" onmouseout="this.className='ds_button ds_left'" onclick="#{getOnClick('fastRewind')}">
+ «
+ </span>
+ </c:when>
+ <c:otherwise>
+ <span class="ds_button ds_left ds_disabled">
+ «
+ </span>
+ </c:otherwise>
+ </c:choose>
+ </c:if>
+
+ <cdk:call expression="renderPager(facesContext, responseWriter, component);"/>
- <span class="ds_digital" onmouseover="this.className='ds_digital ds_over'" onmouseout="this.className='ds_digital'" onmouseup="this.className='ds_digital ds_over'" onmousedown="this.className='ds_digital ds_press'">
- </span>
+ <c:if test="#{controlsState.fastForwardRendered}">
+ <c:choose>
+ <c:when test="#{controlsState.fastForwardEnabled}">
+ <span class="ds_button ds_right" onmousedown="this.className='ds_button ds_right ds_over'" onmouseup="this.className='ds_button ds_right'" onmouseout="this.className='ds_button ds_right'" onclick="#{getOnClick('fastForward')}">
+ »
+ </span>
+ </c:when>
+ <c:otherwise>
+ <span class="ds_button ds_right ds_disabled">
+ »
+ </span>
+ </c:otherwise>
+ </c:choose>
+ </c:if>
- <span class="ds_button ds_right" onmousedown="this.className='ds_button ds_right ds_over'" onmouseup="this.className='ds_button ds_right'" onmouseout="this.className='ds_button ds_right'">
- »
- </span>
-
- <span class="ds_button ds_right" onmousedown="this.className='ds_button ds_right ds_over'" onmouseup="this.className='ds_button ds_right'" onmouseout="this.className='ds_button ds_right'">
- »»
+ <c:if test="#{controlsState.lastRendered}">
+ <c:choose>
+ <c:when test="#{controlsState.lastEnabled}">
+ <span class="ds_button ds_right" onmousedown="this.className='ds_button ds_right ds_over'" onmouseup="this.className='ds_button ds_right'" onmouseout="this.className='ds_button ds_right'" onclick="#{getOnClick('last')}">
+ »»
+ </span>
+ </c:when>
+ <c:otherwise>
+ <span class="ds_button ds_right ds_disabled">
+ »»
+ </span>
+ </c:otherwise>
+ </c:choose>
+ </c:if>
</span>
- </span>
</cc:implementation>
</cdk:root>
\ No newline at end of file
14 years, 2 months
JBoss Rich Faces SVN: r16514 - in root/examples-sandbox/trunk/components/tables/src/main: webapp and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-03-01 13:30:39 -0500 (Mon, 01 Mar 2010)
New Revision: 16514
Added:
root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/FilteringAndSortingBean.java
root/examples-sandbox/trunk/components/tables/src/main/webapp/filteringAndSorting.xhtml
Log:
RF-7852 filtering and sorting sample
Added: root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/FilteringAndSortingBean.java
===================================================================
--- root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/FilteringAndSortingBean.java (rev 0)
+++ root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/FilteringAndSortingBean.java 2010-03-01 18:30:39 UTC (rev 16514)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.demo;
+
+import java.util.Comparator;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+import javax.swing.SortOrder;
+
+import org.richfaces.demo.model.Employee;
+import org.richfaces.model.Filter;
+
+@ManagedBean(name="filteringAndSortingBean")
+@SessionScoped
+public class FilteringAndSortingBean {
+
+ private SortOrder nameSortOrder = SortOrder.UNSORTED;
+
+ private SortOrder emailSortOrder = SortOrder.UNSORTED;
+
+ private String nameFilterValue;
+
+ private String titleFilterValue;
+
+ public Filter<?> getFilter() {
+ return new Filter<Employee>() {
+ public boolean accept(Employee employee) {
+ if (titleFilterValue != null && employee != null && employee.getTitle() != null) {
+ return employee.getTitle().toUpperCase().startsWith(titleFilterValue.toUpperCase());
+ }
+ return true;
+ }
+ };
+ }
+
+ public Comparator<?> getComparator() {
+ return new Comparator<Employee>() {
+ public int compare(Employee o1, Employee o2) {
+ if (o1.getName() != null) {
+ return o1.getName().compareToIgnoreCase(o2.getName());
+ }
+ return 0;
+ }
+ };
+ }
+
+ public void setNameSortOrder(SortOrder nameSortOrder) {
+ this.nameSortOrder = nameSortOrder;
+ }
+
+ public SortOrder getNameSortOrder() {
+ return nameSortOrder;
+ }
+
+ public void setEmailSortOrder(SortOrder emailSortOrder) {
+ this.emailSortOrder = emailSortOrder;
+ }
+
+ public SortOrder getEmailSortOrder() {
+ return emailSortOrder;
+ }
+
+ public void setTitleFilterValue(String titleFilterValue) {
+ this.titleFilterValue = titleFilterValue;
+ }
+
+ public String getTitleFilterValue() {
+ return titleFilterValue;
+ }
+
+ public void setNameFilterValue(String nameFilterValue) {
+ this.nameFilterValue = nameFilterValue;
+ }
+
+ public String getNameFilterValue() {
+ return nameFilterValue;
+ }
+
+}
Added: root/examples-sandbox/trunk/components/tables/src/main/webapp/filteringAndSorting.xhtml
===================================================================
--- root/examples-sandbox/trunk/components/tables/src/main/webapp/filteringAndSorting.xhtml (rev 0)
+++ root/examples-sandbox/trunk/components/tables/src/main/webapp/filteringAndSorting.xhtml 2010-03-01 18:30:39 UTC (rev 16514)
@@ -0,0 +1,104 @@
+<!--
+JBoss, Home of Professional Open Source
+Copyright ${year}, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:rich="http://richfaces.org/rich">
+ <f:view contentType="text/html"/>
+
+ <h:head>
+ <title>Richfaces Filtering And Sorting Developer's Demo</title>
+ </h:head>
+
+ <h:body>
+ <h:form id="form1">
+ <h:outputText value="Show data in table" />
+ <h:selectBooleanCheckbox value="#{dataBean.state}">
+ <f:ajax render="dataTable" />
+ </h:selectBooleanCheckbox>
+ <rich:dataTable id="dataTable" value="#{dataBean.state ? dataBean.employeeList : null}" var="record" rowKeyVar="rkv" filterVar="fv">
+ <f:facet name="noData">
+ <h:outputText value="There isn't data." style="border: solid black 1px;"/>
+ </f:facet>
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText value="rkv"/>
+ </f:facet>
+ <h:outputText value="#{rkv}" />
+ </rich:column>
+ <rich:column id="column_name" filterValue="#{filteringAndSortingBean.nameFilterValue}"
+ filterExpression="#{fv == null || fv == '' ||fv == record.name}"
+ comparator="#{filteringAndSortingBean.comparator}" sortOrder="#{filteringAndSortingBean.nameSortOrder}">
+ <f:facet name="header">
+ <h:outputText id="columnHeader1" value="Column Header Facet" />
+ <h:outputText value="Title"/>
+ <h:inputText value="#{filteringAndSortingBean.nameFilterValue}">
+ <f:ajax render=":form1:dataTable" />
+ </h:inputText>
+ <h:selectOneMenu value="#{filteringAndSortingBean.nameSortOrder}">
+ <f:selectItem itemLabel="ASCENDING" itemValue="ASCENDING"/>
+ <f:selectItem itemLabel="DESCENDING" itemValue="DESCENDING"/>
+ <f:selectItem itemLabel="UNSORTED" itemValue="UNSORTED"/>
+ <f:ajax render=":form1:dataTable" />
+ </h:selectOneMenu>
+ </f:facet>
+ <h:outputText value="#{record.name}" />
+ <f:facet name="footer">
+ <h:outputText id="columnFooter1" value="Column Footer Facet"/>
+ </f:facet>
+ </rich:column>
+
+ <rich:column id="column_title" width="200px" filter="#{filteringAndSortingBean.filter}">
+ <f:facet name="header">
+ <h:outputText value="Title"/>
+ <h:inputText value="#{filteringAndSortingBean.titleFilterValue}">
+ <f:ajax render=":form1:dataTable" />
+ </h:inputText>
+ </f:facet>
+ <h:outputText value="#{record.title}" />
+ <f:facet name="footer">
+ <h:outputText id="columnFooter2" value="Column Footer Facet2"/>
+ </f:facet>
+ </rich:column>
+
+ <rich:column id="column_email" width="300px" sortBy="#{record.EMail}" sortOrder="#{filteringAndSortingBean.emailSortOrder}">
+ <f:facet name="header">
+ <h:outputText value="E-mail"/>
+ <h:selectOneMenu value="#{filteringAndSortingBean.emailSortOrder}">
+ <f:selectItem itemLabel="ASCENDING" itemValue="ASCENDING"/>
+ <f:selectItem itemLabel="DESCENDING" itemValue="DESCENDING"/>
+ <f:selectItem itemLabel="UNSORTED" itemValue="UNSORTED"/>
+ <f:ajax render=":form1:dataTable" />
+ </h:selectOneMenu>
+ </f:facet>
+ <h:outputText value="#{record.EMail}" />
+ </rich:column>
+ </rich:dataTable>
+ <input type="submit" />
+ </h:form>
+ </h:body>
+</html>
14 years, 2 months
JBoss Rich Faces SVN: r16513 - in root: framework/trunk/impl/src/test/java/org/richfaces and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-03-01 13:28:34 -0500 (Mon, 01 Mar 2010)
New Revision: 16513
Added:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/FilterField.java
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/LocaleAware.java
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Modifiable.java
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ModifiableState.java
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableModel.java
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableStateDefaultImpl.java
Removed:
root/framework/trunk/api/src/main/java/org/richfaces/model/Field.java
root/framework/trunk/api/src/main/java/org/richfaces/model/FilterField.java
root/framework/trunk/api/src/main/java/org/richfaces/model/LocaleAware.java
root/framework/trunk/api/src/main/java/org/richfaces/model/Modifiable.java
root/framework/trunk/api/src/main/java/org/richfaces/model/ModifiableState.java
root/framework/trunk/api/src/main/java/org/richfaces/model/SortField.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/
Modified:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Field.java
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/SortField.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumn.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumn.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
Log:
RF-8118 RF-8119
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/Field.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/Field.java 2010-03-01 14:10:38 UTC (rev 16512)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/Field.java 2010-03-01 18:28:34 UTC (rev 16513)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.richfaces.model;
-
-import javax.el.ValueExpression;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public abstract class Field {
-
- private ValueExpression expression;
-
- public Field(ValueExpression expression) {
- this.expression = expression;
- }
-
- protected ValueExpression getExpression() {
- return expression;
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/FilterField.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/FilterField.java 2010-03-01 14:10:38 UTC (rev 16512)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/FilterField.java 2010-03-01 18:28:34 UTC (rev 16513)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.richfaces.model;
-
-import javax.el.ValueExpression;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class FilterField extends Field{
-
- private Filter<?> filter;
-
- private String filterValue;
-
- public FilterField(ValueExpression filterExpression, Filter<?> filter, String filterValue) {
- super(filterExpression);
- this.filter = filter;
- this.filterValue = filterValue;
- }
-
- public ValueExpression getFilterExpression() {
- return getExpression();
- }
-
- public Filter<?> getFilter() {
- return filter;
- }
-
- public String getFilterValue() {
- return filterValue;
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/LocaleAware.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/LocaleAware.java 2010-03-01 14:10:38 UTC (rev 16512)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/LocaleAware.java 2010-03-01 18:28:34 UTC (rev 16513)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.richfaces.model;
-
-import java.util.Locale;
-
-/**
- * Models that are based on locale-dependent operations should implement this interface
- *
- * @author Nick Belaevski
- * @since 3.3.0
- */
-
-public interface LocaleAware {
-
- Locale getLocale();
-
- void setLocale(Locale locale);
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/Modifiable.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/Modifiable.java 2010-03-01 14:10:38 UTC (rev 16512)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/Modifiable.java 2010-03-01 18:28:34 UTC (rev 16513)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.richfaces.model;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public interface Modifiable {
-
- void modify(ModifiableState state);
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/ModifiableState.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/ModifiableState.java 2010-03-01 14:10:38 UTC (rev 16512)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/ModifiableState.java 2010-03-01 18:28:34 UTC (rev 16513)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.richfaces.model;
-
-import java.util.List;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public interface ModifiableState {
-
- List<FilterField> getFilterFields();
-
- List<SortField> getSortFields();
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/SortField.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/SortField.java 2010-03-01 14:10:38 UTC (rev 16512)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/SortField.java 2010-03-01 18:28:34 UTC (rev 16513)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.richfaces.model;
-
-import java.util.Comparator;
-
-import javax.el.ValueExpression;
-import javax.swing.SortOrder;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class SortField extends Field {
-
- private Comparator<?> comparator;
-
- private SortOrder order;
-
- public SortField(ValueExpression sortBy, Comparator<?> comparator, SortOrder order) {
- super(sortBy);
- this.comparator = comparator;
- this.order = order;
- }
-
- public ValueExpression getSortBy() {
- return getExpression();
- }
-
- public Comparator<?> getComparator() {
- return comparator;
- }
-
- public SortOrder getSortOrder() {
- return order;
- }
-}
Modified: root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Field.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Field.java 2010-03-01 14:10:38 UTC (rev 16512)
+++ root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Field.java 2010-03-01 18:28:34 UTC (rev 16513)
@@ -1,44 +1,42 @@
-/**
- * License Agreement.
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
*
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
*
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
+ * This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
+
package org.richfaces.model;
-import javax.el.Expression;
+import javax.el.ValueExpression;
/**
* @author Konstantin Mishin
- *
+ *
*/
public abstract class Field {
- private Expression expression;
-
- public Field(Expression expression) {
- this.expression = expression;
- }
+ private ValueExpression expression;
- public Expression getExpression() {
- return expression;
- }
+ public Field(ValueExpression expression) {
+ this.expression = expression;
+ }
- public void setExpression(Expression expression) {
- this.expression = expression;
- }
+ protected ValueExpression getExpression() {
+ return expression;
+ }
}
Added: root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/FilterField.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/FilterField.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/FilterField.java 2010-03-01 18:28:34 UTC (rev 16513)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.model;
+
+import javax.el.ValueExpression;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class FilterField extends Field{
+
+ private Filter<?> filter;
+
+ private String filterValue;
+
+ public FilterField(ValueExpression filterExpression, Filter<?> filter, String filterValue) {
+ super(filterExpression);
+ this.filter = filter;
+ this.filterValue = filterValue;
+ }
+
+ public ValueExpression getFilterExpression() {
+ return getExpression();
+ }
+
+ public Filter<?> getFilter() {
+ return filter;
+ }
+
+ public String getFilterValue() {
+ return filterValue;
+ }
+}
Added: root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/LocaleAware.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/LocaleAware.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/LocaleAware.java 2010-03-01 18:28:34 UTC (rev 16513)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.model;
+
+import java.util.Locale;
+
+/**
+ * Models that are based on locale-dependent operations should implement this interface
+ *
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+public interface LocaleAware {
+
+ Locale getLocale();
+
+ void setLocale(Locale locale);
+}
Added: root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Modifiable.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Modifiable.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Modifiable.java 2010-03-01 18:28:34 UTC (rev 16513)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.model;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public interface Modifiable {
+
+ void modify(ModifiableState state);
+}
Added: root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ModifiableState.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ModifiableState.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ModifiableState.java 2010-03-01 18:28:34 UTC (rev 16513)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.model;
+
+import java.util.List;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public interface ModifiableState {
+
+ List<FilterField> getFilterFields();
+
+ List<SortField> getSortFields();
+}
Modified: root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/SortField.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/SortField.java 2010-03-01 14:10:38 UTC (rev 16512)
+++ root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/SortField.java 2010-03-01 18:28:34 UTC (rev 16513)
@@ -1,21 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.richfaces.model;
-import javax.el.Expression;
+import java.util.Comparator;
+
+import javax.el.ValueExpression;
import javax.swing.SortOrder;
+/**
+ * @author Konstantin Mishin
+ *
+ */
public class SortField extends Field {
+ private Comparator<?> comparator;
+
private SortOrder sortOrder;
-
- public SortField(SortOrder sortOrder, Expression expression) {
- super(expression);
+
+ public SortField(ValueExpression sortBy, Comparator<?> comparator, SortOrder sortOrder) {
+ super(sortBy);
+ this.comparator = comparator;
this.sortOrder = sortOrder;
}
- public void setSortOrder(SortOrder sortOrder) {
- this.sortOrder = sortOrder;
+ public ValueExpression getSortBy() {
+ return getExpression();
}
+ public Comparator<?> getComparator() {
+ return comparator;
+ }
+
public SortOrder getSortOrder() {
return sortOrder;
}
Added: root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableModel.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableModel.java 2010-03-01 18:28:34 UTC (rev 16513)
@@ -0,0 +1,381 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.model;
+
+import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.model.DataModelListener;
+import javax.swing.SortOrder;
+
+import org.ajax4jsf.model.DataVisitResult;
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SequenceRange;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class ModifiableModel extends ExtendedDataModel<Object> implements Modifiable, LocaleAware {
+
+ protected FacesContext context;
+
+ protected ELContext elContext;
+
+ protected Map<String, Object> requestMap;
+
+ protected ModifiableState state;
+
+ protected List<Object> rowKeys;
+
+ protected ExtendedDataModel<?> originalModel;
+
+ protected String var;
+
+ protected String filterVar;
+
+ protected Locale locale;
+
+ private Comparator<? super String> stringComparator;
+
+ public ModifiableModel(ExtendedDataModel<?> originalModel, String var, String filterVar) {
+ this(FacesContext.getCurrentInstance(), originalModel, var, filterVar);
+ }
+
+ public ModifiableModel(FacesContext context, ExtendedDataModel<?> originalModel, String var, String filterVar) {
+ this.context = context;
+ elContext = context.getELContext();
+ requestMap = context.getExternalContext().getRequestMap();
+ this.originalModel = originalModel;
+ this.var = var;
+ this.filterVar = filterVar;
+ }
+
+ @Override
+ public void addDataModelListener(DataModelListener listener) {
+ originalModel.addDataModelListener(listener);
+ }
+
+ @Override
+ public DataModelListener[] getDataModelListeners() {
+ return originalModel.getDataModelListeners();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
+ */
+ @Override
+ public Object getRowKey() {
+ return originalModel.getRowKey();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
+ */
+ @Override
+ public void setRowKey(Object key) {
+ originalModel.setRowKey(key);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor,
+ * org.ajax4jsf.model.Range, java.lang.Object)
+ */
+ @Override
+ public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) {
+ final SequenceRange seqRange = (SequenceRange) range;
+ int rows = seqRange.getRows();
+ int rowCount = getRowCount();
+ int currentRow = seqRange.getFirstRow();
+ if (rows > 0) {
+ rows += currentRow;
+ rows = Math.min(rows, rowCount);
+ } else {
+ rows = rowCount;
+ }
+ for (; currentRow < rows; currentRow++) {
+ visitor.process(context, rowKeys.get(currentRow), argument);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getRowCount()
+ */
+ @Override
+ public int getRowCount() {
+ if (rowKeys == null) {
+ return -1;
+ } else {
+ return rowKeys.size();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getRowData()
+ */
+ @Override
+ public Object getRowData() {
+ return originalModel.getRowData();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getRowIndex()
+ */
+ @Override
+ public int getRowIndex() {
+ return rowKeys.indexOf(originalModel.getRowKey());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getWrappedData()
+ */
+ @Override
+ public Object getWrappedData() {
+ return originalModel.getWrappedData();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#isRowAvailable()
+ */
+ @Override
+ public boolean isRowAvailable() {
+ return originalModel.isRowAvailable();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#setRowIndex(int)
+ */
+ @Override
+ public void setRowIndex(int rowIndex) {
+ Object originalKey = null;
+ if (rowIndex >= 0 && rowIndex < rowKeys.size()) {
+ originalKey = rowKeys.get(rowIndex);
+ }
+ originalModel.setRowKey(originalKey);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
+ */
+ @Override
+ public void setWrappedData(Object data) {
+ originalModel.setWrappedData(data);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.model.Modifiable#modify(org.richfaces.model.ModifiableState)
+ */
+ public void modify(ModifiableState state) {
+ this.state = state;
+ int rowCount = originalModel.getRowCount();
+
+ if (rowCount > 0) {
+ rowKeys = new ArrayList<Object>(rowCount);
+ } else {
+ rowKeys = new ArrayList<Object>();
+ }
+ Object rowKey = originalModel.getRowKey();
+ originalModel.walk(context, new DataVisitor() {
+ public DataVisitResult process(FacesContext context, Object rowKey, Object argument) {
+ originalModel.setRowKey(rowKey);
+ if (originalModel.isRowAvailable()) {
+ rowKeys.add(rowKey);
+ }
+ return DataVisitResult.CONTINUE;
+ }
+ }, new SequenceRange(0, -1), null);
+ if (this.state != null) {
+ filter();
+ sort();
+ }
+ originalModel.setRowKey(rowKey);
+ }
+
+ protected void filter() {
+ List<FilterField> filterFields = state.getFilterFields();
+ if (filterFields != null && !filterFields.isEmpty()) {
+ List<Object> filteredCollection = new ArrayList<Object>();
+ for (Object rowKey : rowKeys) {
+ if (accept(rowKey)) {
+ filteredCollection.add(rowKey);
+ }
+ }
+ rowKeys = filteredCollection;
+ }
+ }
+
+ protected void sort() {
+ List<SortField> sortFields = state.getSortFields();
+ if (sortFields != null && !sortFields.isEmpty()) {
+ Collections.sort(rowKeys, new Comparator<Object>() {
+ public int compare(Object rowKey1, Object rowKey2) {
+ return ModifiableModel.this.compare(rowKey1, rowKey2);
+ }
+ });
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected boolean accept(Object rowKey) {
+ originalModel.setRowKey(rowKey);
+ Object object = originalModel.getRowData();
+ updateVar(var, object);
+ for (FilterField filterField : state.getFilterFields()) {
+ Filter filter = filterField.getFilter();
+ if (filter != null) {
+ return filter.accept(object);
+ } else {
+ ValueExpression filterExpression = filterField.getFilterExpression();
+ if (filterExpression != null) {
+ updateVar(filterVar, filterField.getFilterValue());
+ if (Boolean.FALSE.equals(filterExpression.getValue(elContext))) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected int compare(Object rowKey1, Object rowKey2) {
+ originalModel.setRowKey(rowKey1);
+ Object object1 = originalModel.getRowData();
+ originalModel.setRowKey(rowKey2);
+ Object object2 = originalModel.getRowData();
+ int result = 0;
+ for (Iterator<SortField> iterator = state.getSortFields().iterator(); iterator.hasNext() && result == 0;) {
+ SortField sortField = iterator.next();
+ SortOrder sortOrder = sortField.getSortOrder();
+ if (sortOrder != null && !SortOrder.UNSORTED.equals(sortOrder)) {
+ Comparator comparator = sortField.getComparator();
+ if (comparator != null) {
+ result = comparator.compare(object1, object2);
+ } else {
+ ValueExpression sortBy = sortField.getSortBy();
+ if (sortBy != null) {
+ updateVar(var, object1);
+ Object value1 = sortBy.getValue(elContext);
+ updateVar(var, object2);
+ Object value2 = sortBy.getValue(elContext);
+ result = compareSortByValues(value1, value2);
+ }
+ }
+ if (SortOrder.DESCENDING.equals(sortOrder)) {
+ result = -result;
+ }
+ }
+ }
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ private int compareSortByValues(Object value1, Object value2) {
+ int result = 0;
+ if (value1 instanceof String && value2 instanceof String) {
+ if (stringComparator == null) {
+ stringComparator = createStringComparator();
+ }
+ result = stringComparator.compare(((String) value1).trim(), ((String) value2).trim());
+ } else if (value1 instanceof Comparable<?>) {
+ result = ((Comparable) value1).compareTo(value2);
+ } else if (value1 == null && value2 != null) {
+ result = -1;
+ } else if (value2 == null && value1 != null) {
+ result = 1;
+ }
+ return result;
+ }
+
+ private Comparator<? super String> createStringComparator() {
+ Comparator<? super String> comparator = null;
+ if (locale != null) {
+ comparator = Collator.getInstance(locale);
+ } else {
+ comparator = new Comparator<String>() {
+ public int compare(String o1, String o2) {
+ return o1.compareToIgnoreCase(o2);
+ }
+ };
+ }
+ return comparator;
+ }
+
+ private void updateVar(String var, Object value) {
+ if (var != null && var.length() > 0) {
+ requestMap.put(var, value);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.model.LocaleAware#getLocale()
+ */
+ public Locale getLocale() {
+ return locale;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.model.LocaleAware#setLocale(java.util.Locale)
+ */
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
+}
Added: root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableStateDefaultImpl.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableStateDefaultImpl.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableStateDefaultImpl.java 2010-03-01 18:28:34 UTC (rev 16513)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.model;
+
+import java.util.List;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class ModifiableStateDefaultImpl implements ModifiableState {
+
+ private List<FilterField> filterFields;
+
+ private List<SortField> sortFields;
+
+ public ModifiableStateDefaultImpl(List<FilterField> filterFields, List<SortField> sortFields) {
+ this.filterFields = filterFields;
+ this.sortFields = sortFields;
+ }
+
+ public List<FilterField> getFilterFields() {
+ return filterFields;
+ }
+
+ public List<SortField> getSortFields() {
+ return sortFields;
+ }
+}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumn.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumn.java 2010-03-01 14:10:38 UTC (rev 16512)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIColumn.java 2010-03-01 18:28:34 UTC (rev 16513)
@@ -1,33 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.richfaces.component;
+import java.util.Comparator;
+import java.util.Map;
+
+import javax.el.ValueExpression;
import javax.swing.SortOrder;
+import org.richfaces.model.Filter;
+import org.richfaces.model.FilterField;
+import org.richfaces.model.SortField;
public abstract class UIColumn extends javax.faces.component.UIColumn implements Column {
-
- private SortOrder sortOrder;
-
+
public abstract int getRowspan();
public abstract int getColspan();
public abstract boolean isBreakBefore();
-
+
public abstract boolean isSelfSorted();
-
+
public abstract void setSortOrder(SortOrder sortOrder);
-
+
public abstract SortOrder getSortOrder();
-
-
- public SortOrder toggleSortOrder(){
- if(SortOrder.ASCENDING.equals(getSortOrder())) {
- sortOrder = SortOrder.DESCENDING;
- } else {
- sortOrder = SortOrder.ASCENDING;
- }
-
- return sortOrder;
+
+ public FilterField getFilterField() {
+ FilterField field = null;
+ Map<String, Object> attributes = getAttributes();
+ Filter<?> filter = (Filter<?>) attributes.get("filter");
+ ValueExpression filterExpression = getValueExpression("filterExpression");
+ if (filter != null || filterExpression != null) {
+ field = new FilterField(filterExpression, filter, (String) attributes.get("filterValue"));
+ }
+ return field;
}
-
+
+ public SortField getSortField() {
+ SortField field = null;
+ SortOrder sortOrder = getSortOrder();
+ if (sortOrder != null && !SortOrder.UNSORTED.equals(sortOrder)) {
+ Comparator<?> comparator = (Comparator<?>) getAttributes().get("comparator");
+ ValueExpression sortBy = getValueExpression("sortBy");
+ if (comparator != null || sortBy != null) {
+ field = new SortField(sortBy, comparator, sortOrder);
+ }
+ }
+ return field;
+ }
+
}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-03-01 14:10:38 UTC (rev 16512)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-03-01 18:28:34 UTC (rev 16513)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.richfaces.component;
import java.util.Collection;
@@ -2,5 +24,20 @@
import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import org.ajax4jsf.context.ContextInitParameters;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.richfaces.model.FilterField;
+import org.richfaces.model.LocaleAware;
+import org.richfaces.model.Modifiable;
+import org.richfaces.model.ModifiableModel;
+import org.richfaces.model.ModifiableState;
+import org.richfaces.model.ModifiableStateDefaultImpl;
+import org.richfaces.model.SortField;
import org.richfaces.model.SortMode;
@@ -30,19 +67,80 @@
public UIComponent getFooter() {
return getFacet("footer");
}
-
- @Override
- public boolean getRendersChildren() {
+
+ @Override
+ public boolean getRendersChildren() {
return true;
- }
-
- public abstract SortMode getSortMode();
-
- public abstract void setSortMode(SortMode sortMode);
-
- public abstract Collection <Object> getSortPriority();
-
- public abstract void setSortPriority(Collection<Object> sortPriority);
-
+ }
+ public abstract SortMode getSortMode();
+
+ public abstract void setSortMode(SortMode sortMode);
+
+ public abstract Collection<Object> getSortPriority();
+
+ public abstract void setSortPriority(Collection<Object> sortPriority);
+
+ @Override
+ protected ExtendedDataModel<?> createExtendedDataModel() {
+ ExtendedDataModel<?> dataModel = super.createExtendedDataModel();
+ Modifiable modifiable = null;
+ ModifiableState modifiableState = createModifiableState();
+ if (dataModel instanceof Modifiable) {
+ modifiable = (Modifiable) dataModel;
+ } else if (modifiableState != null) {
+ ModifiableModel modifiableModel = new ModifiableModel(dataModel, getVar(), (String) getAttributes().get(
+ "filterVar"));
+ dataModel = modifiableModel;
+ modifiable = modifiableModel;
+ }
+
+ if (dataModel instanceof LocaleAware) {
+ FacesContext facesContext = getFacesContext();
+ if (ContextInitParameters.isDatatableUsesViewLocale(facesContext)) {
+ UIViewRoot viewRoot = facesContext.getViewRoot();
+ ((LocaleAware) dataModel).setLocale(viewRoot.getLocale());
+ }
+ }
+
+ if (modifiable != null) {
+ modifiable.modify(modifiableState);
+ }
+ return dataModel;
+ }
+
+ private ModifiableState createModifiableState() {
+ ModifiableState modifiableState = null;
+ List<FilterField> filterFields = new LinkedList<FilterField>();
+ Map<Object, SortField> sortFieldsMap = new LinkedHashMap<Object, SortField>();
+ for (UIComponent component : getChildren()) {
+ if (component instanceof UIColumn && component.isRendered()) {
+ UIColumn column = (UIColumn) component;
+ FilterField filterField = column.getFilterField();
+ if (filterField != null) {
+ filterFields.add(filterField);
+ }
+ SortField sortField = column.getSortField();
+ if (sortField != null) {
+ sortFieldsMap.put(component.getId(), sortField);
+ }
+ }
+ }
+ List<SortField> sortFields = new LinkedList<SortField>();
+ Collection<Object> sortPriority = getSortPriority();
+ if (sortPriority != null) {
+ for (Object object : sortPriority) {
+ SortField sortField = sortFieldsMap.get(object);
+ if (sortField != null) {
+ sortFields.add(sortField);
+ sortFieldsMap.remove(object);
+ }
+ }
+ }
+ sortFields.addAll(sortFieldsMap.values());
+ if (!filterFields.isEmpty() || !sortFields.isEmpty()) {
+ modifiableState = new ModifiableStateDefaultImpl(filterFields, sortFields);
+ }
+ return modifiableState;
+ }
}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumn.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumn.java 2010-03-01 14:10:38 UTC (rev 16512)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlColumn.java 2010-03-01 18:28:34 UTC (rev 16513)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.richfaces.component.html;
import javax.swing.SortOrder;
@@ -33,7 +55,7 @@
@Override
public SortOrder getSortOrder() {
- return (SortOrder) getStateHelper().eval(PropertyKeys.sortOrder,SortOrder.DESCENDING);
+ return (SortOrder) getStateHelper().eval(PropertyKeys.sortOrder,SortOrder.UNSORTED);
}
@Override
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-03-01 14:10:38 UTC (rev 16512)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-03-01 18:28:34 UTC (rev 16513)
@@ -1,10 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.richfaces.renderkit;
import java.io.IOException;
-import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.Map;
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
@@ -19,8 +39,6 @@
import org.richfaces.component.Row;
import org.richfaces.component.UIDataTable;
import org.richfaces.component.UIDataTableBase;
-import org.richfaces.event.SortingEvent;
-import org.richfaces.model.SortMode;
@ResourceDependencies( { @ResourceDependency(library = "javax.faces", name = "jsf-uncompressed.js"),
@ResourceDependency(name = "jquery.js"), @ResourceDependency(name = "richfaces.js"),
@@ -28,49 +46,6 @@
@ResourceDependency(name = "table.css") })
public class DataTableRenderer extends AbstractTableRenderer {
-
- @Override
- protected void doDecode(FacesContext context, UIComponent component) {
- Map<String, String> requestMap = context.getExternalContext().getRequestParameterMap();
-
- //decode column
-
- UIDataTable dataTable = (UIDataTable)component;
-
- String sortColumn = requestMap.get(dataTable.getClientId()+":sort");
-
- if(sortColumn != null && sortColumn.trim().length() > 0) {
- Collection<Object> sortPriority = dataTable.getSortPriority();
-
- boolean isSingle = SortMode.single.equals(dataTable.getSortMode());
-
- if(isSingle) {
- //reset saved sort priorities
- sortPriority.clear();
- }
-
- Iterator<UIComponent> columns = dataTable.columns();
- while(columns.hasNext()) {
-
- UIComponent column = columns.next();
-
- if(column instanceof org.richfaces.component.UIColumn && isSortable((org.richfaces.component.UIColumn)column)) {
-
- org.richfaces.component.UIColumn sortableColumn = (org.richfaces.component.UIColumn)column;
-
- if(sortableColumn.getClientId().equals(sortColumn)) {
- SortOrder newSortOrder = sortableColumn.toggleSortOrder();
- new SortingEvent(dataTable, column.getClientId(context), newSortOrder).queue();
- sortPriority.add(sortColumn);
- } else if(isSingle) {
- sortableColumn.setSortOrder(SortOrder.UNSORTED);
- }
-
- }
- }
- }
- }
-
public void encodeTableStructure(ResponseWriter writer, FacesContext context, UIDataTableBase dataTable)
throws IOException {
14 years, 2 months
JBoss Rich Faces SVN: r16512 - root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-03-01 09:10:38 -0500 (Mon, 01 Mar 2010)
New Revision: 16512
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java
Log:
https://jira.jboss.org/jira/browse/RF-8232
Tags support - generate Taglib and TagHandlers
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java 2010-03-01 13:46:18 UTC (rev 16511)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java 2010-03-01 14:10:38 UTC (rev 16512)
@@ -36,7 +36,7 @@
protected File outputTestResourcesDirectory = new File(PROJECT_BASE + "target/generated-sources/test/resources");
@Test
-// @Ignore
+ @Ignore
public void createInstance() throws Exception {
List<String> compileSourceRoots = Arrays.asList("");
14 years, 2 months
JBoss Rich Faces SVN: r16511 - root/cdk/trunk.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-03-01 08:46:18 -0500 (Mon, 01 Mar 2010)
New Revision: 16511
Modified:
root/cdk/trunk/pom.xml
Log:
https://jira.jboss.org/jira/browse/RF-8232
Tags support - generate Taglib and TagHandlers
Modified: root/cdk/trunk/pom.xml
===================================================================
--- root/cdk/trunk/pom.xml 2010-03-01 13:44:09 UTC (rev 16510)
+++ root/cdk/trunk/pom.xml 2010-03-01 13:46:18 UTC (rev 16511)
@@ -104,12 +104,6 @@
<build>
<plugins>
<plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <forkMode>never</forkMode>
- </configuration>
- </plugin>
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
14 years, 2 months
JBoss Rich Faces SVN: r16510 - in root: framework/trunk/commons/src/main/java/org/richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-03-01 08:44:09 -0500 (Mon, 01 Mar 2010)
New Revision: 16510
Added:
root/framework/trunk/commons/src/main/java/org/richfaces/MethodMetadata.java
root/framework/trunk/commons/src/main/java/org/richfaces/PartialStateHolderHelper.java
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
Log:
https://jira.jboss.org/jira/browse/RF-8232
Tags support - generate Taglib and TagHandlers
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2010-03-01 13:40:54 UTC (rev 16509)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2010-03-01 13:44:09 UTC (rev 16510)
@@ -379,7 +379,7 @@
/**
* Skan Array of filesets for selected resources.
*
- * @param fileset
+ * @param filesets
* @return
* @throws MojoExecutionException
*/
Added: root/framework/trunk/commons/src/main/java/org/richfaces/MethodMetadata.java
===================================================================
--- root/framework/trunk/commons/src/main/java/org/richfaces/MethodMetadata.java (rev 0)
+++ root/framework/trunk/commons/src/main/java/org/richfaces/MethodMetadata.java 2010-03-01 13:44:09 UTC (rev 16510)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces;
+
+import javax.el.MethodExpression;
+import javax.faces.application.Application;
+import javax.faces.el.MethodBinding;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.TagAttribute;
+
+/**
+ * @author akolonitsky
+ * @since Feb 24, 2010
+ */
+public abstract class MethodMetadata extends Metadata {
+ protected final Class[] signature;
+
+ protected final TagAttribute attribute;
+
+ public MethodMetadata(TagAttribute attribute, Class ... signature) {
+ this.attribute = attribute;
+ this.signature = signature;
+ }
+
+ protected MethodExpression getMethodExpression(FaceletContext ctx) {
+ return this.attribute.getMethodExpression(ctx, null, signature);
+ }
+
+ protected MethodBinding getMethodBinding(FaceletContext ctx) {
+ MethodExpression expression = this.attribute.getMethodExpression(ctx, null, signature);
+ Application application = ctx.getFacesContext().getApplication();
+ return application.createMethodBinding(expression.getExpressionString(), signature); // TODO expression.getExpressionString() ???
+ }
+
+}
Added: root/framework/trunk/commons/src/main/java/org/richfaces/PartialStateHolderHelper.java
===================================================================
--- root/framework/trunk/commons/src/main/java/org/richfaces/PartialStateHolderHelper.java (rev 0)
+++ root/framework/trunk/commons/src/main/java/org/richfaces/PartialStateHolderHelper.java 2010-03-01 13:44:09 UTC (rev 16510)
@@ -0,0 +1,426 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces;
+
+import javax.faces.component.PartialStateHolder;
+import javax.faces.component.StateHelper;
+import javax.faces.component.StateHolder;
+import static javax.faces.component.UIComponentBase.restoreAttachedState;
+import static javax.faces.component.UIComponentBase.saveAttachedState;
+import javax.faces.context.FacesContext;
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * @author akolonitsky
+ * @since Feb 2, 2010
+ *
+ * A base implementation for
+ * maps which implement the PartialStateHolder interface.
+ * <p/>
+ * This can be used as a base-class for all
+ * state-holder implementations in components,
+ * converters and validators and other implementations
+ * of the StateHolder interface.
+ */
+@SuppressWarnings({"unchecked"})
+public class PartialStateHolderHelper implements StateHelper {
+
+ private PartialStateHolder stateHolder;
+ private boolean isTransient;
+ private Map<Serializable, Object> deltaMap;
+ private Map<Serializable, Object> defaultMap;
+
+ // ------------------------------------------------------------ Constructors
+
+
+ public PartialStateHolderHelper(PartialStateHolder stateHolder) {
+
+ this.stateHolder = stateHolder;
+ this.deltaMap = new HashMap<Serializable, Object>();
+ this.defaultMap = new HashMap<Serializable, Object>();
+
+ }
+
+
+ // ------------------------------------------------ Methods from StateHelper
+
+
+ /**
+ * Put the object in the main-map
+ * and/or the delta-map, if necessary.
+ *
+ * @param key
+ * @param value
+ * @return the original value in the delta-map, if not present, the old value in the main map
+ */
+ public Object put(Serializable key, Object value) {
+
+ if (stateHolder.initialStateMarked() || value instanceof PartialStateHolder) {
+ Object retVal = deltaMap.put(key, value);
+
+ if (retVal == null) {
+ return defaultMap.put(key, value);
+ } else {
+ defaultMap.put(key, value);
+ return retVal;
+ }
+ } else {
+ return defaultMap.put(key, value);
+ }
+ }
+
+
+ /**
+ * We need to remove from both
+ * maps, if we do remove an existing key.
+ *
+ * @param key
+ * @return the removed object in the delta-map. if not present, the removed object from the main map
+ */
+ public Object remove(Serializable key) {
+ if (stateHolder.initialStateMarked()) {
+ Object retVal = deltaMap.remove(key);
+
+ if (retVal == null) {
+ return defaultMap.remove(key);
+ } else {
+ defaultMap.remove(key);
+ return retVal;
+ }
+ } else {
+ return defaultMap.remove(key);
+ }
+ }
+
+
+ /**
+ * @see StateHelper#put(java.io.Serializable, String, Object)
+ */
+ public Object put(Serializable key, String mapKey, Object value) {
+
+ Object ret = null;
+ if (stateHolder.initialStateMarked()) {
+ Map<String, Object> dMap = (Map<String, Object>) deltaMap.get(key);
+ if (dMap == null) {
+ dMap = new HashMap<String, Object>(5);
+ deltaMap.put(key, dMap);
+ }
+ ret = dMap.put(mapKey, value);
+
+ }
+ Map<String, Object> map = (Map<String, Object>) get(key);
+ if (map == null) {
+ map = new HashMap<String, Object>(8);
+ defaultMap.put(key, map);
+ }
+ if (ret == null) {
+ return map.put(mapKey, value);
+ } else {
+ map.put(mapKey, value);
+ return ret;
+ }
+
+ }
+
+
+ /**
+ * Get the object from the main-map.
+ * As everything is written through
+ * from the delta-map to the main-map, this
+ * should be enough.
+ *
+ * @param key
+ * @return
+ */
+ public Object get(Serializable key) {
+ return defaultMap.get(key);
+ }
+
+
+ /**
+ * @see StateHelper#eval(java.io.Serializable)
+ */
+ public Object eval(Serializable key) {
+ return eval(key, null);
+ }
+
+
+ /**
+ * @see StateHelper#eval(java.io.Serializable, Object)
+ */
+ public Object eval(Serializable key, Object defaultValue) {
+ Object retVal = get(key);
+ if (retVal == null) {
+ retVal = getValueExpressionValue();
+ }
+
+ return (retVal != null) ? retVal : defaultValue;
+ }
+
+ protected Object getValueExpressionValue() {
+ return null;
+
+// ValueExpression ve = stateHolder.getValueExpression(key.toString());
+// if (ve != null) {
+// retVal = ve.getValue(stateHolder.getFacesContext().getELContext());
+// }
+ }
+
+
+ /**
+ * @see StateHelper#add(java.io.Serializable, Object)
+ */
+ public void add(Serializable key, Object value) {
+
+ if (stateHolder.initialStateMarked()) {
+ List<Object> deltaList = (List<Object>) deltaMap.get(key);
+ if (deltaList == null) {
+ deltaList = new ArrayList<Object>(4);
+ deltaMap.put(key, deltaList);
+ }
+ deltaList.add(value);
+ }
+ List<Object> items = (List<Object>) get(key);
+ if (items == null) {
+ items = new ArrayList<Object>(4);
+ defaultMap.put(key, items);
+ }
+ items.add(value);
+
+ }
+
+
+ /**
+ * @see StateHelper#remove(java.io.Serializable, Object)
+ */
+ public Object remove(Serializable key, Object valueOrKey) {
+ Object source = get(key);
+ if (source instanceof Collection) {
+ return removeFromList(key, valueOrKey);
+ } else if (source instanceof Map) {
+ return removeFromMap(key, valueOrKey.toString());
+ }
+ return null;
+ }
+
+
+ // ------------------------------------------------ Methods from StateHolder
+
+
+ /**
+ * One and only implementation of
+ * save-state - makes all other implementations
+ * unnecessary.
+ *
+ * @param context
+ * @return the saved state
+ */
+ public Object saveState(FacesContext context) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (stateHolder.initialStateMarked()) {
+ return saveMap(context, deltaMap);
+ } else {
+ return saveMap(context, defaultMap);
+ }
+ }
+
+
+ /**
+ * One and only implementation of
+ * restore state. Makes all other implementations
+ * unnecessary.
+ *
+ * @param context FacesContext
+ * @param state the state to be restored.
+ */
+ public void restoreState(FacesContext context, Object state) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (state == null) {
+ return;
+ }
+ Object[] savedState = (Object[]) state;
+ if (savedState[savedState.length - 1] != null) {
+ if ((Boolean) savedState[savedState.length - 1]) {
+ stateHolder.markInitialState();
+ } else {
+ stateHolder.clearInitialState();
+ }
+ }
+
+ int length = (savedState.length - 1) / 2;
+ for (int i = 0; i < length; i++) {
+ Object value = savedState[i * 2 + 1];
+ if (Void.TYPE.equals(value)) {
+ value = null;
+ }
+ Serializable serializable = (Serializable) savedState[i * 2];
+ if (value != null) {
+ if (value instanceof Collection) {
+ value = restoreAttachedState(context, value);
+ /*} else if (value instanceof StateHolderSaver) {
+ value = ((StateHolderSaver) value).restore(context);*/
+ } else {
+ value = value instanceof Serializable
+ ? value
+ : restoreAttachedState(context, value);
+ }
+ }
+ if (value instanceof Map) {
+ for (Map.Entry<String, Object> entry : ((Map<String, Object>) value)
+ .entrySet()) {
+ this.put(serializable, entry.getKey(), entry.getValue());
+ }
+ } else if (value instanceof List) {
+ List<Object> list = (List) get(serializable);
+ for (Object o : (List<Object>) value) {
+ if (list == null || !list.contains(o)) {
+ this.add(serializable, o);
+ }
+ }
+ } else {
+ put(serializable, value);
+ }
+ }
+ }
+
+
+ /**
+ * @see javax.faces.component.StateHolder#isTransient()
+ */
+ public boolean isTransient() {
+ return isTransient;
+ }
+
+
+ /**
+ * @see javax.faces.component.StateHolder#setTransient(boolean)
+ */
+ public void setTransient(boolean newTransientValue) {
+ isTransient = newTransientValue;
+ }
+
+
+ // --------------------------------------------------------- Private Methods
+
+
+ private Object saveMap(FacesContext context, Map<Serializable, Object> map) {
+
+ if (map.isEmpty()) {
+ if (!stateHolder.initialStateMarked()) {
+ // only need to propagate the stateHolder's delta status when
+ // delta tracking has been disabled. We're assuming that
+ // the VDL will reset the status when the view is reconstructed,
+ // so no need to save the state if the saved state is the default.
+ return new Object[]{stateHolder.initialStateMarked()};
+ }
+ return null;
+ }
+
+ Object[] savedState = new Object[map.size() * 2 + 1];
+
+ int i = 0;
+
+ for (Map.Entry<Serializable, Object> entry : map.entrySet()) {
+ Object value = entry.getValue();
+ if (value == null) {
+ value = Void.TYPE;
+ }
+ savedState[i * 2] = entry.getKey();
+ if (value instanceof Collection
+ || value instanceof StateHolder
+ || !(value instanceof Serializable)) {
+ value = saveAttachedState(context, value);
+ }
+ savedState[i * 2 + 1] = value;
+ i++;
+ }
+ if (!stateHolder.initialStateMarked()) {
+ savedState[savedState.length - 1] = stateHolder.initialStateMarked();
+ }
+ return savedState;
+
+ }
+
+
+ private Object removeFromList(Serializable key, Object value) {
+ Object ret = null;
+ if (stateHolder.initialStateMarked() || value instanceof PartialStateHolder) {
+ Collection<Object> deltaList = (Collection<Object>) deltaMap.get(key);
+ if (deltaList != null) {
+ ret = deltaList.remove(value);
+ if (deltaList.isEmpty()) {
+ deltaMap.remove(key);
+ }
+ }
+ }
+ Collection<Object> list = (Collection<Object>) get(key);
+ if (list != null) {
+ if (ret == null) {
+ ret = list.remove(value);
+ } else {
+ list.remove(value);
+ }
+ if (list.isEmpty()) {
+ defaultMap.remove(key);
+ }
+ }
+ return ret;
+ }
+
+
+ private Object removeFromMap(Serializable key, String mapKey) {
+ Object ret = null;
+ if (stateHolder.initialStateMarked()) {
+ Map<String, Object> dMap = (Map<String, Object>) deltaMap.get(key);
+ if (dMap != null) {
+ ret = dMap.remove(mapKey);
+ if (dMap.isEmpty()) {
+ deltaMap.remove(key);
+ }
+ }
+ }
+ Map<String, Object> map = (Map<String, Object>) get(key);
+ if (map != null) {
+ if (ret == null) {
+ ret = map.remove(mapKey);
+ } else {
+ map.remove(mapKey);
+
+ }
+ if (map.isEmpty()) {
+ defaultMap.remove(key);
+ }
+ }
+ if (ret != null && !stateHolder.initialStateMarked()) {
+ deltaMap.remove(key);
+ }
+ return ret;
+ }
+
+}
14 years, 2 months