All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.myfaces.custom.dojo.resource.src.widget.Form.js Maven / Gradle / Ivy

/*
	Copyright (c) 2004-2006, The Dojo Foundation
	All Rights Reserved.

	Licensed under the Academic Free License version 2.1 or above OR the
	modified BSD license. For more information on Dojo licensing, see:

		http://dojotoolkit.org/community/licensing.shtml
*/

dojo.provide("dojo.widget.Form");

dojo.require("dojo.widget.*");
dojo.require("dojo.widget.HtmlWidget");

dojo.widget.defineWidget("dojo.widget.Form", dojo.widget.HtmlWidget,
	{
		/*
		summary: 
			Widget for easily moving data to/from form
		
			description:
				gets and sets data to and from js-object. With
				this it's easy to create forms to application.
				Just create empty form, then set it's values
				with this and after user pushes submit,
				getValues and send them as json-notation to
				server.

				Note: not all Form widgets are supported ATM
					
			usage: 
				
Name:
myObj={name: "John Doe"}; dojo.widget.byId('myForm').setValues(myObj); myObj=dojo.widget.byId('myForm').getValues(); */ isContainer: true, templateString: "
", formElements: [], // ignoreNullValue: // if true, then only fields that has data is set to form // if false, fields that does not have corresponding object, is set to empty ignoreNullValues: false, postCreate: function(args,frag){ for (var key in args) { if (key == "dojotype") continue; var attr= document.createAttribute(key); attr.nodeValue=args[key]; this.containerNode.setAttributeNode(attr); } }, _createRepeaters: function (/*object*/obj, /*widget*/widget) { for(var i=0; i 1) { if(typeof(myObj[nameA[0]]) == "undefined") { myObj[nameA[0]]=[ ]; } // if nameIndex=parseInt(nameA[1]); if(typeof(myObj[nameA[0]][nameIndex]) == "undefined") { myObj[nameA[0]][nameIndex]={}; } } else if(typeof(myObj[nameA[0]]) == "undefined") { myObj[nameA[0]]={} } // if if (nameA.length == 1) { myObj=myObj[nameA[0]]; } else { myObj=myObj[nameA[0]][nameIndex]; } // if } // for if ((elm.type != "select-multiple" && elm.type != "checkbox" && elm.type != "radio") || (elm.type=="radio" && elm.checked)) { if(name == name.split("[")[0]) { myObj[name]=elm.value; } else { // can not set value when there is no name } } else if (elm.type == "checkbox" && elm.checked) { if(typeof(myObj[name]) == 'undefined') { myObj[name]=[ ]; } myObj[name].push(elm.value); } else if (elm.type == "select-multiple") { if(typeof(myObj[name]) == 'undefined') { myObj[name]=[ ]; } for (var jdx=0,len3=elm.options.length; jdx




© 2015 - 2024 Weber Informatics LLC | Privacy Policy