JBoss Rich Faces SVN: r7348 - trunk/samples/dataFilterSliderDemo.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-03-28 01:04:47 -0400 (Fri, 28 Mar 2008)
New Revision: 7348
Modified:
trunk/samples/dataFilterSliderDemo/pom.xml
Log:
http://jira.jboss.com/jira/browse/RF-2808
Modified: trunk/samples/dataFilterSliderDemo/pom.xml
===================================================================
--- trunk/samples/dataFilterSliderDemo/pom.xml 2008-03-28 05:03:53 UTC (rev 7347)
+++ trunk/samples/dataFilterSliderDemo/pom.xml 2008-03-28 05:04:47 UTC (rev 7348)
@@ -13,11 +13,6 @@
<dependencies>
<dependency>
<groupId>org.richfaces.ui</groupId>
- <artifactId>richfaces-ui</artifactId>
- <version>3.2.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.richfaces.ui</groupId>
<artifactId>dataFilterSlider</artifactId>
<version>3.2.0-SNAPSHOT</version>
</dependency>
16 years, 9 months
JBoss Rich Faces SVN: r7347 - in trunk/ui: dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/scripts and 6 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-03-28 01:03:53 -0400 (Fri, 28 Mar 2008)
New Revision: 7347
Added:
trunk/ui/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/scripts/datafilterslider.js
Removed:
trunk/ui/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/scripts/scriptaculous-js-1.6.5/
Modified:
trunk/ui/dataFilterSlider/src/main/java/org/richfaces/renderkit/DataFilterSliderRendererBase.java
trunk/ui/dataFilterSlider/src/main/templates/dataFilterSlider.jspx
trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java
trunk/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java
trunk/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/Control.js
trunk/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js
trunk/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java
Log:
http://jira.jboss.com/jira/browse/RF-2808
Modified: trunk/ui/dataFilterSlider/src/main/java/org/richfaces/renderkit/DataFilterSliderRendererBase.java
===================================================================
--- trunk/ui/dataFilterSlider/src/main/java/org/richfaces/renderkit/DataFilterSliderRendererBase.java 2008-03-28 04:33:13 UTC (rev 7346)
+++ trunk/ui/dataFilterSlider/src/main/java/org/richfaces/renderkit/DataFilterSliderRendererBase.java 2008-03-28 05:03:53 UTC (rev 7347)
@@ -102,7 +102,7 @@
JSReference reference = new JSReference(options.toString());
- JSFunction function = new JSFunction("Control.Slider");
+ JSFunction function = new JSFunction("Richfaces.DFSControl.Slider");
function.addParameter(clientId + "slider-handle");
function.addParameter(clientId + "slider-track");
function.addParameter(reference);
Added: trunk/ui/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/scripts/datafilterslider.js
===================================================================
--- trunk/ui/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/scripts/datafilterslider.js (rev 0)
+++ trunk/ui/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/scripts/datafilterslider.js 2008-03-28 05:03:53 UTC (rev 7347)
@@ -0,0 +1,362 @@
+// script.aculo.us slider.js v1.6.5, Wed Nov 08 14:17:49 CET 2006
+
+// Copyright (c) 2005, 2006 Marty Haught, Thomas Fuchs
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+if (!window.Richfaces) {
+ window.Richfaces = {};
+}
+Richfaces.DFSControl = {};
+Richfaces.DFSControl.Slider = Class.create();
+
+// options:
+// axis: 'vertical', or 'horizontal' (default)
+//
+// callbacks:
+// onChange(value)
+// onSlide(value)
+Richfaces.DFSControl.Slider.prototype = {
+ initialize: function(handle, track, options) {
+ var slider = this;
+
+ if(handle instanceof Array) {
+ this.handles = handle.collect( function(e) { return $(e) });
+ } else {
+ this.handles = [$(handle)];
+ }
+
+ this.track = $(track);
+ this.options = options || {};
+ this.flag = false;
+
+ this.axis = this.options.axis || 'horizontal';
+ this.increment = this.options.increment || 1;
+ this.step = parseInt(this.options.step || '1');
+ this.range = this.options.range || $R(0,1);
+
+ this.value = 0; // assure backwards compat
+ this.values = this.handles.map( function() { return 0 });
+ this.spans = this.options.spans ? this.options.spans.map(function(s){ return $(s) }) : false;
+ this.options.startSpan = $(this.options.startSpan || null);
+ this.options.endSpan = $(this.options.endSpan || null);
+ this.sliderInput = $(this.options.sliderInputId);
+
+ this.restricted = this.options.restricted || false;
+
+ this.maximum = this.options.maximum || this.range.end;
+ this.minimum = this.options.minimum || this.range.start;
+
+ // Will be used to align the handle onto the track, if necessary
+ this.alignX = parseInt(this.options.alignX || '0');
+ this.alignY = parseInt(this.options.alignY || '0');
+
+ this.trackLength = this.maximumOffset() - this.minimumOffset();
+
+
+ this.active = false;
+ this.dragging = false;
+ this.disabled = false;
+
+ if(this.options.disabled) this.setDisabled();
+
+ // Allowed values array
+ this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;
+ if (this.allowedValues && this.allowedValues.length > 0) {
+ this.minimum = this.allowedValues.min();
+ this.maximum = this.allowedValues.max();
+ }
+
+ this.eventMouseDown = this.startDrag.bindAsEventListener(this);
+ this.eventMouseUp = this.endDrag.bindAsEventListener(this);
+ this.eventMouseMove = this.update.bindAsEventListener(this);
+
+ Event.observe(this.track, "mousedown", this.eventMouseDown);
+ Event.observe(document, "mouseup", this.eventMouseUp);
+ Event.observe(document, "mousemove", this.eventMouseMove);
+ // Initialize handles in reverse (make sure first handle is active)
+ this.handles[0].style.visibility="hidden";
+ setTimeout(this.initHandles.bind(this), 100);
+ this.initialized = true;
+
+ },
+ initHandles: function() {
+ this.handleLength = this.isVertical() ?
+ (this.handles[0].offsetHeight != 0 ?
+ this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/,"")) :
+ (this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth :
+ this.handles[0].style.width.replace(/px$/,""));
+
+ var slider = this;
+ this.handles.each( function(h,i) {
+ i = slider.handles.length-1-i;
+ slider.setValue(parseFloat(
+ (slider.options.sliderValue instanceof Array ?
+ slider.options.sliderValue[i] : slider.options.sliderValue) ||
+ slider.range.start), i);
+ Element.makePositioned(h); // fix IE
+ Event.observe(h, "mousedown", slider.eventMouseDown);
+ });
+ this.handles[0].style.visibility="";
+ },
+ dispose: function() {
+ var slider = this;
+ Event.stopObserving(this.track, "mousedown", this.eventMouseDown);
+ Event.stopObserving(document, "mouseup", this.eventMouseUp);
+ Event.stopObserving(document, "mousemove", this.eventMouseMove);
+ this.handles.each( function(h) {
+ Event.stopObserving(h, "mousedown", slider.eventMouseDown);
+ });
+ },
+ setDisabled: function(){
+ this.disabled = true;
+ },
+ setEnabled: function(){
+ this.disabled = false;
+ },
+ getNearestValue: function(value){
+ if (this.allowedValues && this.allowedValues.length > 0) {
+ if(value >= this.allowedValues.max()) return(this.allowedValues.max());
+ if(value <= this.allowedValues.min()) return(this.allowedValues.min());
+
+ var offset = Math.abs(this.allowedValues[0] - value);
+ var newValue = this.allowedValues[0];
+ this.allowedValues.each( function(v) {
+ var currentOffset = Math.abs(v - value);
+ if(currentOffset <= offset){
+ newValue = v;
+ offset = currentOffset;
+ }
+ });
+ return newValue;
+ }
+ if(value > this.range.end) {
+ return this.range.end;
+ } else if(value < this.range.start) {
+ return this.range.start;
+ } else {
+ return parseInt(value);
+ }
+ },
+ setValue: function(sliderValue, handleIdx){
+ if(!this.active) {
+ this.activeHandleIdx = handleIdx || 0;
+ this.activeHandle = this.handles[this.activeHandleIdx];
+ this.updateStyles();
+ }
+ handleIdx = handleIdx || this.activeHandleIdx || 0;
+ if(this.initialized && this.restricted) {
+ if((handleIdx>0) && (sliderValue<this.values[handleIdx-1]))
+ sliderValue = this.values[handleIdx-1];
+ if((handleIdx < (this.handles.length-1)) && (sliderValue>this.values[handleIdx+1]))
+ sliderValue = this.values[handleIdx+1];
+ }
+ sliderValue = this.getNearestValue(sliderValue);
+ this.values[handleIdx] = sliderValue;
+ this.value = this.values[0]; // assure backwards compat
+
+ if (!isNaN(sliderValue)) {
+ this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =
+ this.translateToPx(sliderValue);
+ }
+
+ this.drawSpans();
+ if((!this.dragging || !this.event)&&this.flag) this.updateFinished();
+ this.flag = true;
+ },
+ setValueBy: function(delta, handleIdx) {
+ this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta,
+ handleIdx || this.activeHandleIdx || 0);
+ },
+ translateToPx: function(value) {
+ return Math.round(
+ ((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) *
+ (value - this.range.start)) + "px";
+ },
+ translateToValue: function(offset) {
+ return ((offset/(this.trackLength-this.handleLength) *
+ (this.range.end-this.range.start)) + this.range.start);
+ },
+ getRange: function(range) {
+ var v = this.values.sortBy(Prototype.K);
+ range = range || 0;
+ return $R(v[range],v[range+1]);
+ },
+ minimumOffset: function(){
+ return(this.isVertical() ? this.alignY : this.alignX);
+ },
+ maximumOffset: function(){
+ return(this.isVertical() ?
+ (this.track.offsetHeight != 0 ? this.track.offsetHeight :
+ this.track.style.height.replace(/px$/,"")) - this.alignY :
+ (this.track.offsetWidth != 0 ? this.track.offsetWidth :
+ this.track.style.width.replace(/px$/,"")) - this.alignY);
+ },
+ isVertical: function(){
+ return (this.axis == 'vertical');
+ },
+ drawSpans: function() {
+ var slider = this;
+ if(this.spans)
+ $R(0, this.spans.length-1).each(function(r) { slider.setSpan(slider.spans[r], slider.getRange(r)) });
+ if(this.options.startSpan)
+ this.setSpan(this.options.startSpan,
+ $R(0, this.values.length>1 ? this.getRange(0).min() : this.value ));
+ if(this.options.endSpan)
+ this.setSpan(this.options.endSpan,
+ $R(this.values.length>1 ? this.getRange(this.spans.length-1).max() : this.value, this.maximum));
+ },
+ setSpan: function(span, range) {
+ if(this.isVertical()) {
+ span.style.top = this.translateToPx(range.start);
+ span.style.height = this.translateToPx(range.end - range.start + this.range.start);
+ } else {
+ span.style.left = this.translateToPx(range.start);
+
+ this.handles.each(function(h) {
+ span.style.width = $(h.id).offsetLeft + 'px';
+ });
+
+ //original code from prototype 1.6.5
+ //span.style.width = this.translateToPx(range.end - range.start + this.range.start);
+ }
+ },
+ updateStyles: function() {
+ this.handles.each( function(h){ Element.removeClassName(h, 'selected') });
+ Element.addClassName(this.activeHandle, 'selected');
+ },
+ startDrag: function(event) {
+ if(Event.isLeftClick(event)) {
+ if(!this.disabled){
+ this.active = true;
+
+ var handle = Event.element(event);
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var track = handle;
+ if(track==this.track) {
+ var offsets = Position.cumulativeOffset(this.track);
+ this.event = event;
+ this.setValue(this.translateToValue(
+ (this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2)
+ ));
+ var offsets = Position.cumulativeOffset(this.activeHandle);
+ this.offsetX = (pointer[0] - offsets[0]);
+ this.offsetY = (pointer[1] - offsets[1]);
+ } else {
+ // find the handle (prevents issues with Safari)
+ while((this.handles.indexOf(handle) == -1) && handle.parentNode)
+ handle = handle.parentNode;
+
+ if(this.handles.indexOf(handle)!=-1) {
+ this.activeHandle = handle;
+ this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
+ this.updateStyles();
+
+ var offsets = Position.cumulativeOffset(this.activeHandle);
+ this.offsetX = (pointer[0] - offsets[0]);
+ this.offsetY = (pointer[1] - offsets[1]);
+ }
+ }
+ }
+ Event.stop(event);
+ }
+ },
+ update: function(event) {
+ if(this.active) {
+ if(!this.dragging) this.dragging = true;
+ this.draw(event);
+
+ // fix AppleWebKit rendering
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
+ Event.stop(event);
+ }
+ },
+ draw: function(event) {
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var offsets = Position.cumulativeOffset(this.track);
+ pointer[0] -= this.offsetX + offsets[0];
+ pointer[1] -= this.offsetY + offsets[1];
+ this.event = event;
+ var value = this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] );
+ if(this.invokeEvent("slide",event,value,this.sliderInput)){
+ this.setValue(value);
+ }
+ if(this.initialized) {
+ if (this.options.onSlideSubmit) {
+ this.options.onSlideSubmit(event,this.values.length>1 ? this.values : this.values[0], this);
+ }
+ }
+
+ },
+ endDrag: function(event) {
+ if(this.active && this.dragging) {
+ this.finishDrag(event, true);
+ Event.stop(event);
+ }
+ this.active = false;
+ this.dragging = false;
+ },
+ finishDrag: function(event, success) {
+ this.active = false;
+ this.dragging = false;
+
+ this.updateFinished(event);
+ },
+ updateFinished: function(event) {
+ if(this.initialized) {
+ var value = this.values.length>1 ? this.values : this.values[0];
+ if (this.options.onSlideSubmit) {
+ this.options.onSlideSubmit(event, value, this);
+ }
+ }
+
+ this.event = null;
+ },
+
+ valueChanged: function(event,value){
+ if(this.invokeEvent("change",event,value,this.sliderInput)){
+ this.setValue(value);
+ }
+ },
+
+ invokeEvent: function(eventName, event, value, element) {
+
+ var eventFunction = this.options['on'+eventName];
+ var result;
+
+ if (eventFunction)
+ {
+ var eventObj;
+
+ if (event)
+ {
+ eventObj = event;
+ }
+ else if( document.createEventObject )
+ {
+ eventObj = document.createEventObject();
+ }
+ else if( document.createEvent )
+ {
+ eventObj = document.createEvent('Events');
+ eventObj.initEvent( eventName, true, false );
+ }
+
+ eventObj.rich = {component:this};
+ eventObj.rich.value = value;
+
+ try
+ {
+ result = eventFunction.call(element, eventObj);
+ }
+ catch (e) { LOG.warn("Exception: "+e.Message + "\n[on"+eventName + "]"); }
+
+ }
+
+ if (result!=false) result = true;
+
+ return result;
+ }
+
+}
\ No newline at end of file
Modified: trunk/ui/dataFilterSlider/src/main/templates/dataFilterSlider.jspx
===================================================================
--- trunk/ui/dataFilterSlider/src/main/templates/dataFilterSlider.jspx 2008-03-28 04:33:13 UTC (rev 7346)
+++ trunk/ui/dataFilterSlider/src/main/templates/dataFilterSlider.jspx 2008-03-28 05:03:53 UTC (rev 7347)
@@ -12,7 +12,7 @@
component="org.richfaces.component.UIDataFltrSlider">
<h:styles>css/dataFilterSlider.xcss</h:styles>
- <h:scripts>new org.ajax4jsf.javascript.AjaxScript(),new org.ajax4jsf.javascript.PrototypeScript(),scripts/scriptaculous-js-1.6.5/src/slider.js</h:scripts>
+ <h:scripts>new org.ajax4jsf.javascript.AjaxScript(),new org.ajax4jsf.javascript.PrototypeScript(),scripts/datafilterslider.js</h:scripts>
<f:clientid var="clientId"/>
<f:resource name="org.richfaces.renderkit.html.images.SliderArrowImage" var="arrow" />
Modified: trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java
===================================================================
--- trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java 2008-03-28 04:33:13 UTC (rev 7346)
+++ trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java 2008-03-28 05:03:53 UTC (rev 7347)
@@ -81,7 +81,7 @@
javaScripts.add("org.ajax4jsf.javascript.PrototypeScript");
//No Ajax
javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
- javaScripts.add("scripts/scriptaculous-js-1.6.5/src/slider.js");
+ javaScripts.add("scripts/datafilterslider.js");
}
public DataFilterSliderComponentTest(String testName) {
Modified: trunk/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
===================================================================
--- trunk/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2008-03-28 04:33:13 UTC (rev 7346)
+++ trunk/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2008-03-28 05:03:53 UTC (rev 7347)
@@ -97,7 +97,7 @@
var disNode = $(clientId + id[1]);
if (node && disNode) {
node.observe("click", Richfaces.ListShuttle.HANDLERS[id[0]].bindAsEventListener(this));
- this.controlList[i] = new Control(node, disNode, false, false, id[0]);
+ this.controlList[i] = new Richfaces.Control(node, disNode, false, false, id[0]);
}
}
//this.controlListManager();
Modified: trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java
===================================================================
--- trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java 2008-03-28 04:33:13 UTC (rev 7346)
+++ trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java 2008-03-28 05:03:53 UTC (rev 7347)
@@ -347,9 +347,9 @@
writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle
+ "-selection", null);
writer.writeAttribute(HTML.onblur_ATTRIBUTE,
- "Control.onblur(this);", null);
+ "Richfaces.Control.onblur(this);", null);
writer.writeAttribute(HTML.onfocus_ATTRIBUTE,
- "Control.onfocus(this);", null);
+ "Richfaces.Control.onfocus(this);", null);
}
writer.startElement(HTML.DIV_ELEM, orderingList);
Modified: trunk/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/Control.js
===================================================================
--- trunk/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/Control.js 2008-03-28 04:33:13 UTC (rev 7346)
+++ trunk/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/Control.js 2008-03-28 05:03:53 UTC (rev 7347)
@@ -1,23 +1,25 @@
-Control = Class.create();
+if(!window.Richfaces) window.Richfaces = {};
-Control.eventStub = function() {
+Richfaces.Control = Class.create();
+
+Richfaces.Control.eventStub = function() {
return false;
}
-Control.onfocus = function(element) {
+Richfaces.Control.onfocus = function(element) {
element.hasFocus = true;
}
-Control.onblur = function(element) {
+Richfaces.Control.onblur = function(element) {
element.hasFocus = undefined;
}
-Control.prototype.initialize = function(eNode, dNode, isShown, isEnabled, action) {
+Richfaces.Control.prototype.initialize = function(eNode, dNode, isShown, isEnabled, action) {
this.disabledNode = dNode;
- this.disabledNode.onselectstart = Control.eventStub;
+ this.disabledNode.onselectstart = Richfaces.Control.eventStub;
this.enabledNode = eNode
- this.enabledNode.onselectstart = Control.eventStub;
+ this.enabledNode.onselectstart = Richfaces.Control.eventStub;
this.isShown = isShown;
this.isEnabled = isEnabled;
@@ -33,7 +35,7 @@
last : {hidden : "ol_button_border ol_control_hidden", shown : "ol_button_border ol_control_shown"}
};*/
-Control.prototype.doShow = function() {
+Richfaces.Control.prototype.doShow = function() {
this.isShown = true;
if (this.isEnabled) {
this.doHideNode(this.disabledNode);
@@ -44,19 +46,19 @@
}
}
-Control.prototype.doHide = function() {
+Richfaces.Control.prototype.doHide = function() {
this.isShown = false;
this.doHideNode(this.disabledNode);
this.doHideNode(this.enabledNode);
}
-Control.prototype.doEnable = function() {
+Richfaces.Control.prototype.doEnable = function() {
this.isEnabled = true;
this.doHideNode(this.disabledNode);
this.doShowNode(this.enabledNode);
}
-Control.prototype.doDisable = function() {
+Richfaces.Control.prototype.doDisable = function() {
this.isEnabled = false;
var nodes = this.enabledNode.select("a[id='" + this.enabledNode.id + "link']");
@@ -84,13 +86,13 @@
}
}
-Control.prototype.doHideNode = function(node) {
- //node.className = Control.CLASSES[this.action].hidden;
+Richfaces.Control.prototype.doHideNode = function(node) {
+ //node.className = Richfaces.Control.CLASSES[this.action].hidden;
node.hide();
}
-Control.prototype.doShowNode = function(node) {
- //node.className = Control.CLASSES[this.action].shown;
+Richfaces.Control.prototype.doShowNode = function(node) {
+ //node.className = Richfaces.Control.CLASSES[this.action].shown;
node.show();
}
Modified: trunk/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js
===================================================================
--- trunk/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js 2008-03-28 04:33:13 UTC (rev 7346)
+++ trunk/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js 2008-03-28 05:03:53 UTC (rev 7347)
@@ -45,7 +45,7 @@
var disNode = $(containerId + id[1]);
if (node && disNode) {
node.observe('click', Richfaces.OrderingList.HANDLERS[id[0]].bindAsEventListener(this));
- this.controlList[i] = new Control(node, disNode, false, false, id[0]);
+ this.controlList[i] = new Richfaces.Control(node, disNode, false, false, id[0]);
}
}
//this.controlListManager();
Modified: trunk/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java
===================================================================
--- trunk/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java 2008-03-28 04:33:13 UTC (rev 7346)
+++ trunk/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java 2008-03-28 05:03:53 UTC (rev 7347)
@@ -436,8 +436,8 @@
writer.startElement(HTML.a_ELEMENT, component);
} else {
writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + "-selection", null);
- writer.writeAttribute(HTML.onblur_ATTRIBUTE, "Control.onblur(this);", null);
- writer.writeAttribute(HTML.onfocus_ATTRIBUTE, "Control.onfocus(this);", null);
+ writer.writeAttribute(HTML.onblur_ATTRIBUTE, "Richfaces.Control.onblur(this);", null);
+ writer.writeAttribute(HTML.onfocus_ATTRIBUTE, "Richfaces.Control.onfocus(this);", null);
}
writer.startElement(HTML.DIV_ELEM, component);
16 years, 9 months
JBoss Rich Faces SVN: r7346 - trunk/ui/inplaceSelect/src/main/templates.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-03-28 00:33:13 -0400 (Fri, 28 Mar 2008)
New Revision: 7346
Modified:
trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx
Log:
inplaceselect.jspx updated
Modified: trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx
===================================================================
--- trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx 2008-03-28 04:21:04 UTC (rev 7345)
+++ trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx 2008-03-28 04:33:13 UTC (rev 7346)
@@ -29,12 +29,11 @@
<![CDATA[
Object value = component.getSubmittedValue();
- Object fieldValue = null;
- if(value == null) {
+ if(value == null) {
value = component.getAttributes().get("value");
- fieldValue = value;
- }
- String fieldLabel = getSelectedItemLabel(context, component);
+ }
+ Object fieldValue = value;
+ String fieldLabel = getSelectedItemLabel(context, component);
value = getConvertedStringValue(context, component,value);
if (value == null || value.equals("")) {
16 years, 9 months
JBoss Rich Faces SVN: r7345 - trunk/ui/inplaceSelect/src/main/templates.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-03-28 00:21:04 -0400 (Fri, 28 Mar 2008)
New Revision: 7345
Modified:
trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx
Log:
in-place select made compileable
Modified: trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx
===================================================================
--- trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx 2008-03-28 02:59:55 UTC (rev 7344)
+++ trunk/ui/inplaceSelect/src/main/templates/inplaceselect.jspx 2008-03-28 04:21:04 UTC (rev 7345)
@@ -29,9 +29,10 @@
<![CDATA[
Object value = component.getSubmittedValue();
+ Object fieldValue = null;
if(value == null) {
- Object value = component.getAttributes().get("value");
- Object fieldValue = value;
+ value = component.getAttributes().get("value");
+ fieldValue = value;
}
String fieldLabel = getSelectedItemLabel(context, component);
value = getConvertedStringValue(context, component,value);
16 years, 9 months
JBoss Rich Faces SVN: r7344 - in trunk/ui/tree/src/main: java/org/richfaces/component and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-03-27 22:59:55 -0400 (Thu, 27 Mar 2008)
New Revision: 7344
Modified:
trunk/ui/tree/src/main/config/component/tree.xml
trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java
Log:
http://jira.jboss.com/jira/browse/RF-2812
Modified: trunk/ui/tree/src/main/config/component/tree.xml
===================================================================
--- trunk/ui/tree/src/main/config/component/tree.xml 2008-03-28 02:59:48 UTC (rev 7343)
+++ trunk/ui/tree/src/main/config/component/tree.xml 2008-03-28 02:59:55 UTC (rev 7344)
@@ -256,6 +256,10 @@
null, a particular treeNode saves the current state
</description>
<methodargs>org.richfaces.component.UITree</methodargs>
+ </property>
+
+ <property hidden="true">
+ <name>rowKeyConverter</name>
</property>
</component>
Modified: trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java 2008-03-28 02:59:48 UTC (rev 7343)
+++ trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java 2008-03-28 02:59:55 UTC (rev 7344)
@@ -24,12 +24,17 @@
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.faces.FacesException;
import javax.faces.application.Application;
+import javax.faces.component.ContextCallback;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
import javax.faces.el.MethodBinding;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
@@ -67,6 +72,7 @@
import org.richfaces.model.CacheableTreeDataModel;
import org.richfaces.model.ClassicCacheableTreeDataModel;
import org.richfaces.model.ClassicTreeDataModel;
+import org.richfaces.model.ListRowKey;
import org.richfaces.model.StackingTreeModel;
import org.richfaces.model.StackingTreeModelProvider;
import org.richfaces.model.SwingCacheableTreeDataModel;
@@ -883,6 +889,105 @@
return null;
}
+
+ public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback) throws FacesException {
+ if (null == context || null == clientId || null == callback) {
+ throw new NullPointerException();
+ }
+
+ boolean found = false;
+ if (clientId.equals(this.getClientId(context))) {
+ try {
+ callback.invokeContextCallback(context, this);
+ return true;
+ } catch (Exception e) {
+ throw new FacesException(e);
+ }
+ } else {
+ Iterator<UIComponent> itr = this.getFacetsAndChildren();
+
+ while (itr.hasNext() && !found) {
+ found = itr.next().invokeOnComponent(context, clientId,
+ callback);
+ }
+ }
+
+ if (found) {
+ return true;
+ } else {
+ String baseId = getBaseClientId(context) + NamingContainer.SEPARATOR_CHAR;
+ if (clientId.startsWith(baseId)) {
+ String rowKeyString = clientId.substring(baseId.length());
+ String keyString = (String) getRowKeyConverter().getAsObject(context, this, rowKeyString);
+ AbstractTreeDataModel dataModel = (AbstractTreeDataModel) getExtendedDataModel();
+ Object rowKey = dataModel.convertToKey(context, keyString, this, null);
+
+ if (rowKey != null) {
+ assert rowKey.toString().equals(rowKeyString);
+
+ Object oldKey = getRowKey();
+ try {
+ setRowKey(context, rowKey);
+
+ return getNodeFacet().invokeOnComponent(context, clientId, callback);
+ } finally {
+ try {
+ setRowKey(context, oldKey);
+ } catch (Exception e) {
+ context.getExternalContext().log(e.getMessage(), e);
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private static final Pattern SEPARATOR = Pattern.compile("(?<!" + ListRowKey.SEPARATOR_ESCAPE_CHAR + ")\\"
+ + NamingContainer.SEPARATOR_CHAR + "\\" + SEPARATOR_CHAR);
+
+ private static final Converter KEY_CONVERTER = new Converter() {
+
+ public Object getAsObject(FacesContext context, UIComponent component, String value) {
+ if (component == null || context == null) {
+ throw new NullPointerException();
+ }
+
+ if (value == null || value.length() == 0) {
+ return null;
+ }
+
+ Matcher matcher = SEPARATOR.matcher(value);
+ if (matcher.find()) {
+ return value.substring(0, matcher.start());
+ } else {
+ throw new IllegalArgumentException("Row key is illegally formed: " + value);
+ }
+ }
+
+ public String getAsString(FacesContext context, UIComponent component, Object value) {
+ if (component == null || context == null) {
+ throw new NullPointerException();
+ }
+
+ if (value == null) {
+ return null;
+ }
+
+ return value.toString() + NamingContainer.SEPARATOR_CHAR;
+ }
+ };
+
+ @Override
+ public Converter getRowKeyConverter() {
+ return KEY_CONVERTER;
+ }
+
+ @Override
+ public void setRowKeyConverter(Converter rowKeyConverter) {
+ throw new UnsupportedOperationException();
+ }
}
16 years, 9 months
JBoss Rich Faces SVN: r7343 - in trunk/samples/treeModelDemo/src/main: webapp/WEB-INF and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-03-27 22:59:48 -0400 (Thu, 27 Mar 2008)
New Revision: 7343
Modified:
trunk/samples/treeModelDemo/src/main/java/org/richfaces/model/Directory.java
trunk/samples/treeModelDemo/src/main/webapp/WEB-INF/faces-config.xml
trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp
Log:
http://jira.jboss.com/jira/browse/RF-2812
Modified: trunk/samples/treeModelDemo/src/main/java/org/richfaces/model/Directory.java
===================================================================
--- trunk/samples/treeModelDemo/src/main/java/org/richfaces/model/Directory.java 2008-03-28 02:59:42 UTC (rev 7342)
+++ trunk/samples/treeModelDemo/src/main/java/org/richfaces/model/Directory.java 2008-03-28 02:59:48 UTC (rev 7343)
@@ -4,7 +4,9 @@
package org.richfaces.model;
import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
/**
* @author Nick Belaevski
@@ -13,29 +15,88 @@
*
*/
public class Directory extends Entry {
- private List directories = new ArrayList();
- private List files = new ArrayList();;
- public List getDirectories() {
- return directories;
- }
+
+ private Map directories = new LinkedHashMap();
+
+ public void addDir(Directory directory) {
+ this.directories.put(new StringKey(directory.getName()), directory);
+ directory.setParent(this);
+ }
+
+ public Map getDirectories() {
+ return directories;
+ }
+
+ public void setDirectories(Map directories) {
+ this.directories = directories;
+ }
+
+ public static class StringKey {
+ private String s;
+
+ public StringKey(String s) {
+ super();
+ this.s = s;
+ }
+
+ @Override
+ public String toString() {
+ return s;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((s == null) ? 0 : s.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ StringKey other = (StringKey) obj;
+ if (s == null) {
+ if (other.s != null)
+ return false;
+ } else if (!s.equals(other.s))
+ return false;
+ return true;
+ }
+
+
+ }
- public void setDirectories(List directories) {
- this.directories = directories;
- }
+// private List directories = new ArrayList();
+//
+// public List getDirectories() {
+// return directories;
+// }
+//
+// public void setDirectories(List directories) {
+// this.directories = directories;
+// }
+//
+// public void addDir(Directory directory) {
+// this.directories.add(directory);
+// directory.setParent(this);
+// }
+ private List files = new ArrayList();;
+
public List getFiles() {
- return files;
+ return files;
}
public void setFiles(List files) {
- this.files = files;
+ this.files = files;
}
-
- public void addDir(Directory directory) {
- this.directories.add(directory);
- directory.setParent(this);
- }
public void addFile(File file) {
this.files.add(file);
Modified: trunk/samples/treeModelDemo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/samples/treeModelDemo/src/main/webapp/WEB-INF/faces-config.xml 2008-03-28 02:59:42 UTC (rev 7342)
+++ trunk/samples/treeModelDemo/src/main/webapp/WEB-INF/faces-config.xml 2008-03-28 02:59:48 UTC (rev 7343)
@@ -4,6 +4,10 @@
<faces-config>
<managed-bean>
+ <managed-bean-name>tree</managed-bean-name>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
<managed-bean-name>treeModelBean</managed-bean-name>
<managed-bean-class>org.richfaces.TreeModelBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
Modified: trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp 2008-03-28 02:59:42 UTC (rev 7342)
+++ trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp 2008-03-28 02:59:48 UTC (rev 7343)
@@ -3,6 +3,7 @@
<%@ taglib uri="http://labs.jboss.com/jbossrichfaces/ui/treeModel" prefix="model" %>
<%@ taglib uri="http://labs.jboss.com/jbossrichfaces/ui/tree" prefix="tree" %>
+<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j" %>
<html>
<head>
@@ -11,24 +12,38 @@
<body>
<f:view>
<h:form>
+ <a4j:outputPanel ajaxRendered="true">
+ <h:messages />
+ </a4j:outputPanel>
+
+ <h:inputText required="true" value="val"/>
+
<tree:tree adviseNodeOpened="#{treeModelBean.adviseNodeOpened}" switchType="client">
<model:treeNodesAdaptor id="project" nodes="#{loaderBean.projects}" var="project">
<tree:treeNode>
+ <a4j:commandLink action="#{project.click}" ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{project.click}" value="Project: #{project.name}" />
</tree:treeNode>
<model:treeNodesAdaptor id="srcDir" var="srcDir" nodes="#{project.srcDirs}">
<tree:treeNode>
+ <a4j:commandLink action="#{srcDir.click}" ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{srcDir.click}" value="Source directory: #{srcDir.name}" />
</tree:treeNode>
<model:treeNodesAdaptor id="pkg" var="pkg" nodes="#{srcDir.packages}">
<tree:treeNode>
+ <a4j:commandLink action="#{pkg.click}" ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{pkg.click}" value="Package: #{pkg.name}" />
</tree:treeNode>
<model:treeNodesAdaptor id="class" var="class" nodes="#{pkg.classes}">
<tree:treeNode>
+ <a4j:commandLink action="#{class.click}" ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{class.click}" value="Class: #{class.name}" />
</tree:treeNode>
</model:treeNodesAdaptor>
@@ -36,11 +51,15 @@
<model:treeNodesAdaptor id="pkg1" var="pkg" nodes="#{srcDir.packages}">
<tree:treeNode>
+ <a4j:commandLink action="#{pkg.click}" ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{pkg.click}" value="Package1: #{pkg.name}" />
</tree:treeNode>
<model:treeNodesAdaptor id="class1" var="class" nodes="#{pkg.classes}">
<tree:treeNode>
+ <a4j:commandLink action="#{class.click}" ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{class.click}" value="Class1: #{class.name}" />
</tree:treeNode>
</model:treeNodesAdaptor>
@@ -50,17 +69,23 @@
<model:recursiveTreeNodesAdaptor id="dir" var="dir"
roots="#{project.dirs}" nodes="#{dir.directories}">
<tree:treeNode>
+ <a4j:commandLink action="#{dir.click}" ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{dir.click}" value="Directory: #{dir.name}" />
</tree:treeNode>
<model:treeNodesAdaptor id="file" var="file" nodes="#{dir.files}">
<tree:treeNode>
+ <a4j:commandLink action="#{file.click}" ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{file.click}" value="File: #{file.name}" />
</tree:treeNode>
</model:treeNodesAdaptor>
<model:treeNodesAdaptor id="file1" var="file" nodes="#{dir.files}">
<tree:treeNode>
+ <a4j:commandLink action="#{file.click}" ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{file.click}" value="File1: #{file.name}" />
</tree:treeNode>
</model:treeNodesAdaptor>
@@ -71,6 +96,8 @@
includedNode="#{archiveEntry.class.simpleName == 'ArchiveEntry'}">
<tree:treeNode id="archiveEntryNode">
+ <a4j:commandLink action="#{archiveEntry.click}" ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{archiveEntry.click}" value="Archive entry: #{archiveEntry.name}" />
</tree:treeNode>
16 years, 9 months
JBoss Rich Faces SVN: r7342 - in trunk/samples/tree-demo/src/main: webapp/pages and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-03-27 22:59:42 -0400 (Thu, 27 Mar 2008)
New Revision: 7342
Modified:
trunk/samples/tree-demo/src/main/java/org/richfaces/Bean.java
trunk/samples/tree-demo/src/main/webapp/pages/index.jsp
Log:
http://jira.jboss.com/jira/browse/RF-2812
Modified: trunk/samples/tree-demo/src/main/java/org/richfaces/Bean.java
===================================================================
--- trunk/samples/tree-demo/src/main/java/org/richfaces/Bean.java 2008-03-28 02:57:35 UTC (rev 7341)
+++ trunk/samples/tree-demo/src/main/java/org/richfaces/Bean.java 2008-03-28 02:59:42 UTC (rev 7342)
@@ -33,6 +33,7 @@
import javax.faces.application.Application;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
import javax.faces.event.FacesEvent;
import org.ajax4jsf.context.AjaxContext;
@@ -491,4 +492,9 @@
public void incCounter1() {
counter1++;
}
+
+ public void action(ActionEvent event) {
+ System.out.println("Bean.action() " +
+ event.getComponent().getClientId(FacesContext.getCurrentInstance()));
+ }
}
\ No newline at end of file
Modified: trunk/samples/tree-demo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/samples/tree-demo/src/main/webapp/pages/index.jsp 2008-03-28 02:57:35 UTC (rev 7341)
+++ trunk/samples/tree-demo/src/main/webapp/pages/index.jsp 2008-03-28 02:59:42 UTC (rev 7342)
@@ -67,6 +67,8 @@
<h:form>
+ <h:inputText required="true" value="value" />
+
<dnd:dragIndicator id="treeIndicator">
<f:facet name="single">
<f:verbatim>{marker} <br /> {treeParam} <br /> {nodeParam}</f:verbatim>
@@ -166,7 +168,8 @@
</h:inputText>
<dnd:dndParam name="nodeParam" value="Node Parameter" />
-
+ <h:outputText value=" " escape="false" />
+ <a4j:commandLink ajaxSingle="true" value="Immediate Link" actionListener="#{bean.action}" onclick="Event.stop(event)"/>
</rich:treeNode>
<rich:treeNode type="text" nodeClass="customNode" acceptedTypes="file2" onselected="return false;">
<h:outputText value="#{data}" />
@@ -193,6 +196,8 @@
<rich:treeNode>
<h:outputText value="#{data.data}" />
+ <h:outputText value=" " escape="false" />
+ <a4j:commandLink ajaxSingle="true" value="Immediate Link" actionListener="#{bean.action}" onclick="Event.stop(event)"/>
</rich:treeNode>
</rich:tree>
16 years, 9 months
JBoss Rich Faces SVN: r7341 - trunk/framework/api/src/main/java/org/richfaces/model.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-03-27 22:57:35 -0400 (Thu, 27 Mar 2008)
New Revision: 7341
Modified:
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java
Log:
http://jira.jboss.com/jira/browse/RF-2812
Modified: trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2008-03-28 02:56:01 UTC (rev 7340)
+++ trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2008-03-28 02:57:35 UTC (rev 7341)
@@ -705,7 +705,7 @@
int idx = i*2;
String modelId = strings[idx];
- model = model.getInternalModelById(modelId);
+ model = model.getModelById(modelId);
if (model.isActive()) {
Object key = model.convert(context, strings[idx + 1], component, converter);
if (key == null) {
16 years, 9 months
JBoss Rich Faces SVN: r7340 - trunk/framework/api/src/main/java/org/richfaces/model.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-03-27 22:56:01 -0400 (Thu, 27 Mar 2008)
New Revision: 7340
Added:
trunk/framework/api/src/main/java/org/richfaces/model/ConvertableKeyModel.java
Modified:
trunk/framework/api/src/main/java/org/richfaces/model/AbstractTreeDataModel.java
trunk/framework/api/src/main/java/org/richfaces/model/CacheableTreeDataModel.java
trunk/framework/api/src/main/java/org/richfaces/model/ClassicTreeDataModel.java
trunk/framework/api/src/main/java/org/richfaces/model/ListRowKey.java
trunk/framework/api/src/main/java/org/richfaces/model/MapDataModel.java
trunk/framework/api/src/main/java/org/richfaces/model/SequenceDataModel.java
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java
trunk/framework/api/src/main/java/org/richfaces/model/SwingTreeDataModel.java
trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModel.java
Log:
http://jira.jboss.com/jira/browse/RF-2812
Modified: trunk/framework/api/src/main/java/org/richfaces/model/AbstractTreeDataModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/AbstractTreeDataModel.java 2008-03-27 20:46:35 UTC (rev 7339)
+++ trunk/framework/api/src/main/java/org/richfaces/model/AbstractTreeDataModel.java 2008-03-28 02:56:01 UTC (rev 7340)
@@ -24,7 +24,9 @@
import java.io.IOException;
import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.model.ExtendedDataModel;
@@ -124,4 +126,7 @@
}
public abstract TreeNode getTreeNode();
+
+ public abstract Object convertToKey(FacesContext context, String keyString,
+ UIComponent component, Converter converter);
}
Modified: trunk/framework/api/src/main/java/org/richfaces/model/CacheableTreeDataModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/CacheableTreeDataModel.java 2008-03-27 20:46:35 UTC (rev 7339)
+++ trunk/framework/api/src/main/java/org/richfaces/model/CacheableTreeDataModel.java 2008-03-28 02:56:01 UTC (rev 7340)
@@ -23,7 +23,9 @@
import java.io.IOException;
+import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.model.Range;
@@ -135,4 +137,8 @@
protected abstract void setDefaultNodeData(T node, Object data);
+ @Override
+ public Object convertToKey(FacesContext context, String keyString, UIComponent component, Converter converter) {
+ return treeDataModel.convertToKey(context, keyString, component, converter);
+ }
}
Modified: trunk/framework/api/src/main/java/org/richfaces/model/ClassicTreeDataModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/ClassicTreeDataModel.java 2008-03-27 20:46:35 UTC (rev 7339)
+++ trunk/framework/api/src/main/java/org/richfaces/model/ClassicTreeDataModel.java 2008-03-28 02:56:01 UTC (rev 7340)
@@ -21,6 +21,15 @@
package org.richfaces.model;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map.Entry;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
/**
* {@link TreeDataModel} implementation for classic {@link TreeNode} instances
*
@@ -44,4 +53,40 @@
throw new IllegalStateException(
"No tree element available or row key not set!");
}
+
+ @Override
+ public Object convertToKey(FacesContext context, String keyString, UIComponent component, Converter converter) {
+ String[] strings = ListRowKey.fromString(keyString);
+ List<Object> list = new ArrayList<Object>(strings.length);
+ TreeNode node = (TreeNode) getWrappedData();
+
+ for (int i = 0; i < strings.length; i++) {
+ String key = strings[i];
+ TreeNode<?> child = node.getChild(key);
+ if (child != null) {
+ node = child;
+ list.add(key);
+ } else {
+ boolean found = false;
+ Iterator<Entry<Object, TreeNode>> children = node.getChildren();
+
+ while (children.hasNext() && !found) {
+ Entry<Object, TreeNode> entry = children.next();
+ Object keyObject = entry.getKey();
+ if (key.equals(keyObject.toString())) {
+ node = entry.getValue();
+ list.add(keyObject);
+ found = true;
+ }
+ }
+
+ if (!found) {
+ return null;
+ }
+ }
+ }
+
+ return new ListRowKey<Object>(list);
+ }
+
}
Added: trunk/framework/api/src/main/java/org/richfaces/model/ConvertableKeyModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/ConvertableKeyModel.java (rev 0)
+++ trunk/framework/api/src/main/java/org/richfaces/model/ConvertableKeyModel.java 2008-03-28 02:56:01 UTC (rev 7340)
@@ -0,0 +1,51 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * 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,
+ * 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+/**
+ * Models that can handle keys conversion should implement this interface
+ *
+ * For internal use only
+ *
+ * @author Nick Belaevski
+ * @since 3.2
+ */
+
+public interface ConvertableKeyModel {
+
+ /**
+ * Converts {@link String} to model object key
+ *
+ * @param context
+ * @param key
+ * @param component
+ * @param converter
+ * @return
+ */
+ public Object getKeyAsObject(FacesContext context, String key,
+ UIComponent component, Converter converter);
+
+}
Modified: trunk/framework/api/src/main/java/org/richfaces/model/ListRowKey.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/ListRowKey.java 2008-03-27 20:46:35 UTC (rev 7339)
+++ trunk/framework/api/src/main/java/org/richfaces/model/ListRowKey.java 2008-03-28 02:56:01 UTC (rev 7340)
@@ -22,9 +22,12 @@
package org.richfaces.model;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
+import javax.faces.component.NamingContainer;
+
/**
* Default {@link TreeRowKey} implementation based on {@link ArrayList}
* @author Nick Belaevski - nbelaevski(a)exadel.com
@@ -148,28 +151,42 @@
}
}
+ private void appendSegment(StringBuilder builder, String segment) {
+ StringBuilder escapedSubPath = new StringBuilder();
+ for (int i = 0; i < segment.length(); i++) {
+ char ch = segment.charAt(i);
+
+ //escape
+ if (AbstractTreeDataModel.SEPARATOR == ch || ListRowKey.SEPARATOR_ESCAPE_CHAR == ch) {
+ escapedSubPath.append(ListRowKey.SEPARATOR_ESCAPE_CHAR);
+ }
+
+ escapedSubPath.append(ch);
+ }
+
+ builder.append(escapedSubPath.toString());
+ }
+
public String getPath() {
- StringBuffer result = new StringBuffer();
+ StringBuilder result = new StringBuilder();
Iterator<T> iterator = path.iterator();
boolean hasNext = iterator.hasNext();
-
+
while (hasNext) {
- String pathSegment = iterator.next().toString();
-
- StringBuffer escapedSubPath = new StringBuffer();
- for (int i = 0; i < pathSegment.length(); i++) {
- char ch = pathSegment.charAt(i);
-
- //escape
- if (AbstractTreeDataModel.SEPARATOR == ch || ListRowKey.SEPARATOR_ESCAPE_CHAR == ch) {
- escapedSubPath.append(ListRowKey.SEPARATOR_ESCAPE_CHAR);
+ T segment = iterator.next();
+ if (segment instanceof CompositeKey) {
+ CompositeKey compositeKey = (CompositeKey) segment;
+ Iterator keySegments = compositeKey.getKeySegments();
+ while (keySegments.hasNext()) {
+ appendSegment(result, keySegments.next().toString());
+ if (keySegments.hasNext()) {
+ result.append(AbstractTreeDataModel.SEPARATOR);
}
+ }
+ } else {
+ appendSegment(result, segment.toString());
+ }
- escapedSubPath.append(ch);
- }
-
- result.append(escapedSubPath.toString());
-
hasNext = iterator.hasNext();
if (hasNext) {
@@ -195,4 +212,25 @@
public T get(int i) {
return path.get(i);
}
+
+ private static final String SEPARATOR = "(?<!" + ListRowKey.SEPARATOR_ESCAPE_CHAR + ")\\"
+ + NamingContainer.SEPARATOR_CHAR;
+
+ public static String[] fromString(String keyString) {
+ String[] split = keyString.split(SEPARATOR);
+ for (int i = 0; i < split.length; i++) {
+ //TODO exception if not escaped properly
+ split[i] = split[i].replaceAll("_(:|_)", "$1");
+ }
+
+ return split;
+ }
+
+ public static interface CompositeKey {
+ public Iterator getKeySegments();
+ }
+
+ public static void main(String[] args) {
+ System.out.println(Arrays.toString(fromString("test_:abc:123:a__b")));
+ }
}
Modified: trunk/framework/api/src/main/java/org/richfaces/model/MapDataModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/MapDataModel.java 2008-03-27 20:46:35 UTC (rev 7339)
+++ trunk/framework/api/src/main/java/org/richfaces/model/MapDataModel.java 2008-03-28 02:56:01 UTC (rev 7340)
@@ -10,8 +10,11 @@
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
+import java.util.Map.Entry;
+import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.model.ExtendedDataModel;
@@ -24,7 +27,7 @@
*
* @author Nick Belaevski mailto:nbelaevski@exadel.com created 30.07.2007
*/
-public class MapDataModel extends ExtendedDataModel {
+public class MapDataModel extends ExtendedDataModel implements ConvertableKeyModel {
private Map<Object, Object> map;
private Object rowKey;
@@ -199,4 +202,22 @@
}
}
+ public Object getKeyAsObject(FacesContext context, String key, UIComponent component, Converter converter) {
+ if (this.map != null) {
+ if (this.map.containsKey(key)) {
+ return key;
+ } else {
+ Set<Entry<Object,Object>> set = this.map.entrySet();
+ for (Entry<Object, Object> entry : set) {
+ Object keyObject = entry.getKey();
+ if (key.equals(keyObject.toString())) {
+ return keyObject;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
}
Modified: trunk/framework/api/src/main/java/org/richfaces/model/SequenceDataModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/SequenceDataModel.java 2008-03-27 20:46:35 UTC (rev 7339)
+++ trunk/framework/api/src/main/java/org/richfaces/model/SequenceDataModel.java 2008-03-28 02:56:01 UTC (rev 7340)
@@ -12,7 +12,9 @@
import java.util.Iterator;
import java.util.List;
+import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.model.ExtendedDataModel;
@@ -27,7 +29,7 @@
* created 30.07.2007
*
*/
-public class SequenceDataModel extends ExtendedDataModel {
+public class SequenceDataModel extends ExtendedDataModel implements ConvertableKeyModel {
private Object wrappedData;
private List list;
@@ -140,4 +142,13 @@
this.list = null;
}
}
+
+ public Object getKeyAsObject(FacesContext context, String keyString, UIComponent component, Converter converter) {
+ int key = Integer.parseInt(keyString);
+ if (key >= 0 && this.list != null && key < this.list.size()) {
+ return key;
+ } else {
+ return null;
+ }
+ }
}
Modified: trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2008-03-27 20:46:35 UTC (rev 7339)
+++ trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2008-03-28 02:56:01 UTC (rev 7340)
@@ -5,18 +5,24 @@
import java.io.IOException;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
+import java.util.NoSuchElementException;
+import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.model.ExtendedDataModel;
import org.ajax4jsf.model.Range;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.iterators.FilterIterator;
+import org.richfaces.model.ListRowKey.CompositeKey;
import org.w3c.dom.NamedNodeMap;
/**
@@ -123,6 +129,8 @@
leaveModel(getRoot().stackEntries.iterator(), null, context);
return null;
}
+
+ //TODO what's here?
}
if (keyIterator != null && keyIterator.hasNext()) {
@@ -503,7 +511,7 @@
*
* @author Nick Belaevski
*/
- protected static class Key implements Serializable {
+ protected static class Key implements Serializable, CompositeKey {
/**
*
*/
@@ -551,6 +559,103 @@
return false;
return true;
}
+
+ static enum IteratorState {
+ INITIAL {
+ @Override
+ protected boolean hasNext(Key arg0) {
+ return true;
+ }
+
+ @Override
+ protected Object next(Key arg0) {
+ throw new IllegalStateException();
+ }
+
+ @Override
+ protected IteratorState nextState() {
+ return ID;
+ }
+ },
+
+ ID {
+ @Override
+ protected boolean hasNext(Key arg0) {
+ return true;
+ }
+
+ @Override
+ protected Object next(Key arg0) {
+ return arg0.modelId;
+ }
+
+ @Override
+ protected IteratorState nextState() {
+ return KEY;
+ }
+ },
+
+ KEY {
+ @Override
+ protected boolean hasNext(Key arg0) {
+ return false;
+ }
+
+ @Override
+ protected Object next(Key arg0) {
+ return arg0.modelKey;
+ }
+
+ @Override
+ protected IteratorState nextState() {
+ return DONE;
+ }
+ },
+
+ DONE {
+ @Override
+ protected boolean hasNext(Key arg0) {
+ return false;
+ }
+
+ @Override
+ protected Object next(Key arg0) {
+ throw new NoSuchElementException();
+ }
+
+ @Override
+ protected IteratorState nextState() {
+ return DONE;
+ }
+ };
+
+ protected abstract boolean hasNext(Key key);
+
+ protected abstract Object next(Key key);
+
+ protected abstract IteratorState nextState();
+ };
+
+ public Iterator getKeySegments() {
+
+ return new Iterator<Object>() {
+ IteratorState state = IteratorState.INITIAL;
+
+ public boolean hasNext() {
+ return state.hasNext(Key.this);
+ }
+
+ public Object next() {
+ state = state.nextState();
+ return state.next(Key.this);
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ };
+ }
}
protected boolean isActiveData() {
@@ -583,4 +688,47 @@
public void setWrappedData(Object data) {
throw new UnsupportedOperationException();
}
+
+ @Override
+ public Object convertToKey(FacesContext context, String keyString,
+ UIComponent component, Converter converter) {
+
+ //force model leave
+ setRowKey(null);
+
+ String[] strings = ListRowKey.fromString(keyString);
+ int l = strings.length / 2;
+ List<Object> list = new ArrayList<Object>(l);
+ StackingTreeModel model = getRoot();
+
+ for (int i = 0; i < l; i++) {
+ int idx = i*2;
+
+ String modelId = strings[idx];
+ model = model.getInternalModelById(modelId);
+ if (model.isActive()) {
+ Object key = model.convert(context, strings[idx + 1], component, converter);
+ if (key == null) {
+ return null;
+ }
+
+ list.add(new Key(modelId, key));
+
+ if (!model.setupModel(key, context) || !model.isActiveData()) {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ return new ListRowKey<Object>(list);
+ }
+
+ protected Object convert(FacesContext context, String string,
+ UIComponent component, Converter converter) {
+
+ ConvertableKeyModel convertable = (ConvertableKeyModel) getDataModel();
+ return convertable.getKeyAsObject(context, string, component, converter);
+ }
}
Modified: trunk/framework/api/src/main/java/org/richfaces/model/SwingTreeDataModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/SwingTreeDataModel.java 2008-03-27 20:46:35 UTC (rev 7339)
+++ trunk/framework/api/src/main/java/org/richfaces/model/SwingTreeDataModel.java 2008-03-28 02:56:01 UTC (rev 7340)
@@ -21,9 +21,14 @@
package org.richfaces.model;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
+import java.util.List;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
import javax.swing.tree.TreeNode;
/**
@@ -77,4 +82,30 @@
super.setWrappedData(data);
}
+
+
+ @Override
+ public Object convertToKey(FacesContext context, String keyString, UIComponent component, Converter converter) {
+ String[] strings = ListRowKey.fromString(keyString);
+ List<Integer> list = new ArrayList<Integer>(strings.length);
+ TreeNode node = this.treeNode;
+
+ if (node != null) {
+ TreeDataModelNodeAdaptor<TreeNode> adaptor = getNodeAdaptor();
+
+ for (int i = 0; i < strings.length; i++) {
+ int key = Integer.parseInt(strings[i]);
+
+ node = adaptor.getChild(node, key);
+ if (node != null) {
+ list.add(key);
+ } else {
+ return null;
+ }
+ }
+ }
+
+ return new ListRowKey<Integer>(list);
+ }
+
}
Modified: trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModel.java 2008-03-27 20:46:35 UTC (rev 7339)
+++ trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModel.java 2008-03-28 02:56:01 UTC (rev 7340)
@@ -36,7 +36,7 @@
* @author Nick Belaevski - nbelaevski(a)exadel.com created 16.11.2006
*
*/
-public class TreeDataModel<T> extends AbstractTreeDataModel {
+public abstract class TreeDataModel<T> extends AbstractTreeDataModel {
private Object wrappedData;
private Class<T> clazz;
16 years, 9 months
JBoss Rich Faces SVN: r7339 - trunk/ui/combobox/src/main/templates.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-03-27 16:46:35 -0400 (Thu, 27 Mar 2008)
New Revision: 7339
Modified:
trunk/ui/combobox/src/main/templates/combobox.jspx
Log:
http://jira.jboss.com/jira/browse/RF-2791
Modified: trunk/ui/combobox/src/main/templates/combobox.jspx
===================================================================
--- trunk/ui/combobox/src/main/templates/combobox.jspx 2008-03-27 20:46:18 UTC (rev 7338)
+++ trunk/ui/combobox/src/main/templates/combobox.jspx 2008-03-27 20:46:35 UTC (rev 7339)
@@ -79,7 +79,11 @@
Boolean selectFirstOnUpdate = (Boolean) component.getAttributes().get("selectFirstOnUpdate");
variables.setVariable("selectFirstOnUpdate", selectFirstOnUpdate);
- Object value = component.getAttributes().get("value");
+ Object value = component.getSubmittedValue();
+ if (value == null) {
+ value = component.getAttributes().get("value");
+ }
+
String valueStyle = "rich-combobox-font-inactive";
value = getConvertedStringValue(context, component,value);
if (value == null || value.equals("")) {
16 years, 9 months