PDA

View Full Version : [CLOSED] filefield error after update sources from SVN 4702



supera
Dec 27, 2012, 12:52 PM
hi!

After update sources from SVN 4702, I get this error when I try a upload file...

Runtime Error in Microsoft JScript: Can not get property value 'dom': the object is null or undefined

5321

I made a sample!



<%@ Page Language="vb" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>

<script type="text/javascript">

Ext.onReady(function () {

var viewPort = Ext.create("Ext.net.Viewport", {
id: "ViewportConsole",
renderTo: Ext.getBody(),
layout: 'border',
padding: '50 50'
});

//paneMain
var paneMain = viewPort.add({
itemId: 'mainPanel',
layout: 'absolute',
title: 'fileUpload',
region: 'center',
border: true,
bodyPadding: 6
});

var formFileUpdate = paneMain.add({
fileUpload: true,
xtype: 'form',
x: 5,
y: 5,
width: 400,
height: 50,
//hidden: true,
layout: 'absolute',
border: false,
defaults: {
'labelAlign': 'top'
}
});

//txtFileUpload
formFileUpdate.add({
itemId: 'txtFileUpload',
xtype: 'filefield',
x: 5,
y: 5,
width: 390,
emptyText: 'Select a file',
fieldLabel: 'File name',
buttonText: 'Select a file'
// buttonConfig: {
// iconCls: 'upload_16'
// }
});

paneMain.add({
xtype: 'button',
text: 'send',
x: 10,
y: 80,
listeners: {
click: {
fn: function (item) {
paneMain.upLoadFile();
}
}
}
})

paneMain.upLoadFile = function (data) {
formFileUpdate.submit({
url: '/testfile2.aspx',
params: { ID: 0 }, //here, I set the code of image in database, if is edit image.
waitMsg: 'Uploading... Please wait...',
success: function (fp, o) {
Ext.Msg.alert('Success', o.result.msg);
},
failure: function (form, action) {
alert('failure');
switch (action.failureType) {
case Ext.form.Action.CLIENT_INVALID:
Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
break;
case Ext.form.Action.CONNECT_FAILURE:
Ext.Msg.alert('Failure', 'Ajax communication failed');
break;
case Ext.form.Action.SERVER_INVALID:
Ext.Msg.alert('Failure', action.result.msg);
break;
default:
Ext.Msg.alert('Failure', action.result.msg);
break;
}
}
});
}

});

</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
</form>
</body>
</html>

Daniil
Dec 27, 2012, 3:04 PM
Hi @supera,

Thank you for the report.

How does the "testfile2.aspx" page look?

supera
Dec 27, 2012, 3:28 PM
Hi @supera,

Thank you for the report.

How does the "testfile2.aspx" page look?

Oops! sorry!

Follow!



