/mojarra-2.1.7/jsf-ri/resources/mojarra.js
# · JavaScript · 191 lines · 56 code · 14 blank · 121 comment · 11 complexity · 5dd5ab940f0c5049ba09d80384eb42a2 MD5 · raw file
- /*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common Development
- * and Distribution License("CDDL") (collectively, the "License"). You
- * may not use this file except in compliance with the License. You can obtain
- * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
- * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
- * language governing permissions and limitations under the License.
- *
- * When distributing the software, include this License Header Notice in each
- * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
- * Sun designates this particular file as subject to the "Classpath" exception
- * as provided by Sun in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the License
- * Header, with the fields enclosed by brackets [] replaced by your own
- * identifying information: "Portions Copyrighted [year]
- * [name of copyright owner]"
- *
- * Contributor(s):
- *
- * If you wish your version of this file to be governed by only the CDDL or
- * only the GPL Version 2, indicate your decision by adding "[Contributor]
- * elects to include this software in this distribution under the [CDDL or GPL
- * Version 2] license." If you don't indicate a single choice of license, a
- * recipient has the option to distribute your version of this file under
- * either the CDDL, the GPL Version 2 or to extend the choice of license to
- * its licensees as provided above. However, if you add GPL Version 2 code
- * and therefore, elected the GPL Version 2 license, then the option applies
- * only if the new code is made subject to such option by the copyright
- * holder.
- *
- *
- * This file incorporates work covered by the following copyright and
- * permission notice:
- *
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed 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.
- */
-
- /**
- @project JSF Ajax Library
- @version 2.0
- @description This is the standard implementation of the JSF Ajax Library.
- */
-
- /**
- * Register with OpenAjax
- */
- if (typeof OpenAjax !== "undefined" &&
- typeof OpenAjax.hub.registerLibrary !== "undefined") {
- OpenAjax.hub.registerLibrary("mojarra", "www.sun.com", "1.0", null);
- }
-
- /**
- * @name mojarra
- * @namespace
- */
-
- /*
- * Create our top level namespaces - mojarra
- */
- var mojarra = mojarra || {};
-
-
- /**
- * This function deletes any hidden parameters added
- * to the form by checking for a variable called 'adp'
- * defined on the form. If present, this variable will
- * contain all the params added by 'apf'.
- *
- * @param f - the target form
- */
- mojarra.dpf = function dpf(f) {
- var adp = f.adp;
- if (adp !== null) {
- for (var i = 0; i < adp.length; i++) {
- f.removeChild(adp[i]);
- }
- }
- };
-
- /*
- * This function adds any parameters specified by the
- * parameter 'pvp' to the form represented by param 'f'.
- * Any parameters added will be stored in a variable
- * called 'adp' and stored on the form.
- *
- * @param f - the target form
- * @param pvp - associative array of parameter
- * key/value pairs to be added to the form as hidden input
- * fields.
- */
- mojarra.apf = function apf(f, pvp) {
- var adp = new Array();
- f.adp = adp;
- var i = 0;
- for (var k in pvp) {
- if (pvp.hasOwnProperty(k)) {
- var p = document.createElement("input");
- p.type = "hidden";
- p.name = k;
- p.value = pvp[k];
- f.appendChild(p);
- adp[i++] = p;
- }
- }
- };
-
- /*
- * This is called by command link and command button. It provides
- * the form it is nested in, the parameters that need to be
- * added and finally, the target of the action. This function
- * will delete any parameters added <em>after</em> the form
- * has been submitted to handle DOM caching issues.
- *
- * @param f - the target form
- * @param pvp - associative array of parameter
- * key/value pairs to be added to the form as hidden input
- * fields.
- * @param t - the target of the form submission
- */
- mojarra.jsfcljs = function jsfcljs(f, pvp, t) {
- mojarra.apf(f, pvp);
- var ft = f.target;
- if (t) {
- f.target = t;
- }
- f.submit();
- f.target = ft;
- mojarra.dpf(f);
- };
-
- /*
- * This is called by functions that need access to their calling
- * context, in the form of <code>this</code> and <code>event</code>
- * objects.
- *
- * @param f the function to execute
- * @param t this of the calling function
- * @param e event of the calling function
- * @return object that f returns
- */
- mojarra.jsfcbk = function jsfcbk(f, t, e) {
- return f.call(t,e);
- };
-
- /*
- * This is called by the AjaxBehaviorRenderer script to
- * trigger a jsf.ajax.request() call.
- *
- * @param s the source element or id
- * @param e event of the calling function
- * @param n name of the behavior event that has fired
- * @param ex execute list
- * @param re render list
- * @param op options object
- */
- mojarra.ab = function ab(s, e, n, ex, re, op) {
- if (!op) {
- op = {};
- }
-
- if (n) {
- op["javax.faces.behavior.event"] = n;
- }
-
- if (ex) {
- op["execute"] = ex;
- }
-
- if (re) {
- op["render"] = re;
- }
-
- jsf.ajax.request(s, e, op);
- };