Propchange:
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/prototype.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/prototype.js
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange:
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/prototype.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/scriptaculous.js
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/scriptaculous.js?view=auto&rev=543957
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/scriptaculous.js
(added)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/scriptaculous.js
Sun Jun 3 11:51:08 2007
@@ -0,0 +1,58 @@
+// script.aculo.us scriptaculous.js v1.7.1_beta3, Fri May 25 17:19:41 +0200
2007
+
+// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us,
http://mir.aculo.us)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+var Scriptaculous = {
+ Version: '1.7.1_beta3',
+ require: function(libraryName) {
+ // inserting via DOM fails in Safari 2.0, so brute force approach
+ document.write('<script type="text/javascript"
src="'+libraryName+'"></script>');
+ },
+ REQUIRED_PROTOTYPE: '1.5.1',
+ load: function() {
+ function convertVersionString(versionString){
+ var r = versionString.split('.');
+ return parseInt(r[0])*100000 + parseInt(r[1])*1000 + parseInt(r[2]);
+ }
+
+ if((typeof Prototype=='undefined') ||
+ (typeof Element == 'undefined') ||
+ (typeof Element.Methods=='undefined') ||
+ (convertVersionString(Prototype.Version) <
+ convertVersionString(Scriptaculous.REQUIRED_PROTOTYPE)))
+ throw("script.aculo.us requires the Prototype JavaScript framework >= "
+
+ Scriptaculous.REQUIRED_PROTOTYPE);
+
+ $A(document.getElementsByTagName("script")).findAll( function(s) {
+ return (s.src && s.src.match(/scriptaculous\.js(\?.*)?$/))
+ }).each( function(s) {
+ var path = s.src.replace(/scriptaculous\.js(\?.*)?$/,'');
+ var includes = s.src.match(/\?.*load=([a-z,]*)/);
+ (includes ? includes[1] :
'builder,effects,dragdrop,controls,slider,sound').split(',').each(
+ function(include) { Scriptaculous.require(path+include+'.js') });
+ });
+ }
+}
+
+Scriptaculous.load();
\ No newline at end of file
Propchange:
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/scriptaculous.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/scriptaculous.js
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange:
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/scriptaculous.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/slider.js
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/slider.js?view=auto&rev=543957
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/slider.js
(added)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/slider.js
Sun Jun 3 11:51:08 2007
@@ -0,0 +1,277 @@
+// script.aculo.us slider.js v1.7.1_beta3, Fri May 25 17:19:41 +0200 2007
+
+// Copyright (c) 2005-2007 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(!Control) var Control = {};
+Control.Slider = Class.create();
+
+// options:
+// axis: 'vertical', or 'horizontal' (default)
+//
+// callbacks:
+// onChange(value)
+// onSlide(value)
+Control.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.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.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.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$/,""));
+
+ 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.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);
+
+ // Initialize handles in reverse (make sure first handle is active)
+ 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);
+ });
+
+ Event.observe(this.track, "mousedown", this.eventMouseDown);
+ Event.observe(document, "mouseup", this.eventMouseUp);
+ Event.observe(document, "mousemove", this.eventMouseMove);
+
+ this.initialized = true;
+ },
+ 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){
+ 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;
+ if(value < this.range.start) return this.range.start;
+ return 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
+
+ this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =
+ this.translateToPx(sliderValue);
+
+ this.drawSpans();
+ if(!this.dragging || !this.event) this.updateFinished();
+ },
+ 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);
+ 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);
+ if(Prototype.Browser.WebKit) 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;
+ this.setValue(this.translateToValue( this.isVertical() ? pointer[1] :
pointer[0] ));
+ if(this.initialized && this.options.onSlide)
+ this.options.onSlide(this.values.length>1 ? this.values : this.value,
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();
+ },
+ updateFinished: function() {
+ if(this.initialized && this.options.onChange)
+ this.options.onChange(this.values.length>1 ? this.values : this.value,
this);
+ this.event = null;
+ }
+}
\ No newline at end of file
Propchange:
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/slider.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/slider.js
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange:
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/slider.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/sound.js
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/sound.js?view=auto&rev=543957
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/sound.js
(added)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/sound.js
Sun Jun 3 11:51:08 2007
@@ -0,0 +1,60 @@
+// script.aculo.us sound.js v1.7.1_beta3, Fri May 25 17:19:41 +0200 2007
+
+// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us,
http://mir.aculo.us)
+//
+// Based on code created by Jules Gravinese (http://www.webveteran.com/)
+//
+// 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/
+
+Sound = {
+ tracks: {},
+ _enabled: true,
+ template:
+ new Template('<embed style="height:0" id="sound_#{track}_#{id}"
src="#{url}" loop="false" autostart="true" hidden="true"/>'),
+ enable: function(){
+ Sound._enabled = true;
+ },
+ disable: function(){
+ Sound._enabled = false;
+ },
+ play: function(url){
+ if(!Sound._enabled) return;
+ var options = Object.extend({
+ track: 'global', url: url, replace: false
+ }, arguments[1] || {});
+
+ if(options.replace && this.tracks[options.track]) {
+ $R(0, this.tracks[options.track].id).each(function(id){
+ var sound = $('sound_'+options.track+'_'+id);
+ sound.Stop && sound.Stop();
+ sound.remove();
+ })
+ this.tracks[options.track] = null;
+ }
+
+ if(!this.tracks[options.track])
+ this.tracks[options.track] = { id: 0 }
+ else
+ this.tracks[options.track].id++;
+
+ options.id = this.tracks[options.track].id;
+ if (Prototype.Browser.IE) {
+ var sound = document.createElement('bgsound');
+ sound.setAttribute('id','sound_'+options.track+'_'+options.id);
+ sound.setAttribute('src',options.url);
+ sound.setAttribute('loop','1');
+ sound.setAttribute('autostart','true');
+ $$('body')[0].appendChild(sound);
+ }
+ else
+ new Insertion.Bottom($$('body')[0], Sound.template.evaluate(options));
+ }
+};
+
+if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){
+ if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return
p.name.indexOf('QuickTime') != -1 }))
+ Sound.template = new Template('<object id="sound_#{track}_#{id}" width="0"
height="0" type="audio/mpeg" data="#{url}"/>')
+ else
+ Sound.play = function(){}
+}
Propchange:
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/sound.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/sound.js
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange:
tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/sound.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/scriptaculous/TestSuggest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/scriptaculous/TestSuggest.java?view=auto&rev=543957
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/scriptaculous/TestSuggest.java
(added)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/scriptaculous/TestSuggest.java
Sun Jun 3 11:51:08 2007
@@ -0,0 +1,277 @@
+package org.apache.tapestry.scriptaculous;
+
+import org.apache.hivemind.ApplicationRuntimeException;
+import org.apache.hivemind.Location;
+import org.apache.tapestry.*;
+import static org.apache.tapestry.Capturer.capture;
+import static org.apache.tapestry.Capturer.newCapturer;
+import org.apache.tapestry.coerce.ValueConverter;
+import org.apache.tapestry.engine.DirectServiceParameter;
+import org.apache.tapestry.engine.IEngineService;
+import org.apache.tapestry.engine.ILink;
+import org.apache.tapestry.form.MockForm;
+import org.apache.tapestry.form.TranslatedFieldSupport;
+import org.apache.tapestry.form.ValidatableFieldSupport;
+import org.apache.tapestry.services.ResponseBuilder;
+import org.apache.tapestry.spec.ComponentSpecification;
+import org.apache.tapestry.valid.IValidationDelegate;
+import org.apache.tapestry.valid.ValidationDelegate;
+import static org.easymock.EasyMock.*;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Tests core functionality of [EMAIL PROTECTED] Suggest} component.
+ */
[EMAIL PROTECTED]
+public class TestSuggest extends BaseComponentTestCase {
+
+ public void test_Render_Component()
+ {
+ IRequestCycle cycle = newMock(IRequestCycle.class);
+ checkOrder(cycle, false);
+
+ ResponseBuilder resp = newMock(ResponseBuilder.class);
+ IEngineService engine = newMock(IEngineService.class);
+ ILink link = newMock(ILink.class);
+ IScript script = newMock(IScript.class);
+ PageRenderSupport prs = newMock(PageRenderSupport.class);
+
+ TranslatedFieldSupport translator =
newMock(TranslatedFieldSupport.class);
+ ValidatableFieldSupport validator =
newMock(ValidatableFieldSupport.class);
+
+ IValidationDelegate delegate = new ValidationDelegate();
+ IForm form = newMock(IForm.class);
+ IMarkupWriter writer = newBufferWriter();
+
+ Suggest comp = newInstance(Suggest.class,
+ "response", resp,
+ "templateTagName", "input",
+ "name", "suggest",
+ "clientId", "suggest",
+ "form", form,
+ "translatedFieldSupport", translator,
+ "validatableFieldSupport", validator,
+ "engineService", engine,
+ "script", script);
+
+ expect(cycle.isRewinding()).andReturn(false).anyTimes();
+ expect(resp.isDynamic()).andReturn(false);
+ trainGetAttribute(cycle, TapestryUtils.FORM_ATTRIBUTE, form);
+
+ expect(form.wasPrerendered(writer, comp)).andReturn(false);
+ expect(form.getDelegate()).andReturn(delegate).anyTimes();
+ expect(form.getElementId(comp)).andReturn("suggest");
+ expect(form.isRewinding()).andReturn(false).anyTimes();
+
+ form.setFormFieldUpdating(true);
+
+ expect(translator.format(comp, null)).andReturn("r2d2");
+ translator.renderContributions(comp, writer, cycle);
+ validator.renderContributions(comp, writer, cycle);
+
+ expect(engine.getLink(eq(false),
isA(DirectServiceParameter.class))).andReturn(link);
+ expect(link.getURL()).andReturn("http://url");
+
+ Capturer<Map> parm = newCapturer(Map.class);
+
+ trainGetAttribute(cycle, TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE,
prs);
+ script.execute(eq(comp), eq(cycle), eq(prs), capture(parm));
+
+ replay();
+
+ comp.renderComponent(writer, cycle);
+
+ verify();
+
+ assert parm.getCaptured() != null;
+ Map parms = parm.getCaptured();
+
+ assertEquals(parms.size(), 4);
+ assertEquals(parms.get("inputId"), "suggest");
+ assertEquals(parms.get("updateId"), "suggestchoices");
+ assertEquals(parms.get("options"),
"{\"onFailure\":\"tapestry.error\"}");
+ assertEquals(parms.get("updateUrl"), "http://url");
+
+ assertBuffer("<input type=\"text\" autocomplete=\"off\" " +
+ "id=\"suggest\" name=\"suggest\" value=\"r2d2\" />" +
+ "<div id=\"suggestchoices\" class=\"\"></div>");
+ }
+
+ public void test_Render_TextArea_Component()
+ {
+ IRequestCycle cycle = newMock(IRequestCycle.class);
+ checkOrder(cycle, false);
+
+ ResponseBuilder resp = newMock(ResponseBuilder.class);
+ IEngineService engine = newMock(IEngineService.class);
+ ILink link = newMock(ILink.class);
+ IScript script = newMock(IScript.class);
+ PageRenderSupport prs = newMock(PageRenderSupport.class);
+
+ TranslatedFieldSupport translator =
newMock(TranslatedFieldSupport.class);
+ ValidatableFieldSupport validator =
newMock(ValidatableFieldSupport.class);
+
+ IValidationDelegate delegate = new ValidationDelegate();
+ IForm form = newMock(IForm.class);
+ IMarkupWriter writer = newBufferWriter();
+
+ Suggest comp = newInstance(Suggest.class,
+ "response", resp,
+ "templateTagName", "textarea",
+ "name", "suggest",
+ "clientId", "suggest",
+ "form", form,
+ "translatedFieldSupport", translator,
+ "validatableFieldSupport", validator,
+ "engineService", engine,
+ "script", script);
+
+ expect(cycle.isRewinding()).andReturn(false).anyTimes();
+ expect(resp.isDynamic()).andReturn(false);
+ trainGetAttribute(cycle, TapestryUtils.FORM_ATTRIBUTE, form);
+
+ expect(form.wasPrerendered(writer, comp)).andReturn(false);
+ expect(form.getDelegate()).andReturn(delegate).anyTimes();
+ expect(form.getElementId(comp)).andReturn("suggest");
+ expect(form.isRewinding()).andReturn(false).anyTimes();
+
+ form.setFormFieldUpdating(true);
+
+ expect(translator.format(comp, null)).andReturn("r2d2");
+ translator.renderContributions(comp, writer, cycle);
+ validator.renderContributions(comp, writer, cycle);
+
+ expect(engine.getLink(eq(false),
isA(DirectServiceParameter.class))).andReturn(link);
+ expect(link.getURL()).andReturn("http://url");
+
+ Capturer<Map> parm = newCapturer(Map.class);
+
+ trainGetAttribute(cycle, TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE,
prs);
+ script.execute(eq(comp), eq(cycle), eq(prs), capture(parm));
+
+ replay();
+
+ comp.renderComponent(writer, cycle);
+
+ verify();
+
+ assert parm.getCaptured() != null;
+ Map parms = parm.getCaptured();
+
+ assertEquals(parms.size(), 4);
+ assertEquals(parms.get("inputId"), "suggest");
+ assertEquals(parms.get("updateId"), "suggestchoices");
+ assertEquals(parms.get("options"),
"{\"onFailure\":\"tapestry.error\"}");
+ assertEquals(parms.get("updateUrl"), "http://url");
+
+ assertBuffer("<textarea id=\"suggest\"
name=\"suggest\">r2d2</textarea>" +
+ "<div id=\"suggestchoices\" class=\"\"></div>");
+ }
+
+ public void test_Render_Invalid_Options_JSON_Syntax()
+ {
+ IRequestCycle cycle = newMock(IRequestCycle.class);
+ checkOrder(cycle, false);
+ ResponseBuilder resp = newMock(ResponseBuilder.class);
+
+ TranslatedFieldSupport translator =
newMock(TranslatedFieldSupport.class);
+ ValidatableFieldSupport validator =
newMock(ValidatableFieldSupport.class);
+
+ IValidationDelegate delegate = new ValidationDelegate();
+ IForm form = new MockForm(delegate);
+ IMarkupWriter writer = newBufferWriter();
+
+ IBinding binding = newMock(IBinding.class);
+ Location l = newLocation();
+ ComponentSpecification spec = new ComponentSpecification();
+
+ Suggest comp = newInstance(Suggest.class,
+ "response", resp,
+ "templateTagName", "input",
+ "name", "suggest",
+ "clientId", "suggest",
+ "form", form,
+ "translatedFieldSupport", translator,
+ "validatableFieldSupport", validator,
+ "options", "{thisisinvalid:true",
+ "specification", spec);
+
+ expect(cycle.isRewinding()).andReturn(false).anyTimes();
+ expect(resp.isDynamic()).andReturn(false);
+ trainGetAttribute(cycle, TapestryUtils.FORM_ATTRIBUTE, form);
+
+ expect(translator.format(comp, null)).andReturn("r2d2");
+ translator.renderContributions(comp, writer, cycle);
+ validator.renderContributions(comp, writer, cycle);
+
+ expect(binding.getObject()).andReturn("{thisisinvalid:true");
+ expect(binding.getLocation()).andReturn(l);
+
+ replay();
+
+ try {
+
+ comp.setBinding("options", binding);
+
+ comp.renderComponent(writer, cycle);
+
+ unreachable();
+ } catch (ApplicationRuntimeException ex) {
+
+ assertEquals(ex.getMessage(), "Invalid JSON options string given:
{thisisinvalid:true. " +
+ "The options parameter must be
properly formatted according to JSON object syntax rules. " +
+ "Expected a ',' or '}' at character
19 of {thisisinvalid:true>>missing value<<");
+ }
+
+ verify();
+ }
+
+ public void test_Render_List()
+ {
+ IRequestCycle cycle = newMock(IRequestCycle.class);
+ checkOrder(cycle, false);
+ ResponseBuilder resp = newMock(ResponseBuilder.class);
+
+ IValidationDelegate delegate = new ValidationDelegate();
+ IForm form = newMock(IForm.class);
+ IMarkupWriter writer = newBufferWriter();
+
+ ValueConverter converter = newMock(ValueConverter.class);
+
+ List<String> source = new ArrayList<String>();
+ source.add("Foo");
+ source.add("Stimpy");
+ source.add("Cat");
+
+ Suggest comp = newInstance(Suggest.class,
+ "response", resp,
+ "templateTagName", "input",
+ "name", "suggest",
+ "clientId", "suggest",
+ "form", form,
+ "searchTriggered", true,
+ "listSource", source,
+ "valueConverter", converter,
+ "listItemRenderer",
DefaultListItemRenderer.SHARED_INSTANCE);
+
+ expect(cycle.isRewinding()).andReturn(false).anyTimes();
+ expect(resp.isDynamic()).andReturn(true);
+ trainGetAttribute(cycle, TapestryUtils.FORM_ATTRIBUTE, form);
+ expect(form.wasPrerendered(writer, comp)).andReturn(false);
+
+ expect(converter.coerceValue(source,
Iterator.class)).andReturn(source.iterator());
+
+ replay();
+
+ comp.renderComponent(writer, cycle);
+
+ verify();
+
+ assertBuffer("<ul><li>Foo</li><li>Stimpy</li><li>Cat</li></ul>");
+ }
+}
Propchange:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/scriptaculous/TestSuggest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/scriptaculous/TestSuggest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/scriptaculous/TestSuggest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/DojoAjaxResponseBuilderTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/DojoAjaxResponseBuilderTest.java?view=diff&rev=543957&r1=543956&r2=543957
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/DojoAjaxResponseBuilderTest.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/DojoAjaxResponseBuilderTest.java
Sun Jun 3 11:51:08 2007
@@ -281,11 +281,10 @@
ResponseBuilder builder = new DojoAjaxResponseBuilder(cycle, writer,
parts);
expect(comp.getClientId()).andReturn("comp");
-
+
expect(cycle.renderStackIterator()).andReturn(Collections.EMPTY_LIST.iterator());
expect(comp.getClientId()).andReturn("comp1");
-
expect(comp.getClientId()).andReturn("comp");
expect(cycle.renderStackIterator()).andReturn(Collections.EMPTY_LIST.iterator());
@@ -402,11 +401,8 @@
replay();
builder.beginResponse();
-
builder.writeExternalScript(mw, script1, cycle);
-
builder.writeExternalScript(mw, script2, cycle);
-
builder.endResponse();
assertOutput("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html
PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\" [\n" +
@@ -441,9 +437,7 @@
replay();
builder.beginResponse();
-
builder.writeInitializationScript(mw, script);
-
builder.endResponse();
assertOutput("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html
PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\" [\n" +
Added:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/PrototypeResponseBuilderTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/PrototypeResponseBuilderTest.java?view=auto&rev=543957
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/PrototypeResponseBuilderTest.java
(added)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/PrototypeResponseBuilderTest.java
Sun Jun 3 11:51:08 2007
@@ -0,0 +1,74 @@
+package org.apache.tapestry.services.impl;
+
+import org.apache.tapestry.*;
+import org.apache.tapestry.engine.NullWriter;
+import org.apache.tapestry.services.ResponseBuilder;
+import static org.easymock.EasyMock.expect;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Tests functionality of [EMAIL PROTECTED] PrototypeResponseBuilder}.
+ */
[EMAIL PROTECTED]
+public class PrototypeResponseBuilderTest extends BaseComponentTestCase {
+
+ public void test_Null_Writer_Render()
+ {
+ IRender render = newMock(IRender.class);
+ IRequestCycle cycle = newMock(IRequestCycle.class);
+ IMarkupWriter writer = newBufferWriter();
+
+ ResponseBuilder builder = new PrototypeResponseBuilder(cycle, writer,
null);
+
+ render.render(NullWriter.getSharedInstance(), cycle);
+
+ replay();
+
+ builder.render(writer, render, cycle);
+
+ verify();
+
+ assertSame(builder.getWriter(), writer);
+ assertBuffer("");
+ }
+
+ public void test_Partial_Render()
+ {
+ IRender render = newMock(IRender.class);
+ IComponent comp1 = newMock(IComponent.class);
+ IRequestCycle cycle = newMock(IRequestCycle.class);
+ IMarkupWriter writer = newMock(IMarkupWriter.class);
+ NestedMarkupWriter nested = newMock(NestedMarkupWriter.class);
+
+ List parts = new ArrayList();
+ parts.add("id1");
+
+ PrototypeResponseBuilder builder = new PrototypeResponseBuilder(cycle,
writer, parts);
+
+ render.render(NullWriter.getSharedInstance(), cycle);
+
+ expect(comp1.getClientId()).andReturn("id1").anyTimes();
+ expect(comp1.peekClientId()).andReturn("id1").anyTimes();
+
+ expect(writer.getNestedWriter()).andReturn(nested);
+
+ comp1.render(nested, cycle);
+
+ replay();
+
+ builder.render(null, render, cycle);
+
+ assertTrue(builder.contains(comp1));
+ assertTrue(IComponent.class.isInstance(comp1));
+
+ builder.render(null, comp1, cycle);
+
+ verify();
+
+ assertSame(builder.getWriter(), writer);
+ assertBuffer("");
+ }
+}
Propchange:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/PrototypeResponseBuilderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/PrototypeResponseBuilderTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/PrototypeResponseBuilderTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain