You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ar...@apache.org on 2008/10/29 22:29:27 UTC
svn commit: r709015 [1/3] - in /myfaces/trinidad/branches/1.2.9.1-branch: ./
trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/
trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/
trinidad-impl/src/main/j...
Author: arobinson74
Date: Wed Oct 29 14:29:27 2008
New Revision: 709015
URL: http://svn.apache.org/viewvc?rev=709015&view=rev
Log:
TRINIDAD-1280
Added try catch around the form submit with a display of a translatable message for failure to sumbit the form with an inputFile. The code isn't 100% foolproof as I do not see a way to make sure that it was indeed the inputFile that caused the error, but it should work for the large portion of the use cases
Modified:
myfaces/trinidad/branches/1.2.9.1-branch/ (props changed)
myfaces/trinidad/branches/1.2.9.1-branch/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/MessageBundle.xrts
myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CoreFormData.java
myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/InputFileRenderer.java
myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlUtils.java
myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/jsLibs/LocaleInfoScriptlet.java
myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js
myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts (contents, props changed)
Propchange: myfaces/trinidad/branches/1.2.9.1-branch/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Oct 29 14:29:27 2008
@@ -1 +1 @@
-/myfaces/trinidad/trunk_1.2.x:702988,707133
+/myfaces/trinidad/trunk_1.2.x:702988,707133,709009
Modified: myfaces/trinidad/branches/1.2.9.1-branch/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/MessageBundle.xrts
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.9.1-branch/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/MessageBundle.xrts?rev=709015&r1=709014&r2=709015&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.9.1-branch/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/MessageBundle.xrts (original)
+++ myfaces/trinidad/branches/1.2.9.1-branch/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/MessageBundle.xrts Wed Oct 29 14:29:27 2008
@@ -451,4 +451,8 @@
<resource key="org.apache.myfaces.trinidad.event.FileDownloadActionListener.DOWNLOAD_ERROR">An error occurred downloading the file.</resource>
<resource key="org.apache.myfaces.trinidad.event.FileDownloadActionListener.DOWNLOAD_ERROR_detail">The file was not downloaded or was not downloaded correctly.</resource>
+ <!-- message for error while uploading a file -->
+ <resource key="org.apache.myfaces.trinidad.component.core.input.CoreInputFile.INPUT_FILE_ERROR">An error occurred uploading the file.</resource>
+ <resource key="org.apache.myfaces.trinidad.component.core.input.CoreInputFile.INPUT_FILE_ERROR_detail">A file upload error has occurred, please verify your upload data and file name.</resource>
+
</resources>
Modified: myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CoreFormData.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CoreFormData.java?rev=709015&r1=709014&r2=709015&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CoreFormData.java (original)
+++ myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CoreFormData.java Wed Oct 29 14:29:27 2008
@@ -6,9 +6,9 @@
* 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
@@ -19,6 +19,7 @@
package org.apache.myfaces.trinidadinternal.renderkit.core.xhtml;
import java.io.IOException;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -44,6 +45,7 @@
import org.apache.myfaces.trinidad.validator.ClientValidator;
import org.apache.myfaces.trinidadinternal.share.data.ServletRequestParameters;
+
/**
* Implementation of FormData from the CoreRenderKit (or,
* more specifically, from the Trinidad FormRenderer)
@@ -415,12 +417,12 @@
component = new org.apache.myfaces.trinidad.component.UIXInput();
component.setId(clientId);
- }
-
+ }
+
// write out the lib(s) and script
- String libURI = submitConverter.getClientLibrarySource(context);
+ String libURI = submitConverter.getClientLibrarySource(context);
String clientScript = submitConverter.getClientScript(context, component);
- Collection<String> libRefs = submitConverter.getClientImportNames();
+ Collection<String> libRefs = submitConverter.getClientImportNames();
_addClientScripts(context, rc, libURI, clientScript, libRefs, "TrConverter()");
String converter = submitConverter.getClientConversion(context,
@@ -434,7 +436,7 @@
}
}
-
+
private void _addClientScripts(
FacesContext context,
RenderingContext rc,
@@ -446,16 +448,9 @@
{
if (libURI != null)
{
- // check if it's already been written
- Map<Object, Object> props = rc.getProperties();
- if( props.get(libURI) == null)
- {
- // put the lib name in the property map so it won't be written out again
- props.put(libURI, Boolean.TRUE);
- XhtmlUtils.writeLibImport(context, rc, libURI);
- }
+ XhtmlUtils.writeLibImport(context, rc, libURI);
}
-
+
if(libRefs != null)
{
_writeDependencies(context, rc, libRefs);
@@ -464,14 +459,14 @@
{
_writeDependencies(context, rc, defaultLibRef);
}
-
+
if ( clientScript != null)
{
List<String> clientDependencies = getClientDependencies(true);
clientDependencies.add(clientScript);
}
}
-
+
/**
@@ -488,13 +483,13 @@
String clientId
) throws IOException
{
-
+
// write out the lib(s) and script
- String libURI = submitValidator.getClientLibrarySource(context);
+ String libURI = submitValidator.getClientLibrarySource(context);
String clientScript = submitValidator.getClientScript(context, component);
- Collection<String> libRefs = submitValidator.getClientImportNames();
+ Collection<String> libRefs = submitValidator.getClientImportNames();
_addClientScripts(context, rc, libURI, clientScript, libRefs, "TrValidator()");
-
+
String validator = submitValidator.getClientValidation(context,
component);
@@ -692,7 +687,7 @@
libReference);
}
}
-
+
/**
* Opportunity for the ClientConverter or Validator to write any of its dependencies
* to the output. For HTML, this will typically be imports of
@@ -712,10 +707,10 @@
Object[] libRefArray = libRefs.toArray();
for (int i = 0; i < libRefArray.length; i++)
{
- XhtmlUtils.addLib(context, rc, libRefArray[i]);
- }
+ XhtmlUtils.addLib(context, rc, libRefArray[i]);
+ }
}
- }
+ }
private int _inputTextCount = 0;
private boolean _hasImmediateComponent = false;
Modified: myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/InputFileRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/InputFileRenderer.java?rev=709015&r1=709014&r2=709015&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/InputFileRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/InputFileRenderer.java Wed Oct 29 14:29:27 2008
@@ -6,9 +6,9 @@
* 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
@@ -25,8 +25,9 @@
import org.apache.myfaces.trinidad.bean.FacesBean;
import org.apache.myfaces.trinidad.component.core.input.CoreInputFile;
-
import org.apache.myfaces.trinidad.context.RenderingContext;
+import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.jsLibs.LocaleInfoScriptlet;
+
public class InputFileRenderer extends InputLabelAndMessageRenderer
{
@@ -40,43 +41,49 @@
{
super(type);
}
-
+
@Override
protected void findTypeConstants(FacesBean.Type type)
{
super.findTypeConstants(type);
_simpleInputFile = new SimpleInputFileRenderer(type);
}
-
+
@Override
protected final void encodeAll(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
// =-=AEW inputFile is currently disabled for PDAs. But this should
// run off of an agent property.
- if (!isPDA(arc))
+ if (!isPDA(rc))
{
- super.encodeAll(context, arc, component, bean);
+ // ensure that the translation is sent down to the client as posting
+ // an IFRAME with an invalid file can cause errors that need to be shown
+ // to the user with JavaScript
+ XhtmlUtils.addLib(context, rc, LocaleInfoScriptlet.LOCALE_INFO_KEY);
+
+ super.encodeAll(context, rc, component, bean);
}
}
@Override
- protected String getRootStyleClass(FacesBean bean)
+ protected String getRootStyleClass(FacesBean bean)
{
return "af|inputFile";
}
-
+
@Override
protected FormInputRenderer getFormInputRenderer()
{
return _simpleInputFile;
}
-
+
/**
- *
+ *
* @param bean
* @return false, since inputFile does not support the readOnly attribute
*/
Modified: myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlUtils.java?rev=709015&r1=709014&r2=709015&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlUtils.java (original)
+++ myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlUtils.java Wed Oct 29 14:29:27 2008
@@ -6,9 +6,9 @@
* 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
@@ -30,21 +30,16 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.apache.myfaces.trinidad.logging.TrinidadLogger;
-
-import org.apache.myfaces.trinidad.component.UIXIterator;
import org.apache.myfaces.trinidad.component.UIXComponentRef;
+import org.apache.myfaces.trinidad.component.UIXIterator;
import org.apache.myfaces.trinidad.component.UIXSubform;
import org.apache.myfaces.trinidad.component.UIXSwitcher;
-
import org.apache.myfaces.trinidad.context.Agent;
-
-import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
import org.apache.myfaces.trinidad.context.RenderingContext;
-
+import org.apache.myfaces.trinidad.logging.TrinidadLogger;
+import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.jsLibs.Scriptlet;
import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.jsLibs.XhtmlScriptletFactory;
-
import org.apache.myfaces.trinidadinternal.share.util.FastMessageFormat;
@@ -144,19 +139,27 @@
/**
* Write out a script element importing a library.
+ * The given URL will only be written once to the page.
*/
public static void writeLibImport(
- FacesContext context,
- RenderingContext arc,
- Object libURL) throws IOException
- {
+ FacesContext context,
+ RenderingContext rc,
+ Object libURL) throws IOException
+ {
+ // check if it's already been written
+ Map<Object, Object> props = rc.getProperties();
+ if (props.containsKey(libURL)) { return; }
+
+ // put the lib name in the property map so it won't be written out again
+ props.put(libURL, Boolean.TRUE);
+
ResponseWriter writer = context.getResponseWriter();
writer.startElement("script", null);
- XhtmlRenderer.renderScriptDeferAttribute(context, arc);
+ XhtmlRenderer.renderScriptDeferAttribute(context, rc);
// Bug #3426092:
// render the type="text/javascript" attribute in accessibility mode
- XhtmlRenderer.renderScriptTypeAttribute(context, arc);
+ XhtmlRenderer.renderScriptTypeAttribute(context, rc);
// For portlets, we want to make sure that we only import
// each script once. Employ document.write() to achieve this
@@ -164,11 +167,11 @@
// problems when resizing windows - but we're done with Netscape 4)
libURL = context.getExternalContext().encodeResourceURL(libURL.toString());
- if (XhtmlConstants.FACET_PORTLET.equals(arc.getOutputMode()))
+ if (XhtmlConstants.FACET_PORTLET.equals(rc.getOutputMode()))
{
- if (arc.getProperties().get(_PORTLET_LIB_TABLE_KEY) == null)
+ if (rc.getProperties().get(_PORTLET_LIB_TABLE_KEY) == null)
{
- arc.getProperties().put(_PORTLET_LIB_TABLE_KEY, Boolean.TRUE);
+ rc.getProperties().put(_PORTLET_LIB_TABLE_KEY, Boolean.TRUE);
writer.writeText("var _uixJSL;" +
"if(!_uixJSL)_uixJSL={};" +
"function _addJSL(u)" +
Modified: myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/jsLibs/LocaleInfoScriptlet.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/jsLibs/LocaleInfoScriptlet.java?rev=709015&r1=709014&r2=709015&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/jsLibs/LocaleInfoScriptlet.java (original)
+++ myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/jsLibs/LocaleInfoScriptlet.java Wed Oct 29 14:29:27 2008
@@ -6,9 +6,9 @@
* 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
@@ -38,7 +38,7 @@
* @version $Name: $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/renderkit/core/xhtml/jsLibs/LocaleInfoScriptlet.java#0 $) $Date: 10-nov-2005.19:02:47 $
*/
-class LocaleInfoScriptlet extends LibraryScriptlet
+public class LocaleInfoScriptlet extends LibraryScriptlet
{
static public final String LOCALE_INFO_KEY = "LocaleInfo";
@@ -56,7 +56,7 @@
/**
* @todo Revisit separate translation and internationalization
* locales.
- */
+ */
@Override
protected void outputScriptletImpl(
FacesContext context,
@@ -134,9 +134,9 @@
buffer.append(locStr);
return buffer.toString();
}
-
- /* return extra parameter "?loc=en", so that we can know what locale
+
+ /* return extra parameter "?loc=en", so that we can know what locale
* the translations in LocaleElements should be in. */
protected String getExtraParameters(
FacesContext context,
@@ -147,11 +147,14 @@
String extraParams = "?loc=" + locStr;
return extraParams;
- }
+ }
- protected Locale getFormattingLocale(RenderingContext arc) {
- return arc.getLocaleContext().getFormattingLocale();
- }
+ protected Locale getFormattingLocale(
+ RenderingContext rc
+ )
+ {
+ return rc.getLocaleContext().getFormattingLocale();
+ }
/**
* Returns the locale variant type to use when formatting dates. The locale
@@ -175,7 +178,7 @@
return null;
}
-
+
/**
* Returns the Locale to use for loading a JavaScript resource,
* given an input Locale
@@ -184,9 +187,9 @@
Locale inLocale
)
{
- HashMap<Locale, Locale> supportedMap =
+ HashMap<Locale, Locale> supportedMap =
LocaleList.getSupportedLocales();
-
+
Locale outLocale = inLocale;
if(supportedMap.containsKey(outLocale))
{
@@ -196,19 +199,19 @@
{
String variant = outLocale.getVariant();
String language = outLocale.getLanguage();
-
+
boolean isSupportedLocale = false;
-
+
if (variant.length() != 0)
- {
+ {
outLocale = new Locale(language, outLocale.getCountry());
isSupportedLocale = supportedMap.containsKey(outLocale);
}
-
+
if (!isSupportedLocale)
- {
+ {
outLocale = new Locale(language, "");
-
+
if (!supportedMap.containsKey(outLocale))
{
// use default Locale
@@ -217,9 +220,9 @@
}
return outLocale;
- }
+ }
}
-
+
static private final String _RESOURCE_BASE = "resources/LocaleElements_";
static private final Scriptlet _sInstance = new LocaleInfoScriptlet();
Modified: myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js?rev=709015&r1=709014&r2=709015&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js (original)
+++ myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js Wed Oct 29 14:29:27 2008
@@ -6,9 +6,9 @@
* 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
@@ -309,7 +309,7 @@
// blackberry because navigator.userAgent on BlackBery Browser 4.0
// starts with Mozilla/4.0 (even though the User-Agent sent to the
// server starts with BlackBerry<model>/<version>)
-
+
// BlackBerry Browser 4.0+ supports navigator.appVersion,
// and earlier versions don't support script, so we can
// leave the version as defined above
@@ -666,7 +666,7 @@
{
// dummy read to test security error
parentWindow.name;
-
+
return parentWindow;
}
catch (e)
@@ -845,7 +845,7 @@
{
//PH:set the right event object;
event = _getEventObj();
-
+
// Make sure we don't run through this function twice
// when we close a dialog. The
// _unloadADFDialog function blocks a second run
@@ -1060,7 +1060,7 @@
// within a frame. So, we check for the _abandoned property
// on the "top" window.
var topWindow = _getTop(self);
-
+
return topWindow._abandoned;
}
@@ -1186,12 +1186,12 @@
function _getFormName(form)
{
var name = form.name;
-
+
if ((typeof name) != 'string')
{
if (_agent.isIE)
{
- name = form.attributes['name'].nodeValue;
+ name = form.attributes['name'].nodeValue;
}
else
{
@@ -1288,7 +1288,7 @@
validators = _getValidators(form);
var failureMap = _multiValidate(form, source, validators);
-
+
var firstFailure = true;
var failureString = errorTitle + '\n';
@@ -1303,7 +1303,7 @@
var currInput = _getFormElement(form, currId);
if (!currInput)
continue;
-
+
// Get the label text for this input
var label = validators[currId].label;
@@ -1319,12 +1319,12 @@
// Get the current message
var facesMessage = messages[j];
-
- var errorString = _getGlobalErrorString(currInput,
- globalMessage,
+
+ var errorString = _getGlobalErrorString(currInput,
+ globalMessage,
facesMessage.getDetail(),
- label);
-
+ label);
+
failureString += errorString + '\n';
}
}
@@ -1339,7 +1339,7 @@
_recordValidation(true, 0);
alert(failureString);
_recordValidation(true, 0);
-
+
return false;
}
@@ -1354,7 +1354,7 @@
validators = _getValidators(form);
var failureMap = _multiValidate(form, source, validators);
-
+
var noFailures = true;
for (var currId in validators)
@@ -1366,14 +1366,14 @@
// If component hasn't got a message element, then skip
var msgElem = _getElementById(document, currId+ "::msg");
-
+
// Clear any existing inline message
if (msgElem)
msgElem.innerHTML = "";
-
- // Clear any existing messages from the MessageBox
+
+ // Clear any existing messages from the MessageBox
TrMessageBox.removeMessages(currId);
-
+
// Get the messages array for currId, skip if none
var messages = failureMap[currId];
if (!messages || messages.length==0)
@@ -1385,12 +1385,12 @@
iconElem.style.display = "none";
continue;
}
-
+
// Get the input element
var currInput = _getFormElement(form, currId);
if (!currInput)
continue;
-
+
// Get the label text for this input
var label = validators[currId].label;
@@ -1416,11 +1416,11 @@
// summary or detail, then pop an alert to warn the page developer
if (!msgElem && !TrMessageBox.isPresent())
alert("Field Error [" + currId + "] - " + facesMessage.getDetail());
-
+
// Add the message to the MessageBox
TrMessageBox.addMessage(currId, label, facesMessage);
}
-
+
// If we got this far, we know there's something to display so
// make the inline message and icon visible.
if (msgElem)
@@ -1437,12 +1437,12 @@
* the appropriate message will be displayed in the message component for this
* input field.
* <p>
- * The simplest usage of this method is from the onblur attribute of the
+ * The simplest usage of this method is from the onblur attribute of the
* input component. e.g. onblur="_validateInput(event);"
* <p>
* @param event(Event) The event object provided by the event handler.
* @param falseOnFail(boolean) Force method to return false if validation failed.
- * @return boolean, false if validation failed and falseOnFail set to true, otherwise true.
+ * @return boolean, false if validation failed and falseOnFail set to true, otherwise true.
*/
// TODO: make this a public function only after hanging it on
// a namespaced object, *and* making it not specific to inline
@@ -1451,10 +1451,10 @@
{
if (!event)
return true;
-
+
// Get the element associated with the event
var inputElem = event.target || event.srcElement;
-
+
if (!inputElem || !inputElem.id)
return true;
@@ -1465,7 +1465,7 @@
var validators = _getValidators(form);
if (!validators)
return true;
-
+
var id = inputElem.id;
var descriptor = validators[id];
@@ -1487,8 +1487,8 @@
// Call inline validation using only the appropriate validators
var retval = _validateInline(form, null, validatorsToRun, 1, null);
-
- // Only return the actual outcome if asked to do so
+
+ // Only return the actual outcome if asked to do so
if (falseOnFail)
return retval;
}
@@ -1832,7 +1832,31 @@
if(_agent.isIE && window.external)
window.external.AutoCompleteSaveForm(form);
- form.submit();
+ try
+ {
+ form.submit();
+ }
+ catch (e)
+ {
+ if (TrPage.getInstance().getRequestQueue()._isMultipartForm(form))
+ {
+ // IE will fail on an input file submission of a file that does not exist
+ var facesMessage = _createFacesMessage(
+ 'org.apache.myfaces.trinidad.component.core.input.CoreInputFile.INPUT_FILE_ERROR');
+ // if there's nowhere to display the message in either
+ // summary or detail, then pop an alert to warn the page developer
+ if (!TrMessageBox.isPresent())
+ alert(facesMessage.getDetail());
+ else
+ // Add the message to the MessageBox
+ TrMessageBox.addMessage(null, null, facesMessage);
+ }
+ else
+ {
+ throw e;
+ }
+ }
+
if (_blockOnEverySubmit)
_pprStartBlocking(window);
@@ -2016,7 +2040,7 @@
}
else if (element.type.indexOf("select") != -1)
{
- //PH:selectdata must be initialized to "". Otherwise, results for
+ //PH:selectdata must be initialized to "". Otherwise, results for
//selectdata+="stringtoconcatenate" is "undefinedstringtoconcatenate"
var selectdata ="" ;
for (var j = 0; j < element.options.length; j++)
@@ -2242,7 +2266,7 @@
if (currInput.focus)
currInput.focus();
- //PH:element["value"] is not supported for PIE,IEM and BB. Therefore
+ //PH:element["value"] is not supported for PIE,IEM and BB. Therefore
//use element.value which is supported by all
if ((currInput.type == "text")
&& (currInput.value != (void 0))
@@ -2265,12 +2289,12 @@
if (!validatorMap)
validatorMap = new Object();
- // Now, iterate through the array we've been given
+ // Now, iterate through the array we've been given
for (var i = 0; i < validators.length; i += 5)
{
var id = validators[i];
var descriptor = new Object();
-
+
// If the field is required, replace the format index with the
// actual message
if (validators[i + 1])
@@ -2283,7 +2307,7 @@
// If the converter exists, change it from an index to a converter
var converterIndex = validators[i + 3];
if (converterIndex != null)
- {
+ {
descriptor.converter = validations[converterIndex];
}
@@ -2313,7 +2337,7 @@
{
var inputElem = _getElementById(document, id);
if (inputElem)
- {
+ {
_addEvent(inputElem, "change", _validateInput);
}
}
@@ -2378,7 +2402,7 @@
{
continue;
}
-
+
var isIgnored = false;
// If this field is one that's specifically being ignored,
// then don't validate here.
@@ -2411,7 +2435,7 @@
//Initialize the failure array for this input
var inputFailures = new Array();
-
+
var descriptor = validators[id];
var label = descriptor.label;
@@ -2436,9 +2460,9 @@
// get the formatted error string for the current input and
var requiredErrorString = _getErrorString(currInput, label,
descriptor.requiredFormat);
-
+
// Populate the failureMap with the current error
- inputFailures[inputFailures.length] =
+ inputFailures[inputFailures.length] =
new TrFacesMessage(requiredErrorString, requiredErrorString);
}
else
@@ -2463,13 +2487,13 @@
}
catch (e)
{
- converterError = true;
+ converterError = true;
// Populate the failureMap with the current error
inputFailures[inputFailures.length] = e.getFacesMessage();
}
}
}
-
+
if ( converterError == false)
{
var validatorArray = descriptor.validators;
@@ -2488,13 +2512,13 @@
if (validatorConstructor && value !== undefined)
{
var validator = eval(validatorConstructor);
-
- try
+
+ try
{
validator.validate(value, label, converter);
}
catch (e)
- {
+ {
// Populate the failureMap with the current error
inputFailures[inputFailures.length] = e.getFacesMessage();
}
@@ -2504,7 +2528,7 @@
}
}
}
-
+
// if there were failures, then add the current input to the failuresMap
if (inputFailures.length > 0)
{
@@ -2514,7 +2538,7 @@
}
}
}
-
+
return failureMap;
}
@@ -2530,10 +2554,10 @@
key,
label,
value,
- param2,
+ param2,
param3
)
-{
+{
var summary = TrMessageFactory.getSummaryString(key);
var detail = TrMessageFactory.getDetailString(key);
// format the detail error string
@@ -2541,8 +2565,8 @@
{
detail = TrFastMessageFormatUtils.format(detail, label, value, param2, param3);
}
- return new TrFacesMessage(summary,
- detail,
+ return new TrFacesMessage(summary,
+ detail,
TrFacesMessage.SEVERITY_ERROR);
}
@@ -2559,18 +2583,18 @@
detail,
label,
value,
- param2,
+ param2,
param3
)
-{
+{
// format the detail error string
if (detail != null)
{
detail = TrFastMessageFormatUtils.format(detail, label, value, param2, param3);
}
-
- return new TrFacesMessage(summary,
+
+ return new TrFacesMessage(summary,
detail,
TrFacesMessage.SEVERITY_ERROR);
}
@@ -2583,7 +2607,7 @@
label
)
{
- var form = _getForm(input);
+ var form = _getForm(input);
if (errorFormat && label != null)
{
return _formatErrorString(errorFormat,
@@ -2592,9 +2616,9 @@
"1":errorString
});
}
-
- return errorString;
-}
+
+ return errorString;
+}
/**
@@ -2603,15 +2627,15 @@
*/
function _isShowing(
input)
- {
- //PH: removed !input.focus because firstly, focus() function is supported by
- //all browsers (PIE,IEM,BB,FF,IE) and secondly, _isShowing should be treated
- //as a function to test visibility only. If there is a case where one really
- //wants to test whether focus function exists or not, do it in an if
+ {
+ //PH: removed !input.focus because firstly, focus() function is supported by
+ //all browsers (PIE,IEM,BB,FF,IE) and secondly, _isShowing should be treated
+ //as a function to test visibility only. If there is a case where one really
+ //wants to test whether focus function exists or not, do it in an if
//statement and call _isShowing within it.
if (input.type == 'hidden')
return false;
-
+
// determine visibility from style information
if (_agent.isIEGroup)
{
@@ -2647,12 +2671,12 @@
var computedStyle = input.ownerDocument.defaultView.getComputedStyle(input,
null);
-
+
// either of these styles will prevent focus from succeeding
return ((computedStyle["visibility"] != "hidden") &&
(computedStyle["display"] != "none"));
}
-
+
return true;
}
@@ -2669,7 +2693,7 @@
{
return input.name;
}
-
+
// for non-Netscape return the ID directly
var id = input.id;
@@ -2721,7 +2745,7 @@
return form;
}
-
+
/**
* Returns the element of name elementName for the given form
*/
@@ -2745,7 +2769,7 @@
}
return formElement;
}
-
+
/**
* Returns the name of an input element on either IE or Netscape, dealing
@@ -2785,7 +2809,7 @@
{
if (type == (void 0))
return false;
-
+
if (obj == (void 0))
return false;
@@ -2880,7 +2904,7 @@
{
var currValue = tokens[currToken];
- // if the token has no value
+ // if the token has no value
if (!currValue)
{
currValue = "";
@@ -2913,24 +2937,24 @@
for (i=0; i<currValue.length; i++)
{
b1 = b1 + 'placeHolderString';
- }
-
+ }
+
while (indexOf >= 0)
{
currString=(currString.substring(0,indexOf)
+ b1
+ currString.substring(indexOf+currRegExp.length));
- indexOf = currString.indexOf(currRegExp);
- }
-
+ indexOf = currString.indexOf(currRegExp);
+ }
+
indexOf = currString.indexOf(b1);
-
+
while (indexOf >= 0)
- {
+ {
currString =(currString.substring(0,indexOf)
+ currValue
- + currString.substring(indexOf+b1.length));
- indexOf = currString.indexOf(b1);
+ + currString.substring(indexOf+b1.length));
+ indexOf = currString.indexOf(b1);
}
}
else
@@ -2954,7 +2978,7 @@
// And now take any doubled-up single quotes down to one,
// to handle escaping
var twoSingleQuotes = /''/g;
-
+
return currString.replace(twoSingleQuotes, "'");
}
@@ -2975,7 +2999,7 @@
if ( shortCircuit && (result1 == false))
return false;
var result2 = _callChained(evh2, target, event);
-
+
// since undefined results should be evaluated as true,
// return false only if either result1 or result2 return false
return !((result1 == false) || (result2 == false));
@@ -2989,7 +3013,7 @@
{
if (handler && (handler.length > 0))
- {
+ {
// handle ie case, where we have no event parameter
if( (typeof(event) == 'undefined') || (event == (void 0) ) )
@@ -3097,25 +3121,25 @@
//
//PH:exclude BlackBerry
if (((_agent.kind != "ie") || (_agent.version >= 5)) && (!_agent.isBlackBerry))
- {
- var element = doc.getElementById(id);
-
+ {
+ var element = doc.getElementById(id);
+
// IE's implementation of getElementById() is buggy. If
// the page contains an anchor which has the same name
// as the requested id, IE will return the anchor, even
// if the anchor's id attribute is not set. So, make
// sure that we actually get back an element with the
- // correct id.
+ // correct id.
if ((element == null) || (element.id == id))
return element;
- // If we get here, that means that IE has probably returned
+ // If we get here, that means that IE has probably returned
// an anchor instead of the desired element. Let's scan
// the entire DOM tree to find the element we want.
return _findElementById(doc, id);
}
-
- return doc.getElementById(id);
- }
+
+ return doc.getElementById(id);
+ }
else if (typeof(doc.all) == 'undefined')
{
// Browser does not support getElementById nor DOM documnet.all object.
@@ -3130,12 +3154,12 @@
{
var f = doc.forms[i];
if(f[id])
- return f[id];
+ return f[id];
}
-
- //element is not within the form but form(s) is(are) present.
- return window[id];
- }
+
+ //element is not within the form but form(s) is(are) present.
+ return window[id];
+ }
else
{
// Browser does not support getElementById but supports DOM documnet.all
@@ -3372,7 +3396,7 @@
// blocking starts. Use a timeout to allow the update.
win._pprTimeoutFunc = win.setTimeout("_doPprStartBlocking(window);",
1);
- return;
+ return;
}
else
{
@@ -3412,7 +3436,7 @@
8000);
}
else if (_agent.isIEGroup)
- {
+ {
// save off the element we'll return focus to
_pprEventElement = window.document.activeElement;
}
@@ -4117,7 +4141,7 @@
// If we're inside a frameset, and the top frame wants
// reloads blocked, install a _noReload handler.
var topWindow = _getTop(self);
-
+
if ((self != topWindow) && topWindow["_blockReload"])
{
document.onkeydown = _noReload;
@@ -4131,7 +4155,7 @@
//PH: Set Focus on element for all browsers.
if(myElement)
_setFocus(myElement);
- }
+ }
// Initialize ourselves if we're in a PopupDialog
TrPopupDialog._initDialogPage();
@@ -4498,9 +4522,9 @@
}
/** This function is called from _spinboxRepeat.
- * This function increments or decrements the value that is in the
- * input field by the stepSize. If the max/min is reached, check circular.
- * If circular is true, then circle the number around.
+ * This function increments or decrements the value that is in the
+ * input field by the stepSize. If the max/min is reached, check circular.
+ * If circular is true, then circle the number around.
* we default circular for now, because we do not support it yet.
* Else, stop at the max or min.
*/
@@ -4515,7 +4539,7 @@
{
alert("value, stepSize, min, and max must all be numbers. value: "+
value+", stepSize: "+stepSize+", min: "+min+", max: "+max);
- return false;
+ return false;
}
if (increment)
{
@@ -4523,17 +4547,17 @@
if (incrementedValue < max)
input.value = incrementedValue;
else if (circular)
- input.value = min;
+ input.value = min;
else input.value = max;
}
else
{
var decrementedValue = parseFloat(value) - parseFloat(stepSize);
-
+
if (decrementedValue > min)
input.value = decrementedValue;
else if (circular)
- input.value = max;
+ input.value = max;
else input.value = min;
}
return true;
@@ -4541,9 +4565,9 @@
return false;
}
-/* This function is called when the inputNumberSpinbox component's spinbox
+/* This function is called when the inputNumberSpinbox component's spinbox
* buttons are released (onmouseup).
- * This function stops the spinboxTimer.
+ * This function stops the spinboxTimer.
* The spinboxTimer calls _stepSpinboxValue in one second increments.
*/
function _clearSpinbox()
@@ -4553,14 +4577,14 @@
}
/**
- * This function is called when the inputNumberSpinbox component's
- * spinbox buttons are pressed. This is called onmousedown.
+ * This function is called when the inputNumberSpinbox component's
+ * spinbox buttons are pressed. This is called onmousedown.
* It calls the _stepSpinboxValue function to increment or decrement
* the input element's value. We call this repeatedly every second.
* onmouseup the component calls _clearSpinbox which clears the timeout.
*/
function _spinboxRepeat(id, increment, stepSize, min, max)
-{
+{
// increment/decrement
var success = _stepSpinboxValue(id, increment, stepSize, min, max);
// if not successful, then clear the timeout and return
@@ -4573,7 +4597,7 @@
if (_spinboxRepeat.functionString == null)
{
// setup the function to pass to the timeout.
- _spinboxRepeat.functionString =
+ _spinboxRepeat.functionString =
"_spinboxRepeat('"+id+"',"+increment+
","+stepSize+","+min+","+max+");";
}
@@ -4588,9 +4612,9 @@
{
if(typeof(event) == 'undefined')
return window.event;
- else
+ else
return event;
-
+
return null;
}
@@ -4641,13 +4665,13 @@
/**
* Get the client window size.
* TODO - make this public?
- *
+ *
* @return {Object} the client size of the window. The returned object will have w and h properties.
*/
TrUIUtils._getWindowClientSize = function()
{
var func;
-
+
if (TrUIUtils['_getWinClientSize'] == null)
{
// IE is abnormal
@@ -4667,15 +4691,15 @@
}
}
}
-
+
return TrUIUtils._getWinClientSize();
}
/**
* Return the offset bounds of an element
* TODO - make this public?
- *
- * @param elem {String or Element} the ID of an element or an element reference
+ *
+ * @param elem {String or Element} the ID of an element or an element reference
* @return {Object} the returned object will have x, y, w and h properties.
* Returns null if the element does not exist
*/
@@ -4697,8 +4721,8 @@
* Get the location of an element in relation to the view port.
* This will return the same co-ordinates as browser events (i.e. mouse event locations).
* TODO - make this public?
- *
- * @param elem {String or Element} the ID of an element or an element reference
+ *
+ * @param elem {String or Element} the ID of an element or an element reference
* @return {Object} the location on the page. The returned object will have x and y properties.
* Returns null if the element does not exist
*/
@@ -4712,9 +4736,9 @@
{
return null;
}
-
+
var func;
-
+
if (TrUIUtils['_getElemLoc'] == null)
{
// if possible, use more accurate browser specific methods
@@ -4740,7 +4764,7 @@
var loc = { x: rect.left, y: rect.top };
var docElem = doc.documentElement;
var scrollLeft = docElem.scrollLeft;
-
+
var rtl = docElem["dir"] == "rtl";
// IE scroll bar adjustment
if (rtl)
@@ -4756,7 +4780,7 @@
{
TrUIUtils._getElemLoc = function(elem)
{
- var win = elem.ownerDocument.contentWindow;
+ var win = elem.ownerDocument.contentWindow;
// use offset* properties to determine location
var curleft = 0;
var curtop = 0;
@@ -4769,7 +4793,7 @@
}
}
}
-
+
return TrUIUtils._getElemLoc(elem);
}
@@ -4788,7 +4812,7 @@
upperNext = true;
continue;
}
-
+
if (upperNext)
{
jsProp += prop.charAt(c).toUpperCase();
@@ -4797,10 +4821,10 @@
{
jsProp += prop.charAt(c);
}
-
+
upperNext = false;
}
-
+
return jsProp;
}
Modified: myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js?rev=709015&r1=709014&r2=709015&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js (original)
+++ myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js Wed Oct 29 14:29:27 2008
@@ -6,9 +6,9 @@
* 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
@@ -18,18 +18,18 @@
*/
/**
- * The RequestQueue class is a service to serialize the XML HTTP
+ * The RequestQueue class is a service to serialize the XML HTTP
* request communication from the client to the server.
*/
function TrRequestQueue(domWindow)
-{
+{
this._state = TrRequestQueue.STATE_READY;
this._requestQueue = new Array();
// listeners that are interested in the state change of this service object
this._stateChangeListeners = null;
//this._iframeLoadCallback = undefined;
- // Stash away the DOM window for later reference.
+ // Stash away the DOM window for later reference.
this._window = domWindow;
}
@@ -38,7 +38,7 @@
TrRequestQueue.STATE_BUSY = 1;
// frame used for multi-part form post
TrRequestQueue._MULTIPART_FRAME = "_trDTSFrame";
-
+
TrRequestQueue._XMLHTTP_TYPE = 0;
TrRequestQueue._MULTIPART_TYPE = 1;
@@ -53,7 +53,7 @@
TrRequestQueue._RequestItem = function(
type,
- context,
+ context,
actionURL,
headerParams,
content,
@@ -88,7 +88,7 @@
TrRequestQueue.prototype._addRequestToQueue = function(
type,
- context,
+ context,
listener,
actionURL,
content,
@@ -98,20 +98,20 @@
var newRequest = new TrRequestQueue._RequestItem(
type, context, actionURL, headerParams, content, listener);
this._requestQueue.push(newRequest);
-
+
try
{
var dtsRequestEvent = new TrXMLRequestEvent(
TrXMLRequestEvent.STATUS_QUEUED,
null); // no xmlhttp object at this time
-
+
this._broadcastRequestStatusChanged(context, listener, dtsRequestEvent);
- }
+ }
catch(e)
{
TrRequestQueue._logError("Error on listener callback invocation - STATUS_QUEUED", e);
}
-
+
if(this._state == TrRequestQueue.STATE_READY)
{
this._state = TrRequestQueue.STATE_BUSY;
@@ -144,7 +144,7 @@
{
var content = this._getPostbackContent(actionForm, params);
- // IE BUG, see TRINIDAD-704
+ // IE BUG, see TRINIDAD-704
if(_agent.isIE && window.external)
window.external.AutoCompleteSaveForm(actionForm);
@@ -169,9 +169,9 @@
if (actionForm.enctype.toLowerCase() != "multipart/form-data")
return false;
- var inputs = actionForm.getElementsByTagName("input"),
+ var inputs = actionForm.getElementsByTagName("input"),
inputCount = inputs.length, multiPartForm = null;
-
+
for (var i = 0; i < inputCount; ++i)
{
var inputElem = inputs[i];
@@ -180,7 +180,7 @@
return true;
}
}
-
+
return false;
}
@@ -193,7 +193,7 @@
TrRequestQueue.prototype._getPostbackContent = function(actionForm, params)
{
var formElements = actionForm.elements;
-
+
// 1. build up formParams
var formParams = {};
if (formElements)
@@ -201,7 +201,7 @@
for (var elementIndex = 0; elementIndex < formElements.length; elementIndex++)
{
var input = formElements[elementIndex];
-
+
// todo: do not post values for non-triggering submit buttons
// TRINIDAD-874 skip input.type="submit" fields
if (input.name && !input.disabled && !(input.tagName=="INPUT" && input.type=="submit"))
@@ -223,11 +223,11 @@
// if this happens to be an unselected checkbox or radio then
// skip it. Otherwise, if it is any other form control, or it is
// a selected checkbox or radio than add it:
- else if (!((input.type == "checkbox" ||
- input.type == "radio") &&
+ else if (!((input.type == "checkbox" ||
+ input.type == "radio") &&
!input.checked))
{
- // the value might already have been set (because of a
+ // the value might already have been set (because of a
// multi-select checkbox group:
var current = formParams[input.name];
if (current)
@@ -254,14 +254,14 @@
}
}
}
-
+
// 2. override formParams with params
for (var key in params)
{
var value = params[key];
formParams[key] = params[key];
}
-
+
// 3. create form submit payload
var content = "";
for (var key in formParams)
@@ -297,7 +297,7 @@
{
buffer = buffer + "&";
}
-
+
return buffer + key + "=" + value.toString().replace(/\%/g, '%25')
.replace(/\+/g, '%2B')
.replace(/\//g, '%2F')
@@ -312,7 +312,7 @@
/**
* Performs Asynchronous XML HTTP Request with the Server
-* @param context any object that is sent back to the callback when the request
+* @param context any object that is sent back to the callback when the request
* is complete. This object can be null.
* @param method Javascript method
* @param actionURL the url to send the request to
@@ -332,10 +332,10 @@
/**
* Performs Asynchronous HTTP Request with the Server for multipart data
-* @param context any object that is sent back to the callback when the request
+* @param context any object that is sent back to the callback when the request
* is complete. This object can be null.
* @param actionURL this is the appropriate action url
-* @param htmlForm the form containing multi-part data. The action attribute
+* @param htmlForm the form containing multi-part data. The action attribute
* of the form is used for send the request to the server
* @param params additional parameters that need to be sent to the server
* @param method Javascript method
@@ -365,10 +365,10 @@
case TrRequestQueue._XMLHTTP_TYPE:
this._doXmlHttpRequest(requestItem);
break;
-
- case TrRequestQueue._MULTIPART_TYPE:
+
+ case TrRequestQueue._MULTIPART_TYPE:
this._doRequestThroughIframe(requestItem);
- break;
+ break;
}
}
@@ -379,19 +379,19 @@
xmlHttp.__dtsRequestMethod = requestItem._method;
var callback = TrUIUtils.createCallback(this, this._handleRequestCallback);
xmlHttp.setCallback(callback);
-
+
// xmlhttp request uses the same charset as its parent document's charset.
// There is no need to set the charset.
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
-
+
var headerParams = requestItem._headerParams;
-
+
if (headerParams != null)
{
for (var headerName in headerParams)
{
var currHeader = headerParams[headerName];
-
+
// handle array parameters by joining them together with comma separators
// Test if it's an array via the "join" method
if (currHeader["join"])
@@ -400,7 +400,7 @@
xmlHttp.setRequestHeader(headerName, currHeader);
}
}
-
+
xmlHttp.send(requestItem._actionURL, requestItem._content);
}
@@ -424,10 +424,10 @@
frameStyle.width = frameStyle.height = '1px'
frameStyle.position = 'absolute';
frameStyle.visibility = "hidden";
-
+
domDocument.body.appendChild(hiddenFrame);
}
-
+
if (agentIsIE)
{
// Why these lines happen to work, I can't say - but remove them,
@@ -443,7 +443,7 @@
else
{
iframeDoc = hiddenFrame.contentDocument;
- }
+ }
// We may not have a document yet for the IFRAME, since
// nothing has been loaded (appears to work this way on Safari)
@@ -456,15 +456,15 @@
this._htmlForm = htmlForm;
this._savedActionUrl = htmlForm.action;
this._savedTarget = htmlForm.target;
-
+
// FIXME: why are the next two lines at all necessary? The form
// should already be set to post, and if the action has been
- // updated since this was queued
+ // updated since this was queued
htmlForm.method = "POST";
htmlForm.action = actionURL;
htmlForm.target = frameName;
-
+
this._appendParamNode(domDocument, htmlForm, "Tr-XHR-Message", "true");
// FIXME: the "partial" parameter is unnecessary
this._appendParamNode(domDocument, htmlForm, "partial", "true");
@@ -476,30 +476,54 @@
this._appendParamNode(domDocument, htmlForm, key, params[key]);
}
}
-
+
if(this._iframeLoadCallback == null)
this._iframeLoadCallback = TrUIUtils.createCallback(this, this._handleIFrameLoad);
- // IE BUG, see TRINIDAD-704
+ // IE BUG, see TRINIDAD-704
if(_agent.isIE && window.external)
window.external.AutoCompleteSaveForm(htmlForm);
- htmlForm.submit();
-
+
+ try
+ {
+ htmlForm.submit();
+ }
+ catch (e)
+ {
+ if (this._isMultipartForm(htmlForm))
+ {
+ // IE will fail on an input file submission of a file that does not exist
+ var facesMessage = _createFacesMessage(
+ 'org.apache.myfaces.trinidad.component.core.input.CoreInputFile.INPUT_FILE_ERROR');
+ // if there's nowhere to display the message in either
+ // summary or detail, then pop an alert to warn the page developer
+ if (!TrMessageBox.isPresent())
+ alert(facesMessage.getDetail());
+ else
+ // Add the message to the MessageBox
+ TrMessageBox.addMessage(null, null, facesMessage);
+ }
+ else
+ {
+ throw e;
+ }
+ }
+
this._window.setTimeout(this._iframeLoadCallback, 50);
}
TrRequestQueue.prototype._appendParamNode = function(domDocument, form, name, value)
{
// assert(form!=null);
-
+
var nodes = this._paramNodes;
-
+
if(!nodes)
{
nodes = new Array();
this._paramNodes = nodes;
}
-
+
var node = domDocument.createElement("input");
node.type = "hidden";
node.name = name;
@@ -511,17 +535,17 @@
TrRequestQueue.prototype._clearParamNodes = function()
{
var nodes = this._paramNodes;
-
+
if(nodes)
{
var form = nodes[0].parentNode;
var count = nodes.length;
-
+
for (var i = 0; i < count; i++)
{
form.removeChild(nodes[i]);
}
-
+
delete this._paramNodes;
}
}
@@ -542,10 +566,10 @@
hiddenFrame = domDocument.getElementById(frameName);
iframeDoc = hiddenFrame.contentDocument;
}
-
+
try
{
- if(!iframeDoc.documentElement || !iframeDoc.documentElement.firstChild
+ if(!iframeDoc.documentElement || !iframeDoc.documentElement.firstChild
|| (agentIsIE && iframeDoc.readyState != "complete"))
{
this._window.setTimeout(this._iframeLoadCallback, 50);
@@ -572,10 +596,10 @@
requestMethod)
{
try
- {
+ {
var dtsRequestEvent = new TrIFrameXMLRequestEvent(
iframeDoc);
-
+
this._broadcastRequestStatusChanged(context, requestMethod,dtsRequestEvent);
}
finally
@@ -596,10 +620,10 @@
)
{
var httpState = xmlHttp.getCompletionState();
-
+
if(httpState != TrXMLRequest.COMPLETED)
return;
-
+
var statusCode = 0;
var failedConnectionText = TrRequestQueue._getFailedConnectionText();
try
@@ -611,7 +635,7 @@
// Drop the exception without logging anything.
// Firefox will throw an exception on attempting
// to get the status of an XMLHttpRequest if
- // the Http connection has been closed
+ // the Http connection has been closed
}
if ((statusCode != 200) && (statusCode != 0))
@@ -622,16 +646,16 @@
") while performing request\n",
xmlHttp.getResponseText());
}
-
+
try
- {
+ {
if (statusCode != 0)
{
var dtsRequestEvent = new TrXMLRequestEvent(
TrXMLRequestEvent.STATUS_COMPLETE,
xmlHttp);
this._broadcastRequestStatusChanged(
- xmlHttp.__dtsRequestContext,
+ xmlHttp.__dtsRequestContext,
xmlHttp.__dtsRequestMethod,
dtsRequestEvent);
}
@@ -663,7 +687,7 @@
/**
* Adds a listener to the request queue that is interested in its state change.
-* The listners are notified in the order that they are added. A listener can cancel
+* The listners are notified in the order that they are added. A listener can cancel
* notification to other listeners in the chain by returning false.
*
* @param {function} listener listener function to remove
@@ -673,15 +697,15 @@
{
// assertFunction(listener);
// assertObjectOrNull(instance);
-
+
var stateChangeListeners = this._stateChangeListeners;
-
+
if (!stateChangeListeners)
{
stateChangeListeners = new Array();
this._stateChangeListeners = stateChangeListeners;
}
-
+
stateChangeListeners.push(listener);
stateChangeListeners.push(instance);
}
@@ -698,27 +722,27 @@
// remove the listener/instance combination
var stateChangeListeners = this._stateChangeListeners;
-
+
// assert(stateChangeListeners, "stateChangeListeners must exist");
var length = stateChangeListeners.length;
-
+
for (var i = 0; i < length; i++)
{
var currListener = stateChangeListeners[i];
i++;
-
+
if (currListener == listener)
{
var currInstance = stateChangeListeners[i];
-
+
if (currInstance === instance)
{
stateChangeListeners.splice(i - 1, 2);
}
}
}
-
+
// remove array, if empty
if (stateChangeListeners.length == 0)
{
@@ -741,12 +765,12 @@
TrRequestQueue.prototype._broadcastStateChangeEvent = function(state)
{
var stateChangeListeners = this._stateChangeListeners;
-
+
// deliver the state change event to the listeners
if (stateChangeListeners)
{
var listenerCount = stateChangeListeners.length;
-
+
for (var i = 0; i < listenerCount; i++)
{
try
@@ -754,7 +778,7 @@
var currListener = stateChangeListeners[i];
i++;
var currInstance = stateChangeListeners[i];
-
+
if (currInstance != null)
currListener.call(currInstance, state);
else