<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e) {
string s = "<html><body><textarea>{0}</textarea></body></html>";
this.Response.Clear();
this.Response.ContentType = "text/html";
this.Response.Write(string.Format(s, Ext.Net.JSON.Serialize(new {
success = true, msg = "All OK"
})));
this.Response.End();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">
<title></title>
</head>

<body>
<form id="form1" runat="server">
<div></div>
</form>
</body>

</html>

Vladimir
Dec 27, 2012, 4:09 PM
I cannot reproduce the issue
Tested under IE9, FF 17 and Chrome 23. In all browsers I see 'All OK' message

supera
Dec 27, 2012, 4:34 PM
I cannot reproduce the issue
Tested under IE9, FF 17 and Chrome 23. In all browsers I see 'All OK' message

For me, still occurs error!

Any tip?

IE9 9.0.8112.16421
FFox 17.0.1
Chrome 23.0.1271.97 m

I'm using VS2010

5322

Vladimir
Dec 27, 2012, 5:04 PM
It seems that you use old code because latest code has no such code


this.fileInputEl.dom.value


now the following code is used in SVN


this.button.fileInputEl.dom.value

just check what assembly do you use

What SVN location do you use?

supera
Dec 27, 2012, 5:14 PM
Hi Vladimir!

Thanks for your help!

I update from SVN from this uri: http://svn.ext.net/premium/branches/2.1

Vladimir
Dec 27, 2012, 5:28 PM
Branch 2.1 is not under development now. It should not be used anymore
Trunk is under development now, but please note that current ExtJS version in trunk is 4.2 beta

Another option, update from 'branches/2', it is public 2.1.1 release, ExtJS version is 4.1.1

supera
Dec 27, 2012, 6:37 PM
Hi Vladimir!

I set the SVN url to /trunk

Works very fine!

Thanks a lot.

supera
Dec 31, 2012, 12:28 PM

Daniil
Dec 31, 2012, 12:40 PM

supera
Dec 31, 2012, 12:47 PM

Daniil
Dec 31, 2012, 1:24 PM
We will much appreciate any bug reports! Actually, you make a big contribution in Ext.NET!

supera
Jan 02, 2013, 4:18 PM

Daniil
Jan 03, 2013, 7:25 AM
Hi @supera,

Well, there are the fixes in the 2.1 branch that you need, then, I think you can use this branch.

But I was unable to reproduce the error with the FileUploadField using your sample and the Ext.NET sources from the 2.1 branch.

Please double ensure your sample does reproduce the issue and the project refers the 2.1 branch dlls.

supera
Jan 28, 2013, 3:28 PM
Hi Daniil!!!

Sorry about my lag in response the thread...
I'm returning from vacation...

Refering the last message...

I'm downloading the source codes from SVN in http://svn.ext.net/premium/branches/2.1
I updated my source code today from SVN to 4766.
I still get this error:
5491

In body of message are write:
runtime error in the javascript: Can not get property 'dom' undefined reference or null.

This error occurs in all browsers.
In time: I change my environment: Windows 8, VS2012, SQL Express 2012, IE 10.

Follow bellow the sample Project.


<%@ Page Language="vb" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>

<style type="text/css">
.upload_16 {
background-image: url(/upload.png) !important;
}
</style>

<script type="text/javascript">

Ext.onReady(function () {

var viewPort = Ext.create("Ext.net.Viewport", {
id: "ViewportConsole",
renderTo: Ext.getBody(),
layout: 'border',
padding: '50 50'
});

//paneMain
var paneMain = viewPort.add({
itemId: 'mainPanel',
layout: 'absolute',
title: 'fileUpload',
region: 'center',
border: true,
bodyPadding: 6
});

var formFileUpdate = paneMain.add({
fileUpload: true,
xtype: 'form',
x: 5,
y: 5,
width: 400,
height: 50,
//hidden: true,
layout: 'absolute',
border: false,
defaults: {
'labelAlign': 'top'
}
});

//txtFileUpload
formFileUpdate.add({
itemId: 'txtFileUpload',
xtype: 'filefield',
x: 5,
y: 5,
width: 390,
emptyText: 'Select a file',
fieldLabel: 'File name',
buttonText: '',
buttonConfig: {
iconCls: 'upload_16'
}
// buttonConfig: {
// iconCls: 'upload_16'
// }
});

paneMain.add({
xtype: 'button',
text: 'send',
x: 10,
y: 80,
listeners: {
click: {
fn: function (item) {
paneMain.upLoadFile();
}
}
}
})

paneMain.upLoadFile = function (data) {
formFileUpdate.submit({
url: '/testfile2.aspx',
params: { ID: 0 }, //here, I set the code of image in database, if is edit image.
waitMsg: 'Uploading... Please wait...',
success: function (fp, o) {
Ext.Msg.alert('Success', o.result.msg);
},
failure: function (form, action) {
alert('failure');
switch (action.failureType) {
case Ext.form.Action.CLIENT_INVALID:
Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
break;
case Ext.form.Action.CONNECT_FAILURE:
Ext.Msg.alert('Failure', 'Ajax communication failed');
break;
case Ext.form.Action.SERVER_INVALID:
Ext.Msg.alert('Failure', action.result.msg);
break;
default:
Ext.Msg.alert('Failure', action.result.msg);
break;
}
}
});
}

});

</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
</form>
</body>
</html>




<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e) {
string s = "<html><body><textarea>{0}</textarea></body></html>";
this.Response.Clear();
this.Response.ContentType = "text/html";
this.Response.Write(string.Format(s, Ext.Net.JSON.Serialize(new {
success = true, msg = "All OK"
})));
this.Response.End();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">
<title></title>
</head>

<body>
<form id="form1" runat="server">
<div></div>
</form>
</body>

</html>


Thanks for your help!!!

Daniil
Jan 29, 2013, 4:40 AM
Glad to see you again:)

Please set up ScriptMode="Debug" for the ResourceManager of the page where the error occurs and post the whole JavaScript function where the error occurs.

supera
Jan 29, 2013, 9:22 AM
Hi Danill!!!


Follow de javascript code:
The error occurs in function onFileChange this line: var v = this.fileInputEl.dom.value,



Ext.form.field.File.override({
stripPath : true,

isIconIgnore : function () {
return true;
},

onFileChange : function () {
this.lastValue = null;

if (this.stripPath === false) {
Ext.form.field.File.superclass.setValue.call(this, this.fileInputEl.dom.value);
return;
}

var v = this.fileInputEl.dom.value,
fileNameRegex = /[^\\]*$/im,
match = fileNameRegex.exec(v);

if (match !== null) {
v = match[0];
}

Ext.form.field.File.superclass.setValue.call(this, v);
},

onEnable: function(){
var me = this;
me.callParent();
me.fileInputEl.dom.removeAttribute("disabled");
this['buttonEl-btnEl'].dom.removeAttribute("disabled");
me.browseButtonWrap.child('.x-btn').removeCls(["x-item-disabled", "x-btn-disabled"]);
},

disableItems: function(){
var file = this.fileInputEl;
if (file) {
file.dom.disabled = true;
}
this['buttonEl-btnEl'].dom.disabled = true;
this.browseButtonWrap.child('.x-btn').addCls(["x-item-disabled", "x-btn-disabled"]);
},

checkChange: function() {
if (!this.suspendCheckChange) {
var me = this,
newVal = me.getValue(),
oldVal = me.lastValue;
if (!me.isEqual(newVal, oldVal) && !me.isDestroyed && !Ext.isEmpty(newVal)) {
me.lastValue = newVal;
me.fireEvent('change', me, newVal, oldVal);
me.onChange(newVal, oldVal);
}
}
}
});

Daniil
Jan 29, 2013, 10:37 AM
Thank you.

Well, I don't see such code in the 2.1 branch.

The code is a bit different there.

Ext.form.field.File.override({
stripPath : true,

isIconIgnore : function () {
return true;
},

onFileChange : function () {
this.lastValue = null;

if (this.stripPath === false) {
Ext.form.field.File.superclass.setValue.call(this, this.button.fileInputEl.dom.value);
return;
}

var v = this.button.fileInputEl.dom.value,
fileNameRegex = /[^\\]*$/im,
match = fileNameRegex.exec(v);

if (match !== null) {
v = match[0];
}

Ext.form.field.File.superclass.setValue.call(this, v);
},

onEnable: function () {
var me = this;
me.callParent();
me.button.fileInputEl.dom.removeAttribute("disabled");
},

reset : function () {
this.callParent();
if (this.disabled) {
this.button.fileInputEl.dom.disabled = true;
}
}
});

So, I guess you use something else rather than 2.1 branch:)

This is the link for the 2.1 branch.
http://svn.ext.net/premium/branches/2.1/

supera
Jan 29, 2013, 11:37 AM

Daniil
Jan 29, 2013, 12:05 PM
Please double ensure you attach the correct Ext.NET dlls (from your local 2.1 folder) to your test project.

Please open this link in the browser.
http://svn.ext.net/premium/branches/2.1/Ext.Net/Build/Ext.Net/extnet/src/form/FileUploadField.js

There is definitely another code:)


TortoiseSVN configurations, maybe??

I doubt...

supera
Jan 29, 2013, 12:59 PM
Hi Daniil!

The file FileUploadField.js in my local machine is the same as the file in link that you post (see image).

5498

but, the extnet-all.js and extnet-all-debug.js are deprecated (see images).

5499

5500

I checked the extnet-all-debug.js in SVN http://svn.ext.net/premium/branches/2.1/Ext.Net/Build/Ext.Net/extnet/extnet-all-debug.js and is the same code.

5501

this may be the cause of my problem?
Thanks for your help!

Daniil
Jan 29, 2013, 1:28 PM
Yes, this is a problem. I committed the fix, please update and re-test.

I would recommend to retest the whole application, because there are many changes were missed in extnet-all.js and extnet-all-debug.js.

Apologize for the inconvenience.

supera
Jan 29, 2013, 2:53 PM
Hi Daniil!!!

The fileuploadfield issue was solved!

I will follow your suggestion and I will retest my application...

Thanks a lot for your help!

Daniil
Jan 30, 2013, 4:22 AM
I will follow your suggestion and I will retest my application...

We are ready to help if you will face any problems.