You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by mu...@apache.org on 2007/03/03 06:49:21 UTC
svn commit: r514083 [48/49] - in /struts/struts2/trunk/plugins/dojo: ./ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/struts2/
src/main/java/org/apache/struts2/components/ src/main/java/org/apache/s...
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/niftycorners/nifty.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/niftycorners/nifty.js?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/niftycorners/nifty.js (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/niftycorners/nifty.js Fri Mar 2 21:48:54 2007
@@ -0,0 +1,174 @@
+function NiftyCheck(){
+if(!document.getElementById || !document.createElement)
+ return(false);
+isXHTML=/html\:/.test(document.getElementsByTagName('body')[0].nodeName);
+if(Array.prototype.push==null){Array.prototype.push=function(){
+ this[this.length]=arguments[0]; return(this.length);}}
+return(true);
+}
+
+function Rounded(selector,wich,bk,color,opt){
+var i,prefixt,prefixb,cn="r",ecolor="",edges=false,eclass="",b=false,t=false;
+
+if(color=="transparent"){
+ cn=cn+"x";
+ ecolor=bk;
+ bk="transparent";
+ }
+else if(opt && opt.indexOf("border")>=0){
+ var optar=opt.split(" ");
+ for(i=0;i<optar.length;i++)
+ if(optar[i].indexOf("#")>=0) ecolor=optar[i];
+ if(ecolor=="") ecolor="#666";
+ cn+="e";
+ edges=true;
+ }
+else if(opt && opt.indexOf("smooth")>=0){
+ cn+="a";
+ ecolor=Mix(bk,color);
+ }
+if(opt && opt.indexOf("small")>=0) cn+="s";
+prefixt=cn;
+prefixb=cn;
+if(wich.indexOf("all")>=0){t=true;b=true}
+else if(wich.indexOf("top")>=0) t="true";
+else if(wich.indexOf("tl")>=0){
+ t="true";
+ if(wich.indexOf("tr")<0) prefixt+="l";
+ }
+else if(wich.indexOf("tr")>=0){
+ t="true";
+ prefixt+="r";
+ }
+if(wich.indexOf("bottom")>=0) b=true;
+else if(wich.indexOf("bl")>=0){
+ b="true";
+ if(wich.indexOf("br")<0) prefixb+="l";
+ }
+else if(wich.indexOf("br")>=0){
+ b="true";
+ prefixb+="r";
+ }
+var v=getElementsBySelector(selector);
+var l=v.length;
+for(i=0;i<l;i++){
+ if(edges) AddBorder(v[i],ecolor);
+ if(t) AddTop(v[i],bk,color,ecolor,prefixt);
+ if(b) AddBottom(v[i],bk,color,ecolor,prefixb);
+ }
+}
+
+function AddBorder(el,bc){
+var i;
+if(!el.passed){
+ if(el.childNodes.length==1 && el.childNodes[0].nodeType==3){
+ var t=el.firstChild.nodeValue;
+ el.removeChild(el.lastChild);
+ var d=CreateEl("span");
+ d.style.display="block";
+ d.appendChild(document.createTextNode(t));
+ el.appendChild(d);
+ }
+ for(i=0;i<el.childNodes.length;i++){
+ if(el.childNodes[i].nodeType==1){
+ el.childNodes[i].style.borderLeft="1px solid "+bc;
+ el.childNodes[i].style.borderRight="1px solid "+bc;
+ }
+ }
+ }
+el.passed=true;
+}
+
+function AddTop(el,bk,color,bc,cn){
+var i,lim=4,d=CreateEl("b");
+
+if(cn.indexOf("s")>=0) lim=2;
+if(bc) d.className="artop";
+else d.className="rtop";
+d.style.backgroundColor=bk;
+for(i=1;i<=lim;i++){
+ var x=CreateEl("b");
+ x.className=cn + i;
+ x.style.backgroundColor=color;
+ if(bc) x.style.borderColor=bc;
+ d.appendChild(x);
+ }
+el.style.paddingTop=0;
+el.insertBefore(d,el.firstChild);
+}
+
+function AddBottom(el,bk,color,bc,cn){
+var i,lim=4,d=CreateEl("b");
+
+if(cn.indexOf("s")>=0) lim=2;
+if(bc) d.className="artop";
+else d.className="rtop";
+d.style.backgroundColor=bk;
+for(i=lim;i>0;i--){
+ var x=CreateEl("b");
+ x.className=cn + i;
+ x.style.backgroundColor=color;
+ if(bc) x.style.borderColor=bc;
+ d.appendChild(x);
+ }
+el.style.paddingBottom=0;
+el.appendChild(d);
+}
+
+function CreateEl(x){
+if(isXHTML) return(document.createElementNS('http://www.w3.org/1999/xhtml',x));
+else return(document.createElement(x));
+}
+
+function getElementsBySelector(selector){
+var i,selid="",selclass="",tag=selector,f,s=[],objlist=[];
+
+if(selector.indexOf(" ")>0){ //descendant selector like "tag#id tag"
+ s=selector.split(" ");
+ var fs=s[0].split("#");
+ if(fs.length==1) return(objlist);
+ f=document.getElementById(fs[1]);
+ if(f) return(f.getElementsByTagName(s[1]));
+ return(objlist);
+ }
+if(selector.indexOf("#")>0){ //id selector like "tag#id"
+ s=selector.split("#");
+ tag=s[0];
+ selid=s[1];
+ }
+if(selid!=""){
+ f=document.getElementById(selid);
+ if(f) objlist.push(f);
+ return(objlist);
+ }
+if(selector.indexOf(".")>0){ //class selector like "tag.class"
+ s=selector.split(".");
+ tag=s[0];
+ selclass=s[1];
+ }
+var v=document.getElementsByTagName(tag); // tag selector like "tag"
+if(selclass=="")
+ return(v);
+for(i=0;i<v.length;i++){
+ if(v[i].className.indexOf(selclass)>=0){
+ objlist.push(v[i]);
+ }
+ }
+return(objlist);
+}
+
+function Mix(c1,c2){
+var i,step1,step2,x,y,r=new Array(3);
+if(c1.length==4)step1=1;
+else step1=2;
+if(c2.length==4) step2=1;
+else step2=2;
+for(i=0;i<3;i++){
+ x=parseInt(c1.substr(1+step1*i,step1),16);
+ if(step1==1) x=16*x+x;
+ y=parseInt(c2.substr(1+step2*i,step2),16);
+ if(step2==1) y=16*y+y;
+ r[i]=Math.floor((x*50+y*50)/100);
+ }
+return("#"+r[0].toString(16)+r[1].toString(16)+r[2].toString(16));
+}
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/niftycorners/niftyCorners.css
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/niftycorners/niftyCorners.css?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/niftycorners/niftyCorners.css (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/niftycorners/niftyCorners.css Fri Mar 2 21:48:54 2007
@@ -0,0 +1,21 @@
+.rtop,.artop{display:block}
+.rtop *,.artop *{display:block;height:1px;overflow:hidden;font-size:1px}
+.artop *{border-style: solid;border-width:0 1px}
+.r1,.rl1,.re1,.rel1{margin-left:5px}
+.r1,.rr1,.re1,.rer1{margin-right:5px}
+.r2,.rl2,.re2,.rel2,.ra1,.ral1{margin-left:3px}
+.r2,.rr2,.re2,.rer2,.ra1,.rar1{margin-right:3px}
+.r3,.rl3,.re3,.rel3,.ra2,.ral2,.rs1,.rsl1,.res1,.resl1{margin-left:2px}
+.r3,.rr3,.re3,.rer3,.ra2,.rar2,.rs1,.rsr1,.res1,.resr1{margin-right:2px}
+.r4,.rl4,.rs2,.rsl2,.re4,.rel4,.ra3,.ral3,.ras1,.rasl1,.res2,.resl2{margin-left:1px}
+.r4,.rr4,.rs2,.rsr2,.re4,.rer4,.ra3,.rar3,.ras1,.rasr1,.res2,.resr2{margin-right:1px}
+.rx1,.rxl1{border-left-width:5px}
+.rx1,.rxr1{border-right-width:5px}
+.rx2,.rxl2{border-left-width:3px}
+.rx2,.rxr2{border-right-width:3px}
+.re2,.rel2,.ra1,.ral1,.rx3,.rxl3,.rxs1,.rxsl1{border-left-width:2px}
+.re2,.rer2,.ra1,.rar1,.rx3,.rxr3,.rxs1,.rxsr1{border-right-width:2px}
+.rxl1,.rxl2,.rxl3,.rxl4,.rxsl1,.rxsl2,.ral1,.ral2,.ral3,.ral4,.rasl1,.rasl2{border-right-width:0}
+.rxr1,.rxr2,.rxr3,.rxr4,.rxsr1,.rxsr2,.rar1,.rar2,.rar3,.rar4,.rasr1,.rasr2{border-left-width:0}
+.r4,.rl4,.rr4,.re4,.rel4,.rer4,.ra4,.rar4,.ral4,.rx4,.rxl4,.rxr4{height:2px}
+.rer1,.rel1,.re1,.res1,.resl1,.resr1{border-width:1px 0 0;height:0px !important;height /**/:1px}
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/niftycorners/niftyPrint.css
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/niftycorners/niftyPrint.css?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/niftycorners/niftyPrint.css (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/niftycorners/niftyPrint.css Fri Mar 2 21:48:54 2007
@@ -0,0 +1,2 @@
+.rtop,.artop{display: none}
+
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/niftycorners/niftylayout.css
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/niftycorners/niftylayout.css?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/niftycorners/niftylayout.css (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/niftycorners/niftylayout.css Fri Mar 2 21:48:54 2007
@@ -0,0 +1,57 @@
+/*typography*/
+body{font: 76% verdana,arial,sans-serif;text-align: center}
+h1,h2,h3{font-family: "Trebuchet MS",arial,sans-serif}
+h1{font-size: 200%}
+h2{font-size: 160%}
+h3{font-size:110%;text-transform:uppercase;letter-spacing:1px;margin:0 5px}
+h2,p{margin: 0 15px;padding:0}
+p{padding-bottom: 0.7em;line-height: 1.5}
+a{text-decoration: none}
+address{padding: 3px 15px;font-style:normal}
+div#relax p{font-size: 120%}
+
+
+/*layout*/
+html{height: 100%; margin-bottom: 1px}
+html,body{margin:0;padding:0 0 20px}
+div#container{width: 550px;margin: 0 auto;text-align: left}
+div#header{margin:0 0 10px;padding: 0 0 5px}
+div#header h1{margin:0 5px;padding:60px 0 2px}
+div#header a{margin-left: 10px}
+div#sidebar{float: right;width: 150px}
+div#sidebar div{padding: 5px 0;margin-bottom: 5px}
+div#sidebar div#menu{margin: 0 5px}
+div#nav ul,div#nav li{margin:0;padding:0;list-style-type:none;line-height: 1.5}
+div#nav a{margin-left:5px;padding-left:10px}
+div#sidebar p{margin: 0 5px;padding:0}
+div#sidebar p+p{margin-top: 0.7em}
+form{margin: 5px 0;padding: 5px 0}
+form h3{margin-bottom: 10px}
+form div{padding: 5px 0}
+form input#find{width: 90px;margin-left:10px}
+div#content{width:395px;padding:5px 0}
+blockquote{float:left;display:inline;width: 200px;margin: 0 10px 5px 15px;padding: 5px 0}
+blockquote p{margin:0;padding: 0 5px;text-align: center}
+div#relax{margin: 0 15px 10px;padding: 5px 0}
+div#relax p, div#relax h2{margin: 0 5px}
+div#footer{clear: right;margin-top: 10px}
+
+/*colors*/
+body{background: #D6DEEC}
+div#header{background: #84B7FF}
+div#header h1{background: #657DA6}
+h1 a{color: #C1E6FF}
+h1 a:hover{color: #fff}
+h2{color: #f60}
+h3{color: #B02A36}
+div#nav{background: #95B3DE}
+div#nav a{background: url(bullet.jpg) no-repeat center left;color: #2660B1}
+div#nav a:hover{color: #FFF}
+div#sidenotes{background:#B1C0D5}
+form{background: #B4CEF7}
+div#content{background: #FFF}
+blockquote{background: #CDFFAA}
+div#relax{background: url(relax.jpg)}
+div#relax h2{color: #F7DEB5}
+div#relax p{color: #fff}
+div#footer{background: #CCC;color: #333}
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/optiontransferselect.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/optiontransferselect.js?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/optiontransferselect.js (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/optiontransferselect.js Fri Mar 2 21:48:54 2007
@@ -0,0 +1,163 @@
+function moveSelectedOptions(objSourceElement, objTargetElement, toSort, notMove1, notMove2) {
+ var test1 = compile(notMove1);
+ var test2 = compile(notMove2);
+ moveOptions(objSourceElement, objTargetElement, toSort,
+ function(opt) {
+ return (opt.selected && !test1(opt.value) && !test2(opt.value));
+ }
+ );
+}
+
+function moveAllOptions(objSourceElement, objTargetElement, toSort, notMove1, notMove2) {
+ var test1 = compile(notMove1);
+ var test2 = compile(notMove2);
+ moveOptions(objSourceElement, objTargetElement, toSort,
+ function(opt) {
+ return (!test1(opt.value) && !test2(opt.value));
+ }
+ );
+}
+
+function compile(ptn) {
+ if (ptn != undefined) {
+ if (ptn == '' || !window.RegExp) {
+ return function(val) { return val == ptn; }
+ } else {
+ var reg = new RegExp(ptn);
+ return function (val) {
+ if (val == '') { // ignore empty option added by template
+ return true;
+ }
+ return reg.test(val); }
+ }
+ }
+ return function(val) { return false; }
+}
+
+function moveOptions(objSourceElement, objTargetElement, toSort, chooseFunc) {
+ var aryTempSourceOptions = new Array();
+ var aryTempTargetOptions = new Array();
+ var x = 0;
+
+ //looping through source element to find selected options
+ for (var i = 0; i < objSourceElement.length; i++) {
+ if (chooseFunc(objSourceElement.options[i])) {
+ //need to move this option to target element
+ var intTargetLen = objTargetElement.length++;
+ objTargetElement.options[intTargetLen].text = objSourceElement.options[i].text;
+ objTargetElement.options[intTargetLen].value = objSourceElement.options[i].value;
+ }
+ else {
+ //storing options that stay to recreate select element
+ var objTempValues = new Object();
+ objTempValues.text = objSourceElement.options[i].text;
+ objTempValues.value = objSourceElement.options[i].value;
+ aryTempSourceOptions[x] = objTempValues;
+ x++;
+ }
+ }
+
+ //sorting and refilling target list
+ for (var i = 0; i < objTargetElement.length; i++) {
+ var objTempValues = new Object();
+ objTempValues.text = objTargetElement.options[i].text;
+ objTempValues.value = objTargetElement.options[i].value;
+ aryTempTargetOptions[i] = objTempValues;
+ }
+
+ if (toSort) {
+ aryTempTargetOptions.sort(sortByText);
+ }
+
+ for (var i = 0; i < objTargetElement.length; i++) {
+ objTargetElement.options[i].text = aryTempTargetOptions[i].text;
+ objTargetElement.options[i].value = aryTempTargetOptions[i].value;
+ objTargetElement.options[i].selected = false;
+ }
+
+ //resetting length of source
+ objSourceElement.length = aryTempSourceOptions.length;
+ //looping through temp array to recreate source select element
+ for (var i = 0; i < aryTempSourceOptions.length; i++) {
+ objSourceElement.options[i].text = aryTempSourceOptions[i].text;
+ objSourceElement.options[i].value = aryTempSourceOptions[i].value;
+ objSourceElement.options[i].selected = false;
+ }
+}
+
+function sortByText(a, b) {
+ if (a.text < b.text) {return -1}
+ if (a.text > b.text) {return 1}
+ return 0;
+}
+
+function selectAllOptionsExceptSome(objTargetElement, type, ptn) {
+ var test = compile(ptn);
+ for (var i = 0; i < objTargetElement.length; i++) {
+ var opt = objTargetElement.options[i];
+ if ((type == 'key' && !test(opt.value)) ||
+ (type == 'text' && !test(opt.text))) {
+ opt.selected = true;
+ } else {
+ opt.selected = false;
+ }
+ }
+ return false;
+}
+
+function selectAllOptions(objTargetElement) {
+ for (var i = 0; i < objTargetElement.length; i++) {
+ if (objTargetElement.options[i].value != '') {
+ objTargetElement.options[i].selected = true;
+ }
+ }
+ return false;
+}
+
+function moveOptionUp(objTargetElement, type, ptn) {
+ var test = compile(ptn);
+ for (i=0; i<objTargetElement.length; i++) {
+ if (objTargetElement[i].selected) {
+ var v;
+ if (i != 0 && !objTargetElement[i-1].selected) {
+ if (type == 'key') {
+ v = objTargetElement[i-1].value
+ }
+ else {
+ v = objTargetElement[i-1].text;
+ }
+ if (!test(v)) {
+ swapOptions(objTargetElement,i,i-1);
+ }
+ }
+ }
+ }
+}
+
+function moveOptionDown(objTargetElement, type, ptn) {
+ var test = compile(ptn);
+ for (i=(objTargetElement.length-1); i>= 0; i--) {
+ if (objTargetElement[i].selected) {
+ var v;
+ if ((i != (objTargetElement.length-1)) && !objTargetElement[i+1].selected) {
+ if (type == 'key') {
+ v = objTargetElement[i].value
+ }
+ else {
+ v = objTargetElement[i].text;
+ }
+ if (!test(v)) {
+ swapOptions(objTargetElement,i,i+1);
+ }
+ }
+ }
+ }
+}
+
+function swapOptions(objTargetElement, first, second) {
+ var opt = objTargetElement.options;
+ var temp = new Option(opt[first].text, opt[first].value, opt[first].defaultSelected, opt[first].selected);
+ var temp2= new Option(opt[second].text, opt[second].value, opt[second].defaultSelected, opt[second].selected);
+ opt[first] = temp2;
+ opt[second] = temp;
+}
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/tabs.css
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/tabs.css?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/tabs.css (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/tabs.css Fri Mar 2 21:48:54 2007
@@ -0,0 +1,79 @@
+.tab_header {
+ position: relative;
+ width: 100%;
+ height: 3em;
+ width: 30em; /* a width is required for Opera, older Mozilla browsers, and Konqueror browsers */
+}
+
+.tab_header_main {
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+ position: absolute;
+ bottom: -1px;
+ width: 45em; /* a width is required for Opera, older Mozilla browsers, and Konqueror browsers */
+}
+
+.tab_header_main a {
+ display:block;
+ text-decoration:none;
+ padding:2px 0 5px;
+ color: #FFFFFF
+}
+
+.tab_selected, .tab_unselected, .tab_unselected_over {
+ width: 8em;
+ display: block;
+ float: left;
+ padding: 4px 0;
+ list-style: none;
+ margin: 1px 2px 0 0;
+ text-align: center;
+ font-family: tahoma, verdana, sans-serif;
+ font-size: 85%;
+ text-decoration: none;
+ color: #333;
+}
+
+.tab_selected {
+/* border: 1px solid #666; */
+ border-bottom: none;
+ background: #999999;
+ padding-bottom: 6px;
+ margin-top: 0;
+ font-weight:bold;
+}
+
+.tab_unselected, .tab_unselected_over {
+ background: #A5A5A5;
+/* border: 1px solid #AAA; */
+ border-bottom: none;
+ font-weight:normal;
+}
+
+.tab_unselected_over {
+ margin-top: 0;
+/* border-color: #666; */
+ background: #AAAAAA;
+ padding-bottom: 5px;
+ font-weight:normal;
+}
+
+.tab_contents_header {
+/* border: 2px solid #666; */
+ display: block;
+ clear: both;
+ background: #999999;
+ padding: 2px;
+}
+
+.tab_contents {
+ padding: 1.5em;
+ display: block;
+ background: #DDDDDD;
+ min-height: 300px;
+}
+
+.tab_contents_hidden {
+ display: none;
+}
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/tree.css
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/tree.css?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/tree.css (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/tree.css Fri Mar 2 21:48:54 2007
@@ -0,0 +1,29 @@
+.dojoTree {
+ font: caption;
+ font-size: 11px;
+ font-weight: normal;
+ overflow: auto;
+}
+
+.dojoTreeNodeLabel {
+ padding: 1px 2px;
+ color: WindowText;
+ cursor: default;
+}
+
+.dojoTreeNodeLabel:hover {
+ text-decoration: underline;
+}
+
+.dojoTreeNodeLabelSelected {
+ background-color: Highlight;
+ color: HighlightText;
+}
+
+.dojoTree div {
+ white-space: nowrap;
+}
+
+.dojoTree img {
+ vertical-align: middle;
+}
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/validationClient.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/validationClient.js?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/validationClient.js (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/validationClient.js Fri Mar 2 21:48:54 2007
@@ -0,0 +1,37 @@
+/**
+ *
+ * Common code to interface with the validationServlet
+ *
+ */
+
+function ValidationClient(servletUrl) {
+
+ this.servletUrl = servletUrl;
+
+ this.validate = function(input, namespace, actionName) {
+ var vc = this;
+ var form = input.form;
+ var params = new Object();
+ for (var i = 0; i < form.elements.length; i++) {
+ var e = form.elements[i];
+ if (e.name != null && e.name != '') {
+ params[e.name] = e.value;
+ }
+ }
+
+ validator.doPost(function(action) {
+ if (action) {
+ vc.onErrors(input, action);
+ }
+ }, namespace, actionName, params);
+ }
+
+
+ // @param formObject - the form object that triggered the validate call
+ // @param errors - a javascript object representing the action errors and field errors
+ // client should overwrite this handler to display the new error messages
+ this.onErrors = function(inputObject, errors) {
+ }
+
+ return this;
+}
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/a.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/a.ftl?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/a.ftl (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/a.ftl Fri Mar 2 21:48:54 2007
@@ -0,0 +1,4 @@
+<a dojoType="struts:BindAnchor"
+ <#include "/${parameters.templateDir}/ajax/ajax-common.ftl" />
+ <#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
+>
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/ajax-common.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/ajax-common.ftl?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/ajax-common.ftl (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/ajax-common.ftl Fri Mar 2 21:48:54 2007
@@ -0,0 +1,66 @@
+ <#if parameters.id?if_exists != "">
+ id="${parameters.id?html}"<#rt/>
+ </#if>
+ <#if parameters.formId?if_exists != "">
+ formId="${parameters.formId?html}"<#rt/>
+ </#if>
+ <#if parameters.formFilter?if_exists != "">
+ formFilter="${parameters.formFilter?html}"<#rt/>
+ </#if>
+ <#if parameters.tabindex?if_exists != "">
+ tabindex="${parameters.tabindex?html}"<#rt/>
+ </#if>
+ <#if parameters.cssClass?if_exists != "">
+ class="${parameters.cssClass?html}"<#rt/>
+ </#if>
+ <#if parameters.cssStyle?if_exists != "">
+ style="${parameters.cssStyle?html}"<#rt/>
+ </#if>
+ <#if parameters.label?if_exists != "">
+ label="${parameters.label?html}"<#rt/>
+ </#if>
+ <#if parameters.title?if_exists != "">
+ title="${parameters.title?html}"<#rt/>
+ </#if>
+ <#if parameters.name?if_exists != "">
+ name="${parameters.name?html}"<#rt/>
+ </#if>
+ <#if parameters.href?if_exists != "">
+ href="${parameters.href}"<#rt/>
+ </#if>
+ <#if parameters.loadingText?if_exists != "">
+ loadingText="${parameters.loadingText?html}"<#rt/>
+ </#if>
+ <#if parameters.errorText?if_exists != "">
+ errorText="${parameters.errorText?html}"<#rt/>
+ </#if>
+ <#if parameters.executeScripts?exists>
+ executeScripts="${parameters.executeScripts?string?html}"<#rt/>
+ </#if>
+ <#if parameters.listenTopics?if_exists != "">
+ listenTopics="${parameters.listenTopics?html}"<#rt/>
+ </#if>
+ <#if parameters.notifyTopics?if_exists != "">
+ notifyTopics="${parameters.notifyTopics?html}"<#rt/>
+ </#if>
+ <#if parameters.beforeLoading?if_exists != "">
+ beforeLoading="${parameters.beforeLoading?html}"<#rt/>
+ </#if>
+ <#if parameters.afterLoading?if_exists != "">
+ afterLoading="${parameters.afterLoading?html}"<#rt/>
+ </#if>
+ <#if parameters.targets?if_exists != "">
+ targets="${parameters.targets?html}"<#rt/>
+ </#if>
+ <#if parameters.handler?if_exists != "">
+ handler="${parameters.handler?html}"<#rt/>
+ </#if>
+ <#if parameters.indicator?if_exists != "">
+ indicator="${parameters.indicator?html}"<#rt/>
+ </#if>
+ <#if parameters.showErrorTransportText?exists>
+ showError="${parameters.showErrorTransportText?string?html}"<#rt/>
+ </#if>
+ <#if parameters.showLoadingText?exists>
+ showLoading="${parameters.showLoadingText?string?html}"<#rt/>
+ </#if>
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/autocompleter.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/autocompleter.ftl?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/autocompleter.ftl (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/autocompleter.ftl Fri Mar 2 21:48:54 2007
@@ -0,0 +1,96 @@
+<input dojoType="struts:ComboBox"<#rt/>
+<#if parameters.id?if_exists != "">
+ id="${parameters.id?html}"<#rt/>
+</#if>
+<#if parameters.cssClass?if_exists != "">
+ class="${parameters.cssClass?html}"<#rt/>
+</#if>
+<#if parameters.cssStyle?if_exists != "">
+ style="${parameters.cssStyle?html}"<#rt/>
+</#if>
+<#if parameters.href?if_exists != "">
+ dataUrl="${parameters.href}"<#rt/>
+</#if>
+<#if parameters.forceValidOption?exists>
+ forceValidOption="${parameters.forceValidOption?string?html}"<#rt/>
+</#if>
+<#if parameters.searchType?if_exists != "">
+ searchType="${parameters.searchType?html}"<#rt/>
+</#if>
+<#if parameters.autoComplete?exists>
+ autoComplete="${parameters.autoComplete?string?html}"<#rt/>
+</#if>
+<#if parameters.delay?exists>
+ searchDelay="${parameters.delay?c}"<#rt/>
+</#if>
+<#if parameters.disabled?exists>
+ disabled="${parameters.disabled?string?html}"<#rt/>
+</#if>
+<#if parameters.dropdownWidth?exists>
+ dropdownWidth="${parameters.dropdownWidth?c}"<#rt/>
+</#if>
+<#if parameters.dropdownHeight?exists>
+ dropdownHeight="${parameters.dropdownHeight?c}"<#rt/>
+</#if>
+<#if parameters.name?if_exists != "">
+ name="${parameters.name?html}"<#rt/>
+</#if>
+<#if parameters.get("size")?exists>
+ size="${parameters.get("size")?html}"<#rt/>
+</#if>
+<#if parameters.keyName?if_exists != "">
+ keyName="${parameters.keyName?html}"<#rt/>
+</#if>
+<#if parameters.maxlength?exists>
+ maxlength="${parameters.maxlength?string?html}"<#rt/>
+</#if>
+<#if parameters.nameValue?if_exists != "">
+ initialValue="${parameters.nameValue}"<#rt/>
+</#if>
+<#if parameters.key?if_exists != "">
+ initialKey="${parameters.key}"<#rt/>
+</#if>
+<#if parameters.readonly?default(false)>
+ readonly="readonly"<#rt/>
+</#if>
+<#if parameters.tabindex?exists>
+ tabindex="${parameters.tabindex?html}"<#rt/>
+</#if>
+<#if parameters.formId?if_exists != "">
+ formId="${parameters.formId?html}"<#rt/>
+</#if>
+<#if parameters.formFilter?if_exists != "">
+ formFilter="${parameters.formFilter?html}"<#rt/>
+</#if>
+<#if parameters.listenTopics?if_exists != "">
+ listenTopics="${parameters.listenTopics?html}"<#rt/>
+</#if>
+<#if parameters.notifyTopics?if_exists != "">
+ notifyTopics="${parameters.notifyTopics?html}"<#rt/>
+</#if>
+<#if parameters.indicator?if_exists != "">
+ indicator="${parameters.indicator?html}"<#rt/>
+</#if>
+<#if parameters.loadOnTextChange?default(false)>
+ loadOnType="${parameters.loadOnTextChange?string?html}"<#rt/>
+</#if>
+<#if parameters.loadMinimumCount?exists>
+ loadMinimum="${parameters.loadMinimumCount?c}"<#rt/>
+</#if>
+<#if parameters.showDownArrow?exists>
+ visibleDownArrow="${parameters.showDownArrow?string?html}"<#rt/>
+</#if>
+<#if parameters.iconPath?if_exists != "">
+ buttonSrc="<@s.url value='${parameters.iconPath}' encode="false" includeParams='none'/>"<#rt/>
+</#if>
+<#if parameters.templateCssPath?if_exists != "">
+ templateCssPath="<@s.url value='${parameters.templateCssPath}' encode="false" includeParams='none'/>"
+</#if>
+<#if parameters.dataFieldName?if_exists != "">
+ dataFieldName="${parameters.dataFieldName?html}"
+</#if>
+<#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
+>
+
+
+
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/controlheader.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/controlheader.ftl?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/controlheader.ftl (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/controlheader.ftl Fri Mar 2 21:48:54 2007
@@ -0,0 +1,11 @@
+<#--include "/${parameters.templateDir}/xhtml/controlheader-core.ftl" /-->
+<#if parameters.form?exists && parameters.form.validate?default(false) == true>
+ <#-- can't mutate the data model in freemarker -->
+ <#if parameters.onblur?exists>
+ ${tag.addParameter('onblur', "validate(this);${parameters.onblur}")}
+ <#else>
+ ${tag.addParameter('onblur', "validate(this);")}
+ </#if>
+</#if>
+<#include "/${parameters.templateDir}/${themeProperties.parent}/controlheader.ftl" />
+
\ No newline at end of file
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/div-close.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/div-close.ftl?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/div-close.ftl (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/div-close.ftl Fri Mar 2 21:48:54 2007
@@ -0,0 +1 @@
+</div>
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/div.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/div.ftl?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/div.ftl (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/div.ftl Fri Mar 2 21:48:54 2007
@@ -0,0 +1,25 @@
+<div dojoType="struts:BindDiv"
+ <#if parameters.delay?exists>
+ delay="${parameters.delay?c}"<#rt/>
+ </#if>
+ <#if parameters.updateFreq?exists>
+ updateFreq="${parameters.updateFreq?c}"<#rt/>
+ </#if>
+ <#if parameters.autoStart?exists>
+ autoStart="${parameters.autoStart?string?html}"<#rt/>
+ </#if>
+ <#if parameters.startTimerListenTopics?if_exists != "">
+ startTimerListenTopics="${parameters.startTimerListenTopics?html}"<#rt/>
+ </#if>
+ <#if parameters.stopTimerListenTopics?if_exists != "">
+ stopTimerListenTopics="${parameters.stopTimerListenTopics?html}"<#rt/>
+ </#if>
+ <#if parameters.refreshOnShow?exists>
+ refreshOnShow="${parameters.refreshOnShow?string?html}"<#rt/>
+ </#if>
+ <#if parameters.separateScripts?exists>
+ scriptSeparation="${parameters.separateScripts?string?html}"<#rt/>
+ </#if>
+ <#include "/${parameters.templateDir}/ajax/ajax-common.ftl" />
+ <#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
+>
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/dojoRequire.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/dojoRequire.js?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/dojoRequire.js (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/dojoRequire.js Fri Mar 2 21:48:54 2007
@@ -0,0 +1,14 @@
+dojo.require("dojo.io.BrowserIO");
+dojo.require("dojo.event.topic");
+
+dojo.hostenv.setModulePrefix('struts', 'struts');
+dojo.require('dojo.widget.*');
+dojo.widget.manager.registerWidgetPackage('struts.widget');
+
+dojo.require("struts.widget.Bind");
+dojo.require("struts.widget.BindDiv");
+dojo.require("struts.widget.BindAnchor");
+dojo.require("struts.widget.ComboBox");
+dojo.require("struts.widget.StrutsTimePicker")
+dojo.require("dojo.widget.Editor2");
+dojo.hostenv.writeIncludes(); // not needed, but allows the Venkman debugger to work with the includes
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/form-close.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/form-close.ftl?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/form-close.ftl (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/form-close.ftl Fri Mar 2 21:48:54 2007
@@ -0,0 +1,89 @@
+
+<#if (parameters.customOnsubmitEnabled?default(false))>
+<script type="text/javascript">
+<#--
+ Enable auto-select of optiontransferselect tag's entries upon containing form's
+ submission.
+-->
+dojo.require("dojo.event.connect");
+<#if (parameters.optiontransferselectIds?if_exists?size > 0)>
+ var containingForm = document.getElementById("${parameters.id}");
+ <#assign selectObjIds = parameters.optiontransferselectIds.keySet() />
+ <#list selectObjIds as selectObjectId>
+ dojo.event.connect(containingForm, "onsubmit",
+ function(evt) {
+ var selectObj = document.getElementById("${selectObjectId}");
+ <#if parameters.optiontransferselectIds.get(selectObjectId)?exists>
+ <#assign selectTagHeaderKey = parameters.optiontransferselectIds.get(selectObjectId)/>
+ selectAllOptionsExceptSome(selectObj, "key", "${selectTagHeaderKey}");
+ <#else>
+ selectAllOptionsExceptSome(selectObj, "key", "");
+ </#if>
+ });
+ </#list>
+</#if>
+<#if (parameters.inputtransferselectIds?if_exists?size > 0)>
+ var containingForm = document.getElementById("${parameters.id}");
+ <#assign selectObjIds = parameters.inputtransferselectIds.keySet() />
+ <#list selectObjIds as selectObjectId>
+ dojo.event.connect(containingForm, "onsubmit",
+ function(evt) {
+ var selectObj = document.getElementById("${selectObjectId}");
+ <#if parameters.inputtransferselectIds.get(selectObjectId)?exists>
+ <#assign selectTagHeaderKey = parameters.inputtransferselectIds.get(selectObjectId)/>
+ selectAllOptionsExceptSome(selectObj, "key", "${selectTagHeaderKey}");
+ <#else>
+ selectAllOptionsExceptSome(selectObj, "key", "");
+ </#if>
+ });
+ </#list>
+</#if>
+<#if (parameters.optiontransferselectDoubleIds?if_exists?size > 0)>
+ var containingForm = document.getElementById("${parameters.id}");
+ <#assign selectDoubleObjIds = parameters.optiontransferselectDoubleIds.keySet() />
+ <#list selectDoubleObjIds as selectObjId>
+ dojo.event.connect(containingForm, "onsubmit",
+ function(evt) {
+ var selectObj = document.getElementById("${selectObjId}");
+ <#if parameters.optiontransferselectDoubleIds.get(selectObjId)?exists>
+ <#assign selectTagHeaderKey = parameters.optiontransferselectDoubleIds.get(selectObjId)/>
+ selectAllOptionsExceptSome(selectObj, "key", "${selectTagHeaderKey}");
+ <#else>
+ selectAllOptionsExceptSome(selectObj, "key", "");
+ </#if>
+ });
+ </#list>
+</#if>
+
+
+<#--
+ Enable auto-select of all elements of updownselect tag upon its containing form
+ submission
+-->
+<#if (parameters.updownselectIds?if_exists?size > 0)>
+ var containingForm = document.getElementById("${parameters.id}");
+ <#assign tmpIds = parameters.updownselectIds.keySet() />
+ <#list tmpIds as tmpId>
+ dojo.event.connect(containingForm, "onsubmit",
+ function(evt) {
+ var updownselectObj = document.getElementById("${tmpId}");
+ <#if parameters.updownselectIds.get(tmpId)?exists>
+ <#assign tmpHeaderKey = parameters.updownselectIds.get(tmpId) />
+ selectAllOptionsExceptSome(updownselectObj, "key", "${tmpHeaderKey}");
+ <#else>
+ selectAllOptionsExceptSome(updownselectObj, "key", "");
+ </#if>
+ });
+ </#list>
+</#if>
+</script>
+</#if>
+
+<#--
+ Code that will add javascript needed for tooltips
+--><#t/>
+ <#lt/><!-- javascript that is needed for tooltips -->
+ <#lt/><script language="JavaScript" type="text/javascript">dojo.require("dojo.widget.html.Tooltip");dojo.require("dojo.fx.html");</script>
+
+</table>
+</form>
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/form.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/form.ftl?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/form.ftl (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/form.ftl Fri Mar 2 21:48:54 2007
@@ -0,0 +1,47 @@
+<#if parameters.validate?exists>
+<script type="text/javascript" src="${base}/struts/validationClient.js"></script>
+<script type="text/javascript" src="${base}/dwr/interface/validator.js"></script>
+<script type="text/javascript" src="${base}/dwr/engine.js"></script>
+<script type="text/javascript" src="${base}/struts/ajax/validation.js"></script>
+<script type="text/javascript" src="${base}/struts/${themeProperties.parent}/validation.js"></script>
+</#if>
+<form<#rt/>
+<#if parameters.namespace?exists>
+ namespace="${parameters.namespace?html}"<#rt/>
+</#if>
+<#if parameters.id?exists>
+ id="${parameters.id?html}"<#rt/>
+</#if>
+<#if parameters.name?exists>
+ name="${parameters.name?html}"<#rt/>
+</#if>
+<#if parameters.action?exists>
+ action="${parameters.action?html}"<#rt/>
+</#if>
+<#if parameters.target?exists>
+ target="${parameters.target?html}"<#rt/>
+</#if>
+<#if parameters.method?exists>
+ method="${parameters.method?html}"<#rt/>
+</#if>
+<#if parameters.enctype?exists>
+ enctype="${parameters.enctype?html}"<#rt/>
+</#if>
+<#if parameters.cssClass?exists>
+ class="${parameters.cssClass?html}"<#rt/>
+</#if>
+<#if parameters.acceptcharset?exists>
+ accept-charset="${parameters.acceptcharset?html}"<#rt/>
+</#if>
+<#if parameters.cssStyle?exists>
+ style="${parameters.cssStyle?html}"<#rt/>
+</#if>
+ ${tag.addParameter("ajaxSubmit", "true")}
+>
+<#include "/${parameters.templateDir}/${themeProperties.parent}/control.ftl" />
+<#--
+<table class="${parameters.cssClass?default('wwFormTable')?html}"<#rt/>
+<#if parameters.cssStyle?exists> style="${parameters.cssStyle?html}"<#rt/>
+</#if>
+>
+-->
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/head.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/head.ftl?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/head.ftl (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/head.ftl Fri Mar 2 21:48:54 2007
@@ -0,0 +1,6 @@
+<#--include "/${parameters.templateDir}/xhtml/head.ftl" /-->
+<#include "/${parameters.templateDir}/${themeProperties.parent}/head.ftl" />
+<script language="JavaScript" type="text/javascript"
+ src="<@s.url value='/struts/ajax/dojoRequire.js' includeParams='none' encode='false' />"></script>
+<script language="JavaScript" type="text/javascript"
+ src="<@s.url value='/struts/CommonFunctions.js' includeParams='none' encode='false'/>"></script>
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/submit.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/submit.ftl?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/submit.ftl (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/submit.ftl Fri Mar 2 21:48:54 2007
@@ -0,0 +1,41 @@
+<tr>
+ <td colspan="2"><div <#rt/>
+<#if parameters.align?exists>
+ align="${parameters.align?html}"<#t/>
+</#if>
+><#t/>
+<#if parameters.type?exists && parameters.type=="button">
+ <input type="button" dojoType="struts:Bind" event="onclick"<#rt/>
+ <#include "/${parameters.templateDir}/ajax/ajax-common.ftl"/>
+ <#include "/${parameters.templateDir}/simple/scripting-events.ftl"/>
+ <#include "/${parameters.templateDir}/simple/common-attributes.ftl" />
+ <#if parameters.label?if_exists != "">
+ value="${parameters.label?html}"<#rt/>
+ </#if>
+ />
+<#else>
+ <#if parameters.type?exists && parameters.type=="image">
+ <input type="image" dojoType="struts:Bind" event="onclick"<#rt/>
+ <#if parameters.label?if_exists != "">
+ alt="${parameters.label?html}"<#rt/>
+ </#if>
+ <#if parameters.src?if_exists != "">
+ src="${parameters.src?html}"<#rt/>
+ </#if>
+ <#else>
+ <input type="submit" dojoType="struts:Bind" event="onclick"<#rt/>
+ </#if>
+ <#if parameters.nameValue?if_exists != "">
+ value="${parameters.nameValue?html}"<#rt/>
+ </#if>
+ <#if parameters.value?if_exists != "">
+ value="${parameters.value?html}"<#rt/>
+ </#if>
+ <#include "/${parameters.templateDir}/ajax/ajax-common.ftl"/>
+ <#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
+ <#include "/${parameters.templateDir}/simple/common-attributes.ftl" />
+ />
+</#if>
+
+</div><#t/>
+<#include "/${parameters.templateDir}/xhtml/controlfooter.ftl" />
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/tab-close.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/tab-close.ftl?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/tab-close.ftl (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/tab-close.ftl Fri Mar 2 21:48:54 2007
@@ -0,0 +1 @@
+</div>
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/tab.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/tab.ftl?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/tab.ftl (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/tab.ftl Fri Mar 2 21:48:54 2007
@@ -0,0 +1,23 @@
+<div id="${parameters.id}" cacheContent="false"
+ <#if parameters.title?if_exists != "">
+ label="${parameters.title?html}"<#rt/>
+ </#if>
+ <#if parameters.href?if_exists != "">
+ dojoType="LinkPane" <#rt/>
+ href="${parameters.href}"<#rt/>
+ <#else>
+ dojoType="ContentPane"<#rt/>
+ </#if>
+ <#if parameters.cssStyle?if_exists != "">
+ style="${parameters.cssStyle?html}"<#rt/>
+ </#if>
+ <#if parameters.cssClass?if_exists != "">
+ class="${parameters.cssClass?html}"<#rt/>
+ </#if>
+ <#if parameters.closeButton?if_exists != "">
+ closeButton="${parameters.closeButton?html}"<#rt/>
+ </#if>
+ <#if parameters.refreshOnShow?if_exists != "">
+ refreshOnShow="${parameters.refreshOnShow?html}"<#rt/>
+ </#if>
+>
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/textarea.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/textarea.ftl?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/textarea.ftl (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/textarea.ftl Fri Mar 2 21:48:54 2007
@@ -0,0 +1,45 @@
+<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
+
+<textarea<#rt/>
+ dojoType="Editor2"
+<#if parameters.editorControls?exists>
+ items="${parameters.editorControls?html}"<#rt/>
+<#else>
+ items="linkGroup;|;textGroup;|;justifyGroup;|;listGroup;|;indentGroup;|;colorGroup"
+</#if>
+ name="${parameters.name?default("")?html}"<#rt/>
+ cols="${parameters.cols?default("")?html}"<#rt/>
+ rows="${parameters.rows?default("")?html}"<#rt/>
+<#if parameters.wrap?exists>
+ wrap="${parameters.wrap?html}"<#rt/>
+</#if>
+<#if parameters.disabled?default(false)>
+ disabled="disabled"<#rt/>
+</#if>
+<#if parameters.readonly?default(false)>
+ readonly="readonly"<#rt/>
+</#if>
+<#if parameters.tabindex?exists>
+ tabindex="${parameters.tabindex?html}"<#rt/>
+</#if>
+<#if parameters.id?exists>
+ id="${parameters.id?html}"<#rt/>
+</#if>
+<#if parameters.cssClass?exists>
+ class="${parameters.cssClass?html}"<#rt/>
+</#if>
+<#if parameters.cssStyle?exists>
+ style="${parameters.cssStyle?html}"<#rt/>
+</#if>
+<#if parameters.title?exists>
+ title="${parameters.title?html}"<#rt/>
+</#if>
+<#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
+><#rt/>
+<#if parameters.nameValue?exists>
+<@s.property value="parameters.nameValue"/><#t/>
+</#if>
+</textarea>
+
+<#--include "/${parameters.templateDir}/xhtml/controlfooter.ftl" /-->
+<#include "/${parameters.templateDir}/${themeProperties.parent}/controlfooter.ftl" />
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/theme.properties
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/theme.properties?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/theme.properties (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/theme.properties Fri Mar 2 21:48:54 2007
@@ -0,0 +1 @@
+parent=xhtml
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/tree-close.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/tree-close.ftl?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/tree-close.ftl (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/tree-close.ftl Fri Mar 2 21:48:54 2007
@@ -0,0 +1 @@
+<#if parameters.label?exists></div></#if></div>
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/tree.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/tree.ftl?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/tree.ftl (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/tree.ftl Fri Mar 2 21:48:54 2007
@@ -0,0 +1,86 @@
+ <script language="JavaScript" type="text/javascript">
+ <!--
+ dojo.require("dojo.lang.*");
+ dojo.require("dojo.widget.*");
+ dojo.require("dojo.widget.Tree");
+ // dojo.hostenv.writeIncludes();
+ -->
+ </script>
+<div dojoType="Tree"
+ <#if parameters.blankIconSrc?exists>
+ gridIconSrcT="<@s.url value='${parameters.blankIconSrc}' encode="false" includeParams='none'/>"
+ </#if>
+ <#if parameters.gridIconSrcL?exists>
+ gridIconSrcL="<@s.url value='${parameters.gridIconSrcL}' encode="false" includeParams='none'/>"
+ </#if>
+ <#if parameters.gridIconSrcV?exists>
+ gridIconSrcV="<@s.url value='${parameters.gridIconSrcV}' encode="false" includeParams='none'/>"
+ </#if>
+ <#if parameters.gridIconSrcP?exists>
+ gridIconSrcP="<@s.url value='${parameters.gridIconSrcP}' encode="false" includeParams='none'/>"
+ </#if>
+ <#if parameters.gridIconSrcC?exists>
+ gridIconSrcC="<@s.url value='${parameters.gridIconSrcC}' encode="false" includeParams='none'/>"
+ </#if>
+ <#if parameters.gridIconSrcX?exists>
+ gridIconSrcX="<@s.url value='${parameters.gridIconSrcX}' encode="false" includeParams='none'/>"
+ </#if>
+ <#if parameters.gridIconSrcY?exists>
+ gridIconSrcY="<@s.url value='${parameters.gridIconSrcY}' encode="false" includeParams='none'/>"
+ </#if>
+ <#if parameters.gridIconSrcZ?exists>
+ gridIconSrcZ="<@s.url value='${parameters.gridIconSrcZ}' encode="false" includeParams='none'/>"
+ </#if>
+ <#if parameters.expandIconSrcPlus?exists>
+ expandIconSrcPlus="<@s.url value='${parameters.expandIconSrcPlus}' includeParams='none'/>"
+ </#if>
+ <#if parameters.expandIconSrcMinus?exists>
+ expandIconSrcMinus="<@s.url value='${parameters.expandIconSrcMinus?html}' includeParams='none'/>"
+ </#if>
+ <#if parameters.iconWidth?exists>
+ iconWidth="<@s.url value='${parameters.iconWidth?html}' encode="false" includeParams='none'/>"
+ </#if>
+ <#if parameters.iconHeight?exists>
+ iconHeight="<@s.url value='${parameters.iconHeight?html}' encode="false" includeParams='none'/>"
+ </#if>
+ <#if parameters.toggleDuration?exists>
+ toggleDuration=${parameters.toggleDuration?c}
+ </#if>
+ <#if parameters.templateCssPath?exists>
+ templateCssPath="<@s.url value='${parameters.templateCssPath}' encode="false" includeParams='none'/>"
+ </#if>
+ <#if parameters.showGrid?exists>
+ showGrid="${parameters.showGrid?default(true)?string}"
+ </#if>
+ <#if parameters.showRootGrid?exists>
+ showRootGrid="${parameters.showRootGrid?default(true)?string}"
+ </#if>
+ <#if parameters.id?exists>
+ id="${parameters.id?html}"
+ </#if>
+ <#if parameters.treeSelectedTopic?exists>
+ publishSelectionTopic="${parameters.treeSelectedTopic?html}"
+ </#if>
+ <#if parameters.treeExpandedTopic?exists>
+ publishExpandedTopic="${parameters.treeExpandedTopic?html}"
+ </#if>
+ <#if parameters.treeCollapsedTopic?exists>
+ publishCollapsedTopic="${parameters.treeCollapsedTopic?html}"
+ </#if>
+ <#if parameters.toggle?exists>
+ toggle="${parameters.toggle?html}"
+ </#if>
+ >
+ <#if parameters.label?exists>
+ <div dojoType="TreeNode" title="${parameters.label?html}"
+ <#if parameters.nodeIdProperty?exists>
+ id="${stack.findValue(parameters.nodeIdProperty)}"
+ <#else>
+ id="${parameters.id}_root"
+ </#if>
+ >
+ <#elseif parameters.rootNode?exists>
+ ${stack.push(parameters.rootNode)}
+ <#include "/${parameters.templateDir}/ajax/treenode-include.ftl" />
+ <#assign oldNode = stack.pop()/> <#-- pop the node off of the stack, but don't show it -->
+ </#if>
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/treenode-close.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/treenode-close.ftl?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/treenode-close.ftl (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/treenode-close.ftl Fri Mar 2 21:48:54 2007
@@ -0,0 +1 @@
+</div>
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/treenode-include.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/treenode-include.ftl?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/treenode-include.ftl (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/treenode-include.ftl Fri Mar 2 21:48:54 2007
@@ -0,0 +1,7 @@
+<div dojoType="TreeNode" title="${stack.findValue(parameters.nodeTitleProperty)}" id="${stack.findValue(parameters.nodeIdProperty)}">
+<#list stack.findValue(parameters.childCollectionProperty.toString()) as child>
+ ${stack.push(child)}
+ <#include "/${parameters.templateDir}/ajax/treenode-include.ftl" />
+ <#assign oldNode = stack.pop() /> <#-- pop the node off of the stack, but don't show it -->
+</#list>
+</div>
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/treenode.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/treenode.ftl?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/treenode.ftl (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/treenode.ftl Fri Mar 2 21:48:54 2007
@@ -0,0 +1,6 @@
+<div dojoType="TreeNode"
+ <#if parameters.childIconSrc?exists>
+ childIconSrc="<@s.url value='${parameters.childIconSrc}' includeParams='none' encode='false' />"
+ </#if>
+ <#if parameters.id?exists>id="${parameters.id?html}"</#if>
+ title="${parameters.label}">
Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/validation.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/validation.js?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/validation.js (added)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/validation.js Fri Mar 2 21:48:54 2007
@@ -0,0 +1,26 @@
+var strutsValidator = new ValidationClient("$!base/validation");
+strutsValidator.onErrors = function(input, errors) {
+
+ var form = input.form;
+
+ clearErrorMessages(form);
+ clearErrorLabels(form);
+
+ if (errors.fieldErrors) {
+ for (var fieldName in errors.fieldErrors) {
+ if (form.elements[fieldName].touched) {
+ for (var i = 0; i < errors.fieldErrors[fieldName].length; i++) {
+ addError(form.elements[fieldName], errors.fieldErrors[fieldName][i]);
+ }
+ }
+ }
+ }
+}
+
+function validate(element) {
+ // mark the element as touch
+ element.touched = true;
+ var namespace = element.form.attributes['namespace'].nodeValue;
+ var actionName = element.form.attributes['name'].nodeValue;
+ strutsValidator.validate(element, namespace, actionName);
+}
Added: struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/TestAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/TestAction.java?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/TestAction.java (added)
+++ struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/TestAction.java Fri Mar 2 21:48:54 2007
@@ -0,0 +1,141 @@
+/*
+ * $Id: TestAction.java 508508 2007-02-16 17:34:22Z hermanns $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+
+import com.opensymphony.xwork2.Action;
+import com.opensymphony.xwork2.ActionSupport;
+
+
+/**
+ */
+public class TestAction extends ActionSupport {
+
+ private static final long serialVersionUID = -8891365561914451494L;
+
+ private Collection collection;
+ private Collection collection2;
+ private Map map;
+ private String foo;
+ private Integer fooInt;
+ private String result;
+ private String[] array;
+ private String[][] list;
+ private List list2;
+ private List list3;
+
+ public Collection getCollection() {
+ return collection;
+ }
+
+ public void setCollection(Collection collection) {
+ this.collection = collection;
+ }
+
+ public Map getMap() {
+ return map;
+ }
+
+ public void setMap(Map map) {
+ this.map = map;
+ }
+
+ public String getFoo() {
+ return foo;
+ }
+
+ public void setFoo(String foo) {
+ this.foo = foo;
+ }
+
+ public String getResult() {
+ return result;
+ }
+
+ public void setResult(String result) {
+ this.result = result;
+ }
+
+ public String[] getArray() {
+ return array;
+ }
+
+ public void setArray(String[] array) {
+ this.array = array;
+ }
+
+ public String[][] getList() {
+ return list;
+ }
+
+ public void setList(String[][] list) {
+ this.list = list;
+ }
+
+ public List getList2() {
+ return list2;
+ }
+
+ public void setList2(List list2) {
+ this.list2 = list2;
+ }
+
+ public void setList3(List list) {
+ this.list3 = list;
+ }
+
+ public List getList3() {
+ return this.list3;
+ }
+
+ public Collection getCollection2() {
+ return this.collection2;
+ }
+
+ public void setCollection2(Collection collection) {
+ this.collection2 = collection;
+ }
+
+ public Integer getFooInt() {
+ return fooInt;
+ }
+
+ public void setFooInt(Integer fooInt) {
+ this.fooInt = fooInt;
+ }
+
+ public String execute() throws Exception {
+ if (result == null) {
+ result = Action.SUCCESS;
+ }
+
+ return result;
+ }
+
+ public String doInput() throws Exception {
+ return INPUT;
+ }
+
+}
Added: struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/views/jsp/ui/AbstractTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/views/jsp/ui/AbstractTagTest.java?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/views/jsp/ui/AbstractTagTest.java (added)
+++ struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/views/jsp/ui/AbstractTagTest.java Fri Mar 2 21:48:54 2007
@@ -0,0 +1,138 @@
+/*
+ * $Id: AbstractTagTest.java 476696 2006-11-19 03:56:18Z tmjee $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.jsp.ui;
+
+import java.io.File;
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.JspWriter;
+
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.StrutsTestCase;
+import org.apache.struts2.TestAction;
+import org.apache.struts2.dispatcher.ApplicationMap;
+import org.apache.struts2.dispatcher.Dispatcher;
+import org.apache.struts2.dispatcher.RequestMap;
+import org.apache.struts2.dispatcher.SessionMap;
+
+import com.mockobjects.dynamic.Mock;
+import com.opensymphony.xwork2.Action;
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.util.ValueStack;
+import com.opensymphony.xwork2.util.ValueStackFactory;
+
+
+/**
+ * Base class to extend for unit testing UI Tags.
+ *
+ */
+public abstract class AbstractTagTest extends StrutsTestCase {
+ protected Action action;
+ protected Map context;
+ protected Map session;
+ protected ValueStack stack;
+
+ /**
+ * contains the buffer that our unit test will write to. we can later verify this buffer for correctness.
+ */
+ protected StringWriter writer;
+ protected StrutsMockHttpServletRequest request;
+ protected StrutsMockPageContext pageContext;
+ protected HttpServletResponse response;
+ protected StrutsMockServletContext servletContext;
+
+ protected Mock mockContainer;
+
+ /**
+ * Constructs the action that we're going to test against. For most UI tests, this default action should be enough.
+ * However, simply override getAction to return a custom Action if you need something more sophisticated.
+ *
+ * @return the Action to be added to the ValueStack as part of the unit test
+ */
+ public Action getAction() {
+ return new TestAction();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ /**
+ * create our standard mock objects
+ */
+ action = this.getAction();
+ stack = ValueStackFactory.getFactory().createValueStack();
+ context = stack.getContext();
+ stack.push(action);
+
+ request = new StrutsMockHttpServletRequest();
+ request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack);
+ response = new StrutsMockHttpServletResponse();
+ request.setSession(new StrutsMockHttpSession());
+ request.setupGetServletPath("/");
+
+ writer = new StringWriter();
+
+ JspWriter jspWriter = new StrutsMockJspWriter(writer);
+
+ servletContext = new StrutsMockServletContext();
+ servletContext.setRealPath(new File("nosuchfile.properties").getAbsolutePath());
+ servletContext.setServletInfo("Resin");
+
+ pageContext = new StrutsMockPageContext();
+ pageContext.setRequest(request);
+ pageContext.setResponse(response);
+ pageContext.setJspWriter(jspWriter);
+ pageContext.setServletContext(servletContext);
+
+ mockContainer = new Mock(Container.class);
+ Dispatcher du = new Dispatcher(pageContext.getServletContext(), new HashMap());
+ du.init();
+ Dispatcher.setInstance(du);
+ du.setConfigurationManager(configurationManager);
+ session = new SessionMap(request);
+ Map extraContext = du.createContextMap(new RequestMap(request),
+ request.getParameterMap(),
+ session,
+ new ApplicationMap(pageContext.getServletContext()),
+ request,
+ response,
+ pageContext.getServletContext());
+ // let's not set the locale -- there is a test that checks if Dispatcher actually picks this up...
+ // ... but generally we want to just use no locale (let it stay system default)
+ extraContext.remove(ActionContext.LOCALE);
+ stack.getContext().putAll(extraContext);
+
+ context.put(ServletActionContext.HTTP_REQUEST, request);
+ context.put(ServletActionContext.HTTP_RESPONSE, response);
+ context.put(ServletActionContext.SERVLET_CONTEXT, servletContext);
+
+ ActionContext.setContext(new ActionContext(context));
+ }
+
+ protected void tearDown() throws Exception {
+ pageContext.verify();
+ request.verify();
+ }
+}
Added: struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/views/jsp/ui/AbstractUITagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/views/jsp/ui/AbstractUITagTest.java?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/views/jsp/ui/AbstractUITagTest.java (added)
+++ struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/views/jsp/ui/AbstractUITagTest.java Fri Mar 2 21:48:54 2007
@@ -0,0 +1,361 @@
+/*
+ * $Id: AbstractUITagTest.java 474560 2006-11-13 23:09:31Z hermanns $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.jsp.ui;
+
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.views.jsp.ui.AbstractUITag;
+
+import com.opensymphony.xwork2.ActionContext;
+
+
+/**
+ */
+public abstract class AbstractUITagTest extends AbstractTagTest {
+
+ private static final Log LOG = LogFactory.getLog(AbstractUITagTest.class);
+
+ static final String FREEMARKER_ERROR_EXPECTATION = "Java backtrace for programmers:";
+
+ /**
+ * Simple helper class for generic tag property testing mechanism. Basically it holds a property name, a property
+ * value and an output to be expected in tag output when property was accordingly set.
+ *
+ * @author <a href="mailto:gielen@it-neering.net">Rene Gielen</a>
+ */
+ public class PropertyHolder {
+ String name, value, expectation;
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public String getExpectation() {
+ return expectation;
+ }
+
+ /**
+ * Construct simple holder with default expectation.
+ *
+ * @param name The property name to use.
+ * @param value The property value to set.
+ * @see #PropertyHolder(String, String, String)
+ */
+ public PropertyHolder(String name, String value) {
+ this(name, value, null);
+ }
+
+ /**
+ * Construct property holder.
+ *
+ * @param name The property name to use.
+ * @param value The property value to set.
+ * @param expectation The expected String to occur in tag output caused by setting given tag property. If
+ * <tt>null</tt>, will be set to <pre>name + "=\"" + value + "\"</pre>.
+ */
+ public PropertyHolder(String name, String value, String expectation) {
+ this.name = name;
+ this.value = value;
+ if (expectation != null) {
+ this.expectation = expectation;
+ } else {
+ this.expectation = name + "=\"" + value + "\"";
+ }
+ }
+
+ /**
+ * Convenience method for easily adding anonymous constructed instance to a given map, with {@link #getName()}
+ * as key.
+ *
+ * @param map The map to place this instance in.
+ */
+ public void addToMap(Map map) {
+ if (map != null) {
+ map.put(this.name, this);
+ }
+ }
+ }
+
+ /**
+ * Simple Helper for setting bean properties. Although BeanUtils from oscore should provide bean property setting
+ * functionality, it does not work (at least with my JDK 1.5.0_05), failing in jdk's PropertyDescriptor constructor.
+ * This implementation works safely in any case, and does not add dependency on commons-beanutils for building.
+ * TODO: Check how we can remove this crap again.
+ *
+ * @author <a href="mailto:gielen@it-neering.net">Rene Gielen</a>
+ */
+ public class BeanHelper {
+ Map propDescriptors;
+ Object bean;
+
+ public BeanHelper(Object bean) {
+ this.bean = bean;
+
+ try {
+ PropertyDescriptor[] pds;
+ pds = Introspector.getBeanInfo(bean.getClass()).getPropertyDescriptors();
+ propDescriptors = new HashMap(pds.length + 1, 1f);
+ for (int i = 0; i < pds.length; i ++) {
+ propDescriptors.put(pds[i].getName(), pds[i]);
+ }
+ } catch (IntrospectionException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void set(String name, Object value) throws IllegalAccessException, InvocationTargetException {
+ PropertyDescriptor pd = (PropertyDescriptor) propDescriptors.get(name);
+
+ if (pd != null) {
+ pd.getWriteMethod().invoke(bean, new Object[]{value});
+ }
+ }
+
+ }
+
+ /**
+ * Initialize a map of {@link PropertyHolder} for generic tag property testing. Will be used when calling {@link
+ * #verifyGenericProperties(org.apache.struts2.views.jsp.ui.AbstractUITag, String, String[])} as properties to
+ * verify.<p/> This implementation defines testdata for all common AbstractUITag properties and may be overridden in
+ * subclasses.
+ *
+ * @return A Map of PropertyHolders values bound to {@link org.apache.struts2.views.jsp.ui.AbstractUITagTest.PropertyHolder#getName()}
+ * as key.
+ */
+ protected Map initializedGenericTagTestProperties() {
+ Map result = new HashMap();
+ new PropertyHolder("name", "someName").addToMap(result);
+ new PropertyHolder("id", "someId").addToMap(result);
+ new PropertyHolder("cssClass", "cssClass1", "class=\"cssClass1\"").addToMap(result);
+ new PropertyHolder("cssStyle", "cssStyle1", "style=\"cssStyle1\"").addToMap(result);
+ new PropertyHolder("title", "someTitle").addToMap(result);
+ new PropertyHolder("disabled", "true", "disabled=\"disabled\"").addToMap(result);
+ //new PropertyHolder("label", "label", "label=\"label\"").addToMap(result);
+ //new PropertyHolder("required", "someTitle").addToMap(result);
+ new PropertyHolder("tabindex", "99").addToMap(result);
+ new PropertyHolder("value", "someValue").addToMap(result);
+ new PropertyHolder("onclick", "onclick1").addToMap(result);
+ new PropertyHolder("ondblclick", "ondblclick1").addToMap(result);
+ new PropertyHolder("onmousedown", "onmousedown1").addToMap(result);
+ new PropertyHolder("onmouseup", "onmouseup1").addToMap(result);
+ new PropertyHolder("onmouseover", "onmouseover1").addToMap(result);
+ new PropertyHolder("onmousemove", "onmousemove1").addToMap(result);
+ new PropertyHolder("onmouseout", "onmouseout1").addToMap(result);
+ new PropertyHolder("onfocus", "onfocus1").addToMap(result);
+ new PropertyHolder("onblur", "onblur1").addToMap(result);
+ new PropertyHolder("onkeypress", "onkeypress1").addToMap(result);
+ new PropertyHolder("onkeydown", "onkeydown1").addToMap(result);
+ new PropertyHolder("onkeyup", "onkeyup1").addToMap(result);
+ new PropertyHolder("onclick", "onclick1").addToMap(result);
+ new PropertyHolder("onselect", "onchange").addToMap(result);
+ return result;
+ }
+
+ /**
+ * Do a generic verification that setting certain properties on a tag causes expected output regarding this
+ * property. In most cases you would not call this directly, instead use {@link
+ * #verifyGenericProperties(org.apache.struts2.views.jsp.ui.AbstractUITag, String, String[])}.
+ *
+ * @param tag The fresh created tag instance to test.
+ * @param theme The theme to use. If <tt>null</tt>, use configured default theme.
+ * @param propertiesToTest Map of {@link PropertyHolder}s, defining properties to test.
+ * @param exclude Names of properties to exclude from particular test.
+ * @throws Exception
+ */
+ public void verifyGenericProperties(AbstractUITag tag, String theme, Map propertiesToTest, String[] exclude) throws Exception {
+ if (tag != null && propertiesToTest != null) {
+ List excludeList;
+ if (exclude != null) {
+ excludeList = Arrays.asList(exclude);
+ } else {
+ excludeList = Collections.EMPTY_LIST;
+ }
+
+ tag.setPageContext(pageContext);
+ if (theme != null) {
+ tag.setTheme(theme);
+ }
+
+ BeanHelper beanHelper = new BeanHelper(tag);
+ Iterator it = propertiesToTest.values().iterator();
+ while (it.hasNext()) {
+ PropertyHolder propertyHolder = (PropertyHolder) it.next();
+ if (! excludeList.contains(propertyHolder.getName())) {
+ beanHelper.set(propertyHolder.getName(), propertyHolder.getValue());
+ }
+ }
+ tag.doStartTag();
+ tag.doEndTag();
+ String writerString = normalize(writer.toString(), true);
+ if (LOG.isInfoEnabled()) {
+ LOG.info("AbstractUITagTest - [verifyGenericProperties]: Tag output is " + writerString);
+ }
+
+ assertTrue("Freemarker error detected in tag output: " + writerString, writerString.indexOf(FREEMARKER_ERROR_EXPECTATION) == -1);
+
+ it = propertiesToTest.values().iterator();
+ while (it.hasNext()) {
+ PropertyHolder propertyHolder = (PropertyHolder) it.next();
+ if (! excludeList.contains(propertyHolder.getName())) {
+ assertTrue("Expected to find: " + propertyHolder.getExpectation() + " in resulting String: " + writerString, writerString.indexOf(propertyHolder.getExpectation()) > -1);
+ }
+ }
+ }
+ }
+
+ /**
+ * Do a generic verification that setting certain properties on a tag causes expected output regarding this
+ * property. Which properties to test with which expectations will be determined by the Map retrieved by {@link #initializedGenericTagTestProperties()}.
+ *
+ * @param tag The fresh created tag instance to test.
+ * @param theme The theme to use. If <tt>null</tt>, use configured default theme.
+ * @param exclude Names of properties to exclude from particular test.
+ * @throws Exception
+ */
+ public void verifyGenericProperties(AbstractUITag tag, String theme, String[] exclude) throws Exception {
+ verifyGenericProperties(tag, theme, initializedGenericTagTestProperties(), exclude);
+ }
+
+ /**
+ * Attempt to verify the contents of this.writer against the contents of the URL specified. verify() performs a
+ * trim on both ends
+ *
+ * @param url the HTML snippet that we want to validate against
+ * @throws Exception if the validation failed
+ */
+ public void verify(URL url) throws Exception {
+ if (url == null) {
+ fail("unable to verify a null URL");
+ } else if (this.writer == null) {
+ fail("AbstractJspWriter.writer not initialized. Unable to verify");
+ }
+
+ StringBuffer buffer = new StringBuffer(128);
+ InputStream in = url.openStream();
+ byte[] buf = new byte[4096];
+ int nbytes;
+
+ while ((nbytes = in.read(buf)) > 0) {
+ buffer.append(new String(buf, 0, nbytes));
+ }
+
+ in.close();
+
+ /**
+ * compare the trimmed values of each buffer and make sure they're equivalent. however, let's make sure to
+ * normalize the strings first to account for line termination differences between platforms.
+ */
+ String writerString = normalize(writer.toString(), true);
+ String bufferString = normalize(buffer.toString(), true);
+
+ assertEquals(bufferString, writerString);
+ }
+
+ /**
+ * Attempt to verify the contents of this.writer against the contents of the URL specified. verify() performs a
+ * trim on both ends
+ *
+ * @param url the HTML snippet that we want to validate against
+ * @throws Exception if the validation failed
+ */
+ public void verify(URL url, String[] excluded) throws Exception {
+ if (url == null) {
+ fail("unable to verify a null URL");
+ } else if (this.writer == null) {
+ fail("AbstractJspWriter.writer not initialized. Unable to verify");
+ }
+
+ StringBuffer buffer = new StringBuffer(128);
+ InputStream in = url.openStream();
+ byte[] buf = new byte[4096];
+ int nbytes;
+
+ while ((nbytes = in.read(buf)) > 0) {
+ buffer.append(new String(buf, 0, nbytes));
+ }
+
+ in.close();
+
+ /**
+ * compare the trimmed values of each buffer and make sure they're equivalent. however, let's make sure to
+ * normalize the strings first to account for line termination differences between platforms.
+ */
+ String writerString = normalize(writer.toString(), true);
+ String bufferString = normalize(buffer.toString(), true);
+
+ assertEquals(bufferString, writerString);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ ServletActionContext.setServletContext(pageContext.getServletContext());
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ ActionContext.setContext(null);
+ }
+
+ /**
+ * normalizes a string so that strings generated on different platforms can be compared. any group of one or more
+ * space, tab, \r, and \n characters are converted to a single space character
+ *
+ * @param obj the object to be normalized. normalize will perform its operation on obj.toString().trim() ;
+ * @param appendSpace
+ * @return the normalized string
+ */
+ public static String normalize(Object obj, boolean appendSpace) {
+ StringTokenizer st = new StringTokenizer(obj.toString().trim(), " \t\r\n");
+ StringBuffer buffer = new StringBuffer(128);
+
+ while (st.hasMoreTokens()) {
+ buffer.append(st.nextToken());
+
+ /*
+ if (appendSpace && st.hasMoreTokens()) {
+ buffer.append("");
+ }
+ */
+ }
+
+ return buffer.toString();
+ }
+}
Added: struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java (added)
+++ struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java Fri Mar 2 21:48:54 2007
@@ -0,0 +1,58 @@
+/*
+ * $Id: AnchorTest.java 508285 2007-02-16 02:42:24Z musachy $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.jsp.ui;
+
+import org.apache.struts2.TestAction;
+
+
+/**
+ */
+public class AnchorTest extends AbstractUITagTest {
+
+
+ public void testSimple() throws Exception {
+ TestAction testAction = (TestAction) action;
+ testAction.setFoo("bar");
+
+ AnchorTag tag = new AnchorTag();
+ tag.setPageContext(pageContext);
+
+ tag.setId("mylink");
+ tag.setTheme("ajax");
+ tag.setHref("a");
+ tag.setErrorText("c");
+ tag.setLoadingText("d");
+ tag.setAfterLoading("e");
+ tag.setBeforeLoading("f");
+ tag.setListenTopics("g");
+ tag.setTargets("h");
+ tag.setHandler("i");
+ tag.setNotifyTopics("j");
+ tag.setIndicator("k");
+ tag.setShowErrorTransportText("true");
+ tag.setShowLoadingText("true");
+ tag.doStartTag();
+ tag.doEndTag();
+
+ verify(AnchorTest.class.getResource("href-1.txt"));
+ }
+
+}
Added: struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/views/jsp/ui/AutocompleterTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/views/jsp/ui/AutocompleterTest.java?view=auto&rev=514083
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/views/jsp/ui/AutocompleterTest.java (added)
+++ struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/views/jsp/ui/AutocompleterTest.java Fri Mar 2 21:48:54 2007
@@ -0,0 +1,81 @@
+/*
+ * $Id: AutocompleterTest.java 510743 2007-02-23 01:06:19Z musachy $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.jsp.ui;
+
+
+/**
+ * @see org.apache.struts2.components.Autocompleter
+ */
+public class AutocompleterTest extends AbstractUITagTest {
+
+ public void testAjax() throws Exception {
+ AutocompleterTag tag = new AutocompleterTag();
+ tag.setPageContext(pageContext);
+ tag.setTheme("ajax");
+ tag.setAutoComplete("true");
+ tag.setDisabled("false");
+ tag.setForceValidOption("false");
+ tag.setHref("a");
+ tag.setDropdownWidth("10");
+ tag.setDropdownHeight("10");
+ tag.setDelay("100");
+ tag.setSearchType("b");
+ tag.setDisabled("c");
+ tag.setName("f");
+ tag.setValue("g");
+ tag.setIndicator("h");
+ tag.setKeyName("i");
+ tag.setLoadOnTextChange("true");
+ tag.setLoadMinimumCount("3");
+ tag.setShowDownArrow("false");
+ tag.setIconPath("i");
+ tag.setTemplateCssPath("j");
+ tag.setDataFieldName("k");
+ tag.doStartTag();
+ tag.doEndTag();
+
+ verify(AutocompleterTest.class.getResource("Autocompleter-1.txt"));
+ }
+
+ public void testSimple() throws Exception {
+ AutocompleterTag tag = new AutocompleterTag();
+ tag.setPageContext(pageContext);
+ tag.setTheme("simple");
+ tag.setAutoComplete("true");
+ tag.setDisabled("false");
+ tag.setForceValidOption("false");
+ tag.setList("{'d','e'}");
+ tag.setHref("a");
+ tag.setDropdownWidth("10");
+ tag.setDropdownHeight("10");
+ tag.setDelay("100");
+ tag.setSearchType("b");
+ tag.setDisabled("c");
+ tag.setName("f");
+ tag.setIconPath("i");
+ tag.setTemplateCssPath("j");
+ tag.doStartTag();
+ tag.doEndTag();
+
+ verify(AutocompleterTest.class.getResource("Autocompleter-2.txt"));
+ }
+
+}