You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by lbastil <ba...@gmx.de> on 2007/12/13 11:31:33 UTC
[S2] why is javascript executed before DOM is updated
I have a serious problem with an ajax submit.
the scenario is the following:
I submit a form with ajax submit button and I want to update the parent div
(targets="...")
The original content of this div and the result content contains a <script>
section with
javascript at the very end.
Now the following happens: after pressing the submit button the ajax call is
done correctly.
But after that at first the script is executed, then the DOM is updated by
replacing originally div
content with the result from ajax call.
But this is not what I would expect. The javascript for instance changes
some things (like
enabling / disabling form elements), which are then overwritten by the DOM
updating.
The interesting thing is: originally the content of the div is also loaded /
filled by ajax mechanisms,
but not triggered from <s:submit>. In this first case the javascript is
executed on the exact
order, where it is placed in the code. Why not when doing it via <s:submit>?
Can anybody explain me what is going on here and suggest a workaround?
Thank you very much in advance,
basti
--
View this message in context: http://www.nabble.com/-S2--why-is-javascript-executed-before-DOM-is-updated-tp14313561p14313561.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] why is javascript executed before DOM is updated
Posted by lbastil <ba...@gmx.de>.
For me it is still not clear:
with struts 2.0.11, how can I:
modyfy DOM which is given back from an AJAX request with javascript at all?
concrete:
suppose, I have a form, which is updated by a dojo ajax requst.
After the form is updated I wnat to execute a javascript which disables two
of the
submit buttons in the form. Hoy can I do this task?
thank you in advance.
Jeromy Evans - Blue Sky Minds wrote:
>
> I think it is WW-1951.
>
> It's generally a bad idea to include inline scripts in a result loaded
> via XHR because it varies from browser-to-browser and library-to-library
> as to when the scripts are executed. In this case, Dojo has the
> responsibility to parse your result, extract the scripts and then
> execute them (when separateScripts is false and executeScripts is
> true). If, for example, you only used element.innerHTML directly to
> update your page the script would not be executed at all (in most
> browsers). The point is, the Dojo widget is explicitly separating and
> executing your scripts in the result.
>
> In 2.1, revision #543927, the Bind widget was modified to execute
> scripts after setting the content. In 2.0, scripts are executed after
> parsing but before setting the content.
>
> I think you have a couple of options:
> - (recommended) refactor your javascript so its not inline. For
> example, you may be able to listen for an event instead
> - if you're sure it's only s:submit that has the problem and s:div is
> okay, have the submit publish a topic and have a s:div subscribe and
> perform the request itself
> - patch the widget in struts 2.0 with the same change as in 2.1, and
> build your own dojo release.
>
> Hope that helps a little,
> Jeromy Evans
>
> lbastil wrote:
>> Is this the WW-1951 - issue?
>>
>> And if so, is there any workaround for 2.0.11 release?
>>
>> Thank you,
>> basti
>>
>>
>> lbastil wrote:
>>
>>> I have a serious problem with an ajax submit.
>>>
>>> the scenario is the following:
>>>
>>> I submit a form with ajax submit button and I want to update the parent
>>> div (targets="...")
>>> The original content of this div and the result content contains a
>>> <script> section with
>>> javascript at the very end.
>>>
>>> Now the following happens: after pressing the submit button the ajax
>>> call
>>> is done correctly.
>>> But after that at first the script is executed, then the DOM is updated
>>> by
>>> replacing originally div
>>> content with the result from ajax call.
>>>
>>> But this is not what I would expect. The javascript for instance changes
>>> some things (like
>>> enabling / disabling form elements), which are then overwritten by the
>>> DOM
>>> updating.
>>>
>>> The interesting thing is: originally the content of the div is also
>>> loaded
>>> / filled by ajax mechanisms,
>>> but not triggered from <s:submit>. In this first case the javascript is
>>> executed on the exact
>>> order, where it is placed in the code. Why not when doing it via
>>> <s:submit>?
>>>
>>> Can anybody explain me what is going on here and suggest a workaround?
>>>
>>> Thank you very much in advance,
>>> basti
>>>
>>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/-S2--why-is-javascript-executed-before-DOM-is-updated-tp14313561p20090151.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] why is javascript executed before DOM is updated
Posted by Jeromy Evans <je...@blueskyminds.com.au>.
I think it is WW-1951.
It's generally a bad idea to include inline scripts in a result loaded
via XHR because it varies from browser-to-browser and library-to-library
as to when the scripts are executed. In this case, Dojo has the
responsibility to parse your result, extract the scripts and then
execute them (when separateScripts is false and executeScripts is
true). If, for example, you only used element.innerHTML directly to
update your page the script would not be executed at all (in most
browsers). The point is, the Dojo widget is explicitly separating and
executing your scripts in the result.
In 2.1, revision #543927, the Bind widget was modified to execute
scripts after setting the content. In 2.0, scripts are executed after
parsing but before setting the content.
I think you have a couple of options:
- (recommended) refactor your javascript so its not inline. For
example, you may be able to listen for an event instead
- if you're sure it's only s:submit that has the problem and s:div is
okay, have the submit publish a topic and have a s:div subscribe and
perform the request itself
- patch the widget in struts 2.0 with the same change as in 2.1, and
build your own dojo release.
Hope that helps a little,
Jeromy Evans
lbastil wrote:
> Is this the WW-1951 - issue?
>
> And if so, is there any workaround for 2.0.11 release?
>
> Thank you,
> basti
>
>
> lbastil wrote:
>
>> I have a serious problem with an ajax submit.
>>
>> the scenario is the following:
>>
>> I submit a form with ajax submit button and I want to update the parent
>> div (targets="...")
>> The original content of this div and the result content contains a
>> <script> section with
>> javascript at the very end.
>>
>> Now the following happens: after pressing the submit button the ajax call
>> is done correctly.
>> But after that at first the script is executed, then the DOM is updated by
>> replacing originally div
>> content with the result from ajax call.
>>
>> But this is not what I would expect. The javascript for instance changes
>> some things (like
>> enabling / disabling form elements), which are then overwritten by the DOM
>> updating.
>>
>> The interesting thing is: originally the content of the div is also loaded
>> / filled by ajax mechanisms,
>> but not triggered from <s:submit>. In this first case the javascript is
>> executed on the exact
>> order, where it is placed in the code. Why not when doing it via
>> <s:submit>?
>>
>> Can anybody explain me what is going on here and suggest a workaround?
>>
>> Thank you very much in advance,
>> basti
>>
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] why is javascript executed before DOM is updated
Posted by lbastil <ba...@gmx.de>.
Is this the WW-1951 - issue?
And if so, is there any workaround for 2.0.11 release?
Thank you,
basti
lbastil wrote:
>
> I have a serious problem with an ajax submit.
>
> the scenario is the following:
>
> I submit a form with ajax submit button and I want to update the parent
> div (targets="...")
> The original content of this div and the result content contains a
> <script> section with
> javascript at the very end.
>
> Now the following happens: after pressing the submit button the ajax call
> is done correctly.
> But after that at first the script is executed, then the DOM is updated by
> replacing originally div
> content with the result from ajax call.
>
> But this is not what I would expect. The javascript for instance changes
> some things (like
> enabling / disabling form elements), which are then overwritten by the DOM
> updating.
>
> The interesting thing is: originally the content of the div is also loaded
> / filled by ajax mechanisms,
> but not triggered from <s:submit>. In this first case the javascript is
> executed on the exact
> order, where it is placed in the code. Why not when doing it via
> <s:submit>?
>
> Can anybody explain me what is going on here and suggest a workaround?
>
> Thank you very much in advance,
> basti
>
--
View this message in context: http://www.nabble.com/-S2--why-is-javascript-executed-before-DOM-is-updated-tp14313561p14314137.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Ajax file upload + RE: About the "struts.multipart.saveDir" for file upload
Posted by Qunhuan Mei <qm...@qm18.wanadoo.co.uk>.
Ok Wes, I'll wait for your code to be ready. You guys hard work make us
developers' work easier. Many thanks for that! Qunhuan
-----Original Message-----
From: Wes Wannemacher [mailto:wesw@wantii.com]
Sent: 04 June 2009 13:38
To: Struts Users Mailing List
Subject: Re: Ajax file upload + RE: About the "struts.multipart.saveDir" for
file upload
Really, I haven't gotten that far yet, I am only working to improve
the integration with Jakarta FileUpload. JFU is quite capable and
mature, but I figured the first step would be to expose more
functionality since there were a few JIRAs related to people asking
for more than what is currently offered.
I committed a partially complete plugin to the sandbox yesterday
before I left my office, but I still need to glue it together with
configuration, etc. (and work out a bug I realized I had in the middle
of the night last night). Once I get the plugin to an installable
state, you can check it out. I figure the first step is to make the
plugin work, then the next step is building an example UI. I am not
sure how I am going to build the example UI, but JQuery is probably
the most likely candidate for me.
As far as selecting multiple files with Ctrl-Click, I'm not sure if
that is possible... Not from a struts/jquery perspective, but I don't
know if the browser will let you do that. I think Flash may be the
only option (or a java applet or something, but flash is more likely),
so we can come back to that later.
-Wes
On Thu, Jun 4, 2009 at 4:07 AM, Qunhuan Mei <qm...@qm18.wanadoo.co.uk> wrote:
> Hi Wes,
>
> Struts’ ajax file upload would be very interesting to me since I have
> implemented jQuery (http://www.phpletter.com/Our-Projects/AjaxFileUpload/)
> and Struts for ajax file upload in my application and had one or two
> problem(s).
>
> FYI: My use case is to upload a file, together with utf8 encoded caption.
> The problem I had is utf8 encoded caption needs to be sent via HTTP POST,
it
> won’t work with HTTP get. But the jQuery arrangement is sending file in
POST
> while sending caption in Get. So what I did is to send caption and file in
> two POSTs which cause other complications. Later the author (Øyvind
Saltvik
> oyvind.saltvik@gmail.com) sent me the following code contributed by
> (Prokofiev Nikolay nprokofiev@gmail.com) which added the parameter POSTing
> (e.g. caption) to jQuery’s file upload.
>
> $.ajaxFileUpload
> (
> {
> url:document.location+'&ajax=true',
> secureuri:false,
> fileElementId:'fileToUpload',
> data: {foo: 'ghffgh', bar: 'fghfhgg'},
> dataType: 'json',
> success: function (data, status)
> {
> if(typeof(data.error) != 'undefined')
> {
> if(data.error != '')
> {
> alert(data.error);
> }else
> {
> alert(data.msg);
> }
> }
> },
> error: function (data, status, e)
> {
> alert(e);
> }
> }
> )
>
> here is the script:
> jQuery.extend({
> createUploadIframe: function(id, uri)
> {
> //create frame
> var frameId = 'jUploadFrame' + id;
>
> if(window.ActiveXObject) {
> var io = document.createElement('<iframe id="' + frameId +
> '" name="' + frameId + '" />');
> if(typeof uri== 'boolean'){
> io.src = 'javascript:false';
> }
> else if(typeof uri== 'string'){
> io.src = uri;
> }
> }
> else {
> var io = document.createElement('iframe');
> io.id = frameId;
> io.name = frameId;
> }
> io.style.position = 'absolute';
> io.style.top = '-1000px';
> io.style.left = '-1000px';
>
> document.body.appendChild(io);
>
> return io
> },
> createUploadForm: function(id, fileElementId, postData)
> {
> //create form
> var formId = 'jUploadForm' + id;
> var fileId = 'jUploadFile' + id;
> var form = $('<form action="" method="POST" name="' + formId + '"
> id="' + formId + '" enctype="multipart/form-data"></form>');
> var oldElement = $('#' + fileElementId);
> var newElement = $(oldElement).clone();
> $(oldElement).attr('id', fileId);
> $(oldElement).before(newElement);
> $(oldElement).appendTo(form);
> try
> {
> for(param in postData)
> {
> var input = document.createElement('input');
> input.setAttribute('name', param);
> input.setAttribute('value', postData[param]);
> $(input).appendTo(form);
> }
> }
> catch(e) {}
> //set attributes
> $(form).css('position', 'absolute');
> $(form).css('top', '-1200px');
> $(form).css('left', '-1200px');
> $(form).appendTo('body');
> return form;
> },
> ajaxFileUpload: function(s) {
> // TODO introduce global settings, allowing the client to modify
> them for all requests, not only timeout
> s = jQuery.extend({}, jQuery.ajaxSettings, s);
> var id = new Date().getTime()
> var form = jQuery.createUploadForm(id, s.fileElementId, s.data);
> var io = jQuery.createUploadIframe(id, s.secureuri);
> var frameId = 'jUploadFrame' + id;
> var formId = 'jUploadForm' + id;
> // Watch for a new set of requests
> if ( s.global && ! jQuery.active++ )
> {
> jQuery.event.trigger( "ajaxStart" );
> }
> var requestDone = false;
> // Create the request object
> var xml = {}
> if ( s.global )
> jQuery.event.trigger("ajaxSend", [xml, s]);
> // Wait for a response to come back
> var uploadCallback = function(isTimeout)
> {
> var io = document.getElementById(frameId);
> try
> {
> if(io.contentWindow)
> {
> xml.responseText =
>
io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null
> ;
> xml.responseXML =
>
io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:
> io.contentWindow.document;
>
> }else if(io.contentDocument)
> {
> xml.responseText =
>
io.contentDocument.document.body?io.contentDocument.document.body.innerHTML:
> null;
> xml.responseXML =
>
io.contentDocument.document.XMLDocument?io.contentDocument.document.XMLDocum
> ent:io.contentDocument.document;
> }
> }catch(e)
> {
> jQuery.handleError(s, xml, null, e);
> }
> if ( xml || isTimeout == "timeout")
> {
> requestDone = true;
> var status;
> try {
> status = isTimeout != "timeout" ? "success" : "error";
> // Make sure that the request was successful or
> notmodified
> if ( status != "error" )
> {
> // process the data (runs the xml through httpData
> regardless of callback)
> var data = jQuery.uploadHttpData( xml, s.dataType
);
>
> // If a local callback was specified, fire it and
> pass it the data
> if ( s.success )
> s.success( data, status );
>
> // Fire the global callback
> if( s.global )
> jQuery.event.trigger( "ajaxSuccess", [xml, s]
);
> } else
> jQuery.handleError(s, xml, status);
> } catch(e)
> {
> status = "error";
> jQuery.handleError(s, xml, status, e);
> }
>
> // The request was completed
> if( s.global )
> jQuery.event.trigger( "ajaxComplete", [xml, s] );
>
> // Handle the global AJAX counter
> if ( s.global && ! --jQuery.active )
> jQuery.event.trigger( "ajaxStop" );
>
> // Process result
> if ( s.complete )
> s.complete(xml, status);
>
> jQuery(io).unbind()
>
> setTimeout(function()
> { try
> {
> $(io).remove();
> $(form).remove();
>
> } catch(e)
> {
> jQuery.handleError(s, xml,
null,
> e);
> }
>
>
> }, 100)
>
> xml = null
>
> }
> }
> // Timeout checker
> if ( s.timeout > 0 )
> {
> setTimeout(function(){
> // Check to see if the request is still happening
> if( !requestDone ) uploadCallback( "timeout" );
> }, s.timeout);
> }
> try
> {
> // var io = $('#' + frameId);
> var form = $('#' + formId);
> $(form).attr('action', s.url);
> $(form).attr('method', 'POST');
> $(form).attr('target', frameId);
> if(form.encoding)
> {
> form.encoding = 'multipart/form-data';
> }
> else
> {
> form.enctype = 'multipart/form-data';
> }
> $(form).submit();
>
> } catch(e)
> {
> jQuery.handleError(s, xml, null, e);
> }
> if(window.attachEvent){
> document.getElementById(frameId).attachEvent('onload',
> uploadCallback);
> }
> else{
> document.getElementById(frameId).addEventListener('load',
> uploadCallback, false);
> }
> return {abort: function () {}};
>
> },
>
> uploadHttpData: function( r, type ) {
> var data = !type;
> data = type == "xml" || data ? r.responseXML : r.responseText;
> // If the type is "script", eval it in global context
> if ( type == "script" )
> jQuery.globalEval( data );
> // Get the JavaScript object, if JSON is used.
> if ( type == "json" )
> eval( "data = " + data );
> // evaluate scripts within html
> if ( type == "html" )
> jQuery("<div>").html(data).evalScripts();
> //alert($('param',
> data).each(function(){alert($(this).attr('value'));}));
> return data;
> }
> })
>
> But during my tesing, the code appears to run ok only in IE (IE 7). It
> failed on Firefox (3.0.10), Safari (3.2.1) and Chrome (1.0.154.65), with
> simply no request received from the server after “jQuery(form).submit();”
> and no exception thrown or captured either. I reported the problem back
but
> so far no reply (I am not a Javascript expert).
>
> Hope your ajax file upload approach will also handle UTF8 encoded caption
–
> I certainly would do some testing when your code is ready
> The other issue in my mind about file upload is if “multi-file upload in
one
> submit” could be achieved. I saw it in Flash version where user selects
> multiple files using Window’s file selection while keeping control key
down.
> I suppose this ability would bring Struts’ file upload to the next level.
>
> Kind regards,
>
> Qunhuan
>
> -----Original Message-----
> From: Wes Wannemacher [mailto:wesw@wantii.com]
> Sent: 03 June 2009 22:03
> To: Struts Users Mailing List
> Subject: Re: About the "struts.multipart.saveDir" for file upload
>
>
> I'll check it out, I just wanted to improve what we had because it's
> currently impossible to do things like an AJAX upload with accurate
> progress bar. After I get the plugin (1.0-SNAPSHOT, which is the maven
> way of saying beta) committed to the sandbox, I'll whip up a quick
> example of how to do an AJAX w/progress bar using struts.
>
> -Wes
>
> On Wed, Jun 3, 2009 at 5:00 PM, Andy <an...@hotmail.com> wrote:
>>
>> That's great Wes. I am using the file upload but only sparingly (and
> hacked) due to some existing glitches.
>>
>>
>>
>> I read how the Stripes framework does file upload:
> http://www.stripesframework.org/display/stripes/File+Uploads
>>
>>
>>
>> Thought you might find it interesting/useful..
>>
>>
>>
>> Andy
>>
>>
>>
>>> Date: Wed, 3 Jun 2009 16:48:56 -0400
>>> Subject: Re: About the "struts.multipart.saveDir" for file upload
>>> From: wesw@wantii.com
>>> To: user@struts.apache.org
>>>
>>> I don't know if I would suggest it, but you might be able to call -
>>>
>>> Dispatcher.getInstance().setMultipartSaveDir(String path)
>>>
>>> Now, I can't remember if there is one dispatcher per thread, so you
>>> might have to call it in an interceptor.
>>>
>>> However, I would strongly suggest against doing that.
>>>
>>> I am working on an enhanced file upload plugin right now and will
>>> probably commit it to the sandbox by tomorrow. The problem with the
>>> stock file upload capability is that the FileItemFactory and
>>> FileUpload objects are not available to be overridden, and hardly any
>>> configuration is made visible. So, I've got a new
>>> JakartaMultiPartRequest class I'll have out by tomorrow.
>>>
>>> -Wes
>>>
>>> On Wed, Jun 3, 2009 at 4:37 PM, Andy <an...@hotmail.com> wrote:
>>> >
>>> > It defaults but I think he's wondering how he can set the dir
> programatically.
>>> >
>>> >
>>> >
>>> >> Date: Wed, 3 Jun 2009 15:35:33 -0500
>>> >> Subject: Re: About the "struts.multipart.saveDir" for file upload
>>> >> From: burtonrhodes@gmail.com
>>> >> To: user@struts.apache.org
>>> >>
>>> >> I wasn't aware that it was required. If you don't specify doesn't it
>>> >> default to the 'work' directory?
>>> >>
>>> >> On 6/3/09, Qunhuan Mei <qm...@qm18.wanadoo.co.uk> wrote:
>>> >> >
>>> >> > Hi,
>>> >> >
>>> >> > When implementing file upload, it is required to specify an
absolute
>>> >> > directory in struts.xml such as following:
>>> >> >
>>> >> > <constant name="struts.multipart.saveDir"
> value="C:/fileUploadTempDir"
>>> >> > />
>>> >> >
>>> >> > But this might be difficult to achieve, say when the project war is
> deployed
>>> >> > in a external shared server and we do not have much idea about the
> directory
>>> >> > structure of the target server machine.
>>> >> >
>>> >> > I was wondering if there is any recommended way to handle this
> issue.
>>> >> >
>>> >> > Ideally I would like to specify the directory in java code where I
> can
>>> >> > detect the current working directory and specify the saveDir
> accordingly. Is
>>> >> > this possible?
>>> >> >
>>> >> > Many thanks in advance,
>>> >> >
>>> >> > Qunhuan
>>> >> >
>>> >> >
>>> >> >
>>> >> >
>>> >> >
> ---------------------------------------------------------------------
>>> >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> >> > For additional commands, e-mail: user-help@struts.apache.org
>>> >> >
>>> >> >
>>> >>
>>> >> --
>>> >> Sent from my mobile device
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> >> For additional commands, e-mail: user-help@struts.apache.org
>>> >>
>>> >
>>> > _________________________________________________________________
>>> > Windows Live™: Keep your life in sync.
>>> >
> http://windowslive.com/explore?ocid=TXT_TAGLM_WL_BR_life_in_synch_062009
>>>
>>>
>>>
>>> --
>>> Wes Wannemacher
>>> Author - Struts 2 In Practice
>>> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
>>> http://www.manning.com/wannemacher
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>
>> _________________________________________________________________
>> Insert movie times and more without leaving Hotmail®.
>>
>
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutori
> al_QuickAdd_062009
>
>
>
> --
> Wes Wannemacher
> Author - Struts 2 In Practice
> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> http://www.manning.com/wannemacher
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Ajax file upload + RE: About the "struts.multipart.saveDir" for
file upload
Posted by Wes Wannemacher <we...@wantii.com>.
Really, I haven't gotten that far yet, I am only working to improve
the integration with Jakarta FileUpload. JFU is quite capable and
mature, but I figured the first step would be to expose more
functionality since there were a few JIRAs related to people asking
for more than what is currently offered.
I committed a partially complete plugin to the sandbox yesterday
before I left my office, but I still need to glue it together with
configuration, etc. (and work out a bug I realized I had in the middle
of the night last night). Once I get the plugin to an installable
state, you can check it out. I figure the first step is to make the
plugin work, then the next step is building an example UI. I am not
sure how I am going to build the example UI, but JQuery is probably
the most likely candidate for me.
As far as selecting multiple files with Ctrl-Click, I'm not sure if
that is possible... Not from a struts/jquery perspective, but I don't
know if the browser will let you do that. I think Flash may be the
only option (or a java applet or something, but flash is more likely),
so we can come back to that later.
-Wes
On Thu, Jun 4, 2009 at 4:07 AM, Qunhuan Mei <qm...@qm18.wanadoo.co.uk> wrote:
> Hi Wes,
>
> Struts’ ajax file upload would be very interesting to me since I have
> implemented jQuery (http://www.phpletter.com/Our-Projects/AjaxFileUpload/)
> and Struts for ajax file upload in my application and had one or two
> problem(s).
>
> FYI: My use case is to upload a file, together with utf8 encoded caption.
> The problem I had is utf8 encoded caption needs to be sent via HTTP POST, it
> won’t work with HTTP get. But the jQuery arrangement is sending file in POST
> while sending caption in Get. So what I did is to send caption and file in
> two POSTs which cause other complications. Later the author (Øyvind Saltvik
> oyvind.saltvik@gmail.com) sent me the following code contributed by
> (Prokofiev Nikolay nprokofiev@gmail.com) which added the parameter POSTing
> (e.g. caption) to jQuery’s file upload.
>
> $.ajaxFileUpload
> (
> {
> url:document.location+'&ajax=true',
> secureuri:false,
> fileElementId:'fileToUpload',
> data: {foo: 'ghffgh', bar: 'fghfhgg'},
> dataType: 'json',
> success: function (data, status)
> {
> if(typeof(data.error) != 'undefined')
> {
> if(data.error != '')
> {
> alert(data.error);
> }else
> {
> alert(data.msg);
> }
> }
> },
> error: function (data, status, e)
> {
> alert(e);
> }
> }
> )
>
> here is the script:
> jQuery.extend({
> createUploadIframe: function(id, uri)
> {
> //create frame
> var frameId = 'jUploadFrame' + id;
>
> if(window.ActiveXObject) {
> var io = document.createElement('<iframe id="' + frameId +
> '" name="' + frameId + '" />');
> if(typeof uri== 'boolean'){
> io.src = 'javascript:false';
> }
> else if(typeof uri== 'string'){
> io.src = uri;
> }
> }
> else {
> var io = document.createElement('iframe');
> io.id = frameId;
> io.name = frameId;
> }
> io.style.position = 'absolute';
> io.style.top = '-1000px';
> io.style.left = '-1000px';
>
> document.body.appendChild(io);
>
> return io
> },
> createUploadForm: function(id, fileElementId, postData)
> {
> //create form
> var formId = 'jUploadForm' + id;
> var fileId = 'jUploadFile' + id;
> var form = $('<form action="" method="POST" name="' + formId + '"
> id="' + formId + '" enctype="multipart/form-data"></form>');
> var oldElement = $('#' + fileElementId);
> var newElement = $(oldElement).clone();
> $(oldElement).attr('id', fileId);
> $(oldElement).before(newElement);
> $(oldElement).appendTo(form);
> try
> {
> for(param in postData)
> {
> var input = document.createElement('input');
> input.setAttribute('name', param);
> input.setAttribute('value', postData[param]);
> $(input).appendTo(form);
> }
> }
> catch(e) {}
> //set attributes
> $(form).css('position', 'absolute');
> $(form).css('top', '-1200px');
> $(form).css('left', '-1200px');
> $(form).appendTo('body');
> return form;
> },
> ajaxFileUpload: function(s) {
> // TODO introduce global settings, allowing the client to modify
> them for all requests, not only timeout
> s = jQuery.extend({}, jQuery.ajaxSettings, s);
> var id = new Date().getTime()
> var form = jQuery.createUploadForm(id, s.fileElementId, s.data);
> var io = jQuery.createUploadIframe(id, s.secureuri);
> var frameId = 'jUploadFrame' + id;
> var formId = 'jUploadForm' + id;
> // Watch for a new set of requests
> if ( s.global && ! jQuery.active++ )
> {
> jQuery.event.trigger( "ajaxStart" );
> }
> var requestDone = false;
> // Create the request object
> var xml = {}
> if ( s.global )
> jQuery.event.trigger("ajaxSend", [xml, s]);
> // Wait for a response to come back
> var uploadCallback = function(isTimeout)
> {
> var io = document.getElementById(frameId);
> try
> {
> if(io.contentWindow)
> {
> xml.responseText =
> io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null
> ;
> xml.responseXML =
> io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:
> io.contentWindow.document;
>
> }else if(io.contentDocument)
> {
> xml.responseText =
> io.contentDocument.document.body?io.contentDocument.document.body.innerHTML:
> null;
> xml.responseXML =
> io.contentDocument.document.XMLDocument?io.contentDocument.document.XMLDocum
> ent:io.contentDocument.document;
> }
> }catch(e)
> {
> jQuery.handleError(s, xml, null, e);
> }
> if ( xml || isTimeout == "timeout")
> {
> requestDone = true;
> var status;
> try {
> status = isTimeout != "timeout" ? "success" : "error";
> // Make sure that the request was successful or
> notmodified
> if ( status != "error" )
> {
> // process the data (runs the xml through httpData
> regardless of callback)
> var data = jQuery.uploadHttpData( xml, s.dataType );
>
> // If a local callback was specified, fire it and
> pass it the data
> if ( s.success )
> s.success( data, status );
>
> // Fire the global callback
> if( s.global )
> jQuery.event.trigger( "ajaxSuccess", [xml, s] );
> } else
> jQuery.handleError(s, xml, status);
> } catch(e)
> {
> status = "error";
> jQuery.handleError(s, xml, status, e);
> }
>
> // The request was completed
> if( s.global )
> jQuery.event.trigger( "ajaxComplete", [xml, s] );
>
> // Handle the global AJAX counter
> if ( s.global && ! --jQuery.active )
> jQuery.event.trigger( "ajaxStop" );
>
> // Process result
> if ( s.complete )
> s.complete(xml, status);
>
> jQuery(io).unbind()
>
> setTimeout(function()
> { try
> {
> $(io).remove();
> $(form).remove();
>
> } catch(e)
> {
> jQuery.handleError(s, xml, null,
> e);
> }
>
>
> }, 100)
>
> xml = null
>
> }
> }
> // Timeout checker
> if ( s.timeout > 0 )
> {
> setTimeout(function(){
> // Check to see if the request is still happening
> if( !requestDone ) uploadCallback( "timeout" );
> }, s.timeout);
> }
> try
> {
> // var io = $('#' + frameId);
> var form = $('#' + formId);
> $(form).attr('action', s.url);
> $(form).attr('method', 'POST');
> $(form).attr('target', frameId);
> if(form.encoding)
> {
> form.encoding = 'multipart/form-data';
> }
> else
> {
> form.enctype = 'multipart/form-data';
> }
> $(form).submit();
>
> } catch(e)
> {
> jQuery.handleError(s, xml, null, e);
> }
> if(window.attachEvent){
> document.getElementById(frameId).attachEvent('onload',
> uploadCallback);
> }
> else{
> document.getElementById(frameId).addEventListener('load',
> uploadCallback, false);
> }
> return {abort: function () {}};
>
> },
>
> uploadHttpData: function( r, type ) {
> var data = !type;
> data = type == "xml" || data ? r.responseXML : r.responseText;
> // If the type is "script", eval it in global context
> if ( type == "script" )
> jQuery.globalEval( data );
> // Get the JavaScript object, if JSON is used.
> if ( type == "json" )
> eval( "data = " + data );
> // evaluate scripts within html
> if ( type == "html" )
> jQuery("<div>").html(data).evalScripts();
> //alert($('param',
> data).each(function(){alert($(this).attr('value'));}));
> return data;
> }
> })
>
> But during my tesing, the code appears to run ok only in IE (IE 7). It
> failed on Firefox (3.0.10), Safari (3.2.1) and Chrome (1.0.154.65), with
> simply no request received from the server after “jQuery(form).submit();”
> and no exception thrown or captured either. I reported the problem back but
> so far no reply (I am not a Javascript expert).
>
> Hope your ajax file upload approach will also handle UTF8 encoded caption –
> I certainly would do some testing when your code is ready
> The other issue in my mind about file upload is if “multi-file upload in one
> submit” could be achieved. I saw it in Flash version where user selects
> multiple files using Window’s file selection while keeping control key down.
> I suppose this ability would bring Struts’ file upload to the next level.
>
> Kind regards,
>
> Qunhuan
>
> -----Original Message-----
> From: Wes Wannemacher [mailto:wesw@wantii.com]
> Sent: 03 June 2009 22:03
> To: Struts Users Mailing List
> Subject: Re: About the "struts.multipart.saveDir" for file upload
>
>
> I'll check it out, I just wanted to improve what we had because it's
> currently impossible to do things like an AJAX upload with accurate
> progress bar. After I get the plugin (1.0-SNAPSHOT, which is the maven
> way of saying beta) committed to the sandbox, I'll whip up a quick
> example of how to do an AJAX w/progress bar using struts.
>
> -Wes
>
> On Wed, Jun 3, 2009 at 5:00 PM, Andy <an...@hotmail.com> wrote:
>>
>> That's great Wes. I am using the file upload but only sparingly (and
> hacked) due to some existing glitches.
>>
>>
>>
>> I read how the Stripes framework does file upload:
> http://www.stripesframework.org/display/stripes/File+Uploads
>>
>>
>>
>> Thought you might find it interesting/useful..
>>
>>
>>
>> Andy
>>
>>
>>
>>> Date: Wed, 3 Jun 2009 16:48:56 -0400
>>> Subject: Re: About the "struts.multipart.saveDir" for file upload
>>> From: wesw@wantii.com
>>> To: user@struts.apache.org
>>>
>>> I don't know if I would suggest it, but you might be able to call -
>>>
>>> Dispatcher.getInstance().setMultipartSaveDir(String path)
>>>
>>> Now, I can't remember if there is one dispatcher per thread, so you
>>> might have to call it in an interceptor.
>>>
>>> However, I would strongly suggest against doing that.
>>>
>>> I am working on an enhanced file upload plugin right now and will
>>> probably commit it to the sandbox by tomorrow. The problem with the
>>> stock file upload capability is that the FileItemFactory and
>>> FileUpload objects are not available to be overridden, and hardly any
>>> configuration is made visible. So, I've got a new
>>> JakartaMultiPartRequest class I'll have out by tomorrow.
>>>
>>> -Wes
>>>
>>> On Wed, Jun 3, 2009 at 4:37 PM, Andy <an...@hotmail.com> wrote:
>>> >
>>> > It defaults but I think he's wondering how he can set the dir
> programatically.
>>> >
>>> >
>>> >
>>> >> Date: Wed, 3 Jun 2009 15:35:33 -0500
>>> >> Subject: Re: About the "struts.multipart.saveDir" for file upload
>>> >> From: burtonrhodes@gmail.com
>>> >> To: user@struts.apache.org
>>> >>
>>> >> I wasn't aware that it was required. If you don't specify doesn't it
>>> >> default to the 'work' directory?
>>> >>
>>> >> On 6/3/09, Qunhuan Mei <qm...@qm18.wanadoo.co.uk> wrote:
>>> >> >
>>> >> > Hi,
>>> >> >
>>> >> > When implementing file upload, it is required to specify an absolute
>>> >> > directory in struts.xml such as following:
>>> >> >
>>> >> > <constant name="struts.multipart.saveDir"
> value="C:/fileUploadTempDir"
>>> >> > />
>>> >> >
>>> >> > But this might be difficult to achieve, say when the project war is
> deployed
>>> >> > in a external shared server and we do not have much idea about the
> directory
>>> >> > structure of the target server machine.
>>> >> >
>>> >> > I was wondering if there is any recommended way to handle this
> issue.
>>> >> >
>>> >> > Ideally I would like to specify the directory in java code where I
> can
>>> >> > detect the current working directory and specify the saveDir
> accordingly. Is
>>> >> > this possible?
>>> >> >
>>> >> > Many thanks in advance,
>>> >> >
>>> >> > Qunhuan
>>> >> >
>>> >> >
>>> >> >
>>> >> >
>>> >> >
> ---------------------------------------------------------------------
>>> >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> >> > For additional commands, e-mail: user-help@struts.apache.org
>>> >> >
>>> >> >
>>> >>
>>> >> --
>>> >> Sent from my mobile device
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> >> For additional commands, e-mail: user-help@struts.apache.org
>>> >>
>>> >
>>> > _________________________________________________________________
>>> > Windows Live™: Keep your life in sync.
>>> >
> http://windowslive.com/explore?ocid=TXT_TAGLM_WL_BR_life_in_synch_062009
>>>
>>>
>>>
>>> --
>>> Wes Wannemacher
>>> Author - Struts 2 In Practice
>>> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
>>> http://www.manning.com/wannemacher
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>
>> _________________________________________________________________
>> Insert movie times and more without leaving Hotmail®.
>>
> http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutori
> al_QuickAdd_062009
>
>
>
> --
> Wes Wannemacher
> Author - Struts 2 In Practice
> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> http://www.manning.com/wannemacher
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Ajax file upload + RE: About the "struts.multipart.saveDir" for file upload
Posted by Qunhuan Mei <qm...@qm18.wanadoo.co.uk>.
Hi Wes,
Struts’ ajax file upload would be very interesting to me since I have
implemented jQuery (http://www.phpletter.com/Our-Projects/AjaxFileUpload/)
and Struts for ajax file upload in my application and had one or two
problem(s).
FYI: My use case is to upload a file, together with utf8 encoded caption.
The problem I had is utf8 encoded caption needs to be sent via HTTP POST, it
won’t work with HTTP get. But the jQuery arrangement is sending file in POST
while sending caption in Get. So what I did is to send caption and file in
two POSTs which cause other complications. Later the author (Øyvind Saltvik
oyvind.saltvik@gmail.com) sent me the following code contributed by
(Prokofiev Nikolay nprokofiev@gmail.com) which added the parameter POSTing
(e.g. caption) to jQuery’s file upload.
$.ajaxFileUpload
(
{
url:document.location+'&ajax=true',
secureuri:false,
fileElementId:'fileToUpload',
data: {foo: 'ghffgh', bar: 'fghfhgg'},
dataType: 'json',
success: function (data, status)
{
if(typeof(data.error) != 'undefined')
{
if(data.error != '')
{
alert(data.error);
}else
{
alert(data.msg);
}
}
},
error: function (data, status, e)
{
alert(e);
}
}
)
here is the script:
jQuery.extend({
createUploadIframe: function(id, uri)
{
//create frame
var frameId = 'jUploadFrame' + id;
if(window.ActiveXObject) {
var io = document.createElement('<iframe id="' + frameId +
'" name="' + frameId + '" />');
if(typeof uri== 'boolean'){
io.src = 'javascript:false';
}
else if(typeof uri== 'string'){
io.src = uri;
}
}
else {
var io = document.createElement('iframe');
io.id = frameId;
io.name = frameId;
}
io.style.position = 'absolute';
io.style.top = '-1000px';
io.style.left = '-1000px';
document.body.appendChild(io);
return io
},
createUploadForm: function(id, fileElementId, postData)
{
//create form
var formId = 'jUploadForm' + id;
var fileId = 'jUploadFile' + id;
var form = $('<form action="" method="POST" name="' + formId + '"
id="' + formId + '" enctype="multipart/form-data"></form>');
var oldElement = $('#' + fileElementId);
var newElement = $(oldElement).clone();
$(oldElement).attr('id', fileId);
$(oldElement).before(newElement);
$(oldElement).appendTo(form);
try
{
for(param in postData)
{
var input = document.createElement('input');
input.setAttribute('name', param);
input.setAttribute('value', postData[param]);
$(input).appendTo(form);
}
}
catch(e) {}
//set attributes
$(form).css('position', 'absolute');
$(form).css('top', '-1200px');
$(form).css('left', '-1200px');
$(form).appendTo('body');
return form;
},
ajaxFileUpload: function(s) {
// TODO introduce global settings, allowing the client to modify
them for all requests, not only timeout
s = jQuery.extend({}, jQuery.ajaxSettings, s);
var id = new Date().getTime()
var form = jQuery.createUploadForm(id, s.fileElementId, s.data);
var io = jQuery.createUploadIframe(id, s.secureuri);
var frameId = 'jUploadFrame' + id;
var formId = 'jUploadForm' + id;
// Watch for a new set of requests
if ( s.global && ! jQuery.active++ )
{
jQuery.event.trigger( "ajaxStart" );
}
var requestDone = false;
// Create the request object
var xml = {}
if ( s.global )
jQuery.event.trigger("ajaxSend", [xml, s]);
// Wait for a response to come back
var uploadCallback = function(isTimeout)
{
var io = document.getElementById(frameId);
try
{
if(io.contentWindow)
{
xml.responseText =
io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null
;
xml.responseXML =
io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:
io.contentWindow.document;
}else if(io.contentDocument)
{
xml.responseText =
io.contentDocument.document.body?io.contentDocument.document.body.innerHTML:
null;
xml.responseXML =
io.contentDocument.document.XMLDocument?io.contentDocument.document.XMLDocum
ent:io.contentDocument.document;
}
}catch(e)
{
jQuery.handleError(s, xml, null, e);
}
if ( xml || isTimeout == "timeout")
{
requestDone = true;
var status;
try {
status = isTimeout != "timeout" ? "success" : "error";
// Make sure that the request was successful or
notmodified
if ( status != "error" )
{
// process the data (runs the xml through httpData
regardless of callback)
var data = jQuery.uploadHttpData( xml, s.dataType );
// If a local callback was specified, fire it and
pass it the data
if ( s.success )
s.success( data, status );
// Fire the global callback
if( s.global )
jQuery.event.trigger( "ajaxSuccess", [xml, s] );
} else
jQuery.handleError(s, xml, status);
} catch(e)
{
status = "error";
jQuery.handleError(s, xml, status, e);
}
// The request was completed
if( s.global )
jQuery.event.trigger( "ajaxComplete", [xml, s] );
// Handle the global AJAX counter
if ( s.global && ! --jQuery.active )
jQuery.event.trigger( "ajaxStop" );
// Process result
if ( s.complete )
s.complete(xml, status);
jQuery(io).unbind()
setTimeout(function()
{ try
{
$(io).remove();
$(form).remove();
} catch(e)
{
jQuery.handleError(s, xml, null,
e);
}
}, 100)
xml = null
}
}
// Timeout checker
if ( s.timeout > 0 )
{
setTimeout(function(){
// Check to see if the request is still happening
if( !requestDone ) uploadCallback( "timeout" );
}, s.timeout);
}
try
{
// var io = $('#' + frameId);
var form = $('#' + formId);
$(form).attr('action', s.url);
$(form).attr('method', 'POST');
$(form).attr('target', frameId);
if(form.encoding)
{
form.encoding = 'multipart/form-data';
}
else
{
form.enctype = 'multipart/form-data';
}
$(form).submit();
} catch(e)
{
jQuery.handleError(s, xml, null, e);
}
if(window.attachEvent){
document.getElementById(frameId).attachEvent('onload',
uploadCallback);
}
else{
document.getElementById(frameId).addEventListener('load',
uploadCallback, false);
}
return {abort: function () {}};
},
uploadHttpData: function( r, type ) {
var data = !type;
data = type == "xml" || data ? r.responseXML : r.responseText;
// If the type is "script", eval it in global context
if ( type == "script" )
jQuery.globalEval( data );
// Get the JavaScript object, if JSON is used.
if ( type == "json" )
eval( "data = " + data );
// evaluate scripts within html
if ( type == "html" )
jQuery("<div>").html(data).evalScripts();
//alert($('param',
data).each(function(){alert($(this).attr('value'));}));
return data;
}
})
But during my tesing, the code appears to run ok only in IE (IE 7). It
failed on Firefox (3.0.10), Safari (3.2.1) and Chrome (1.0.154.65), with
simply no request received from the server after “jQuery(form).submit();”
and no exception thrown or captured either. I reported the problem back but
so far no reply (I am not a Javascript expert).
Hope your ajax file upload approach will also handle UTF8 encoded caption –
I certainly would do some testing when your code is ready
The other issue in my mind about file upload is if “multi-file upload in one
submit” could be achieved. I saw it in Flash version where user selects
multiple files using Window’s file selection while keeping control key down.
I suppose this ability would bring Struts’ file upload to the next level.
Kind regards,
Qunhuan
-----Original Message-----
From: Wes Wannemacher [mailto:wesw@wantii.com]
Sent: 03 June 2009 22:03
To: Struts Users Mailing List
Subject: Re: About the "struts.multipart.saveDir" for file upload
I'll check it out, I just wanted to improve what we had because it's
currently impossible to do things like an AJAX upload with accurate
progress bar. After I get the plugin (1.0-SNAPSHOT, which is the maven
way of saying beta) committed to the sandbox, I'll whip up a quick
example of how to do an AJAX w/progress bar using struts.
-Wes
On Wed, Jun 3, 2009 at 5:00 PM, Andy <an...@hotmail.com> wrote:
>
> That's great Wes. I am using the file upload but only sparingly (and
hacked) due to some existing glitches.
>
>
>
> I read how the Stripes framework does file upload:
http://www.stripesframework.org/display/stripes/File+Uploads
>
>
>
> Thought you might find it interesting/useful..
>
>
>
> Andy
>
>
>
>> Date: Wed, 3 Jun 2009 16:48:56 -0400
>> Subject: Re: About the "struts.multipart.saveDir" for file upload
>> From: wesw@wantii.com
>> To: user@struts.apache.org
>>
>> I don't know if I would suggest it, but you might be able to call -
>>
>> Dispatcher.getInstance().setMultipartSaveDir(String path)
>>
>> Now, I can't remember if there is one dispatcher per thread, so you
>> might have to call it in an interceptor.
>>
>> However, I would strongly suggest against doing that.
>>
>> I am working on an enhanced file upload plugin right now and will
>> probably commit it to the sandbox by tomorrow. The problem with the
>> stock file upload capability is that the FileItemFactory and
>> FileUpload objects are not available to be overridden, and hardly any
>> configuration is made visible. So, I've got a new
>> JakartaMultiPartRequest class I'll have out by tomorrow.
>>
>> -Wes
>>
>> On Wed, Jun 3, 2009 at 4:37 PM, Andy <an...@hotmail.com> wrote:
>> >
>> > It defaults but I think he's wondering how he can set the dir
programatically.
>> >
>> >
>> >
>> >> Date: Wed, 3 Jun 2009 15:35:33 -0500
>> >> Subject: Re: About the "struts.multipart.saveDir" for file upload
>> >> From: burtonrhodes@gmail.com
>> >> To: user@struts.apache.org
>> >>
>> >> I wasn't aware that it was required. If you don't specify doesn't it
>> >> default to the 'work' directory?
>> >>
>> >> On 6/3/09, Qunhuan Mei <qm...@qm18.wanadoo.co.uk> wrote:
>> >> >
>> >> > Hi,
>> >> >
>> >> > When implementing file upload, it is required to specify an absolute
>> >> > directory in struts.xml such as following:
>> >> >
>> >> > <constant name="struts.multipart.saveDir"
value="C:/fileUploadTempDir"
>> >> > />
>> >> >
>> >> > But this might be difficult to achieve, say when the project war is
deployed
>> >> > in a external shared server and we do not have much idea about the
directory
>> >> > structure of the target server machine.
>> >> >
>> >> > I was wondering if there is any recommended way to handle this
issue.
>> >> >
>> >> > Ideally I would like to specify the directory in java code where I
can
>> >> > detect the current working directory and specify the saveDir
accordingly. Is
>> >> > this possible?
>> >> >
>> >> > Many thanks in advance,
>> >> >
>> >> > Qunhuan
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> > For additional commands, e-mail: user-help@struts.apache.org
>> >> >
>> >> >
>> >>
>> >> --
>> >> Sent from my mobile device
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> For additional commands, e-mail: user-help@struts.apache.org
>> >>
>> >
>> > _________________________________________________________________
>> > Windows Live™: Keep your life in sync.
>> >
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_BR_life_in_synch_062009
>>
>>
>>
>> --
>> Wes Wannemacher
>> Author - Struts 2 In Practice
>> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
>> http://www.manning.com/wannemacher
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>
> _________________________________________________________________
> Insert movie times and more without leaving Hotmail®.
>
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutori
al_QuickAdd_062009
--
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: About the "struts.multipart.saveDir" for file upload
Posted by Wes Wannemacher <we...@wantii.com>.
I'll check it out, I just wanted to improve what we had because it's
currently impossible to do things like an AJAX upload with accurate
progress bar. After I get the plugin (1.0-SNAPSHOT, which is the maven
way of saying beta) committed to the sandbox, I'll whip up a quick
example of how to do an AJAX w/progress bar using struts.
-Wes
On Wed, Jun 3, 2009 at 5:00 PM, Andy <an...@hotmail.com> wrote:
>
> That's great Wes. I am using the file upload but only sparingly (and hacked) due to some existing glitches.
>
>
>
> I read how the Stripes framework does file upload: http://www.stripesframework.org/display/stripes/File+Uploads
>
>
>
> Thought you might find it interesting/useful..
>
>
>
> Andy
>
>
>
>> Date: Wed, 3 Jun 2009 16:48:56 -0400
>> Subject: Re: About the "struts.multipart.saveDir" for file upload
>> From: wesw@wantii.com
>> To: user@struts.apache.org
>>
>> I don't know if I would suggest it, but you might be able to call -
>>
>> Dispatcher.getInstance().setMultipartSaveDir(String path)
>>
>> Now, I can't remember if there is one dispatcher per thread, so you
>> might have to call it in an interceptor.
>>
>> However, I would strongly suggest against doing that.
>>
>> I am working on an enhanced file upload plugin right now and will
>> probably commit it to the sandbox by tomorrow. The problem with the
>> stock file upload capability is that the FileItemFactory and
>> FileUpload objects are not available to be overridden, and hardly any
>> configuration is made visible. So, I've got a new
>> JakartaMultiPartRequest class I'll have out by tomorrow.
>>
>> -Wes
>>
>> On Wed, Jun 3, 2009 at 4:37 PM, Andy <an...@hotmail.com> wrote:
>> >
>> > It defaults but I think he's wondering how he can set the dir programatically.
>> >
>> >
>> >
>> >> Date: Wed, 3 Jun 2009 15:35:33 -0500
>> >> Subject: Re: About the "struts.multipart.saveDir" for file upload
>> >> From: burtonrhodes@gmail.com
>> >> To: user@struts.apache.org
>> >>
>> >> I wasn't aware that it was required. If you don't specify doesn't it
>> >> default to the 'work' directory?
>> >>
>> >> On 6/3/09, Qunhuan Mei <qm...@qm18.wanadoo.co.uk> wrote:
>> >> >
>> >> > Hi,
>> >> >
>> >> > When implementing file upload, it is required to specify an absolute
>> >> > directory in struts.xml such as following:
>> >> >
>> >> > <constant name="struts.multipart.saveDir" value="C:/fileUploadTempDir"
>> >> > />
>> >> >
>> >> > But this might be difficult to achieve, say when the project war is deployed
>> >> > in a external shared server and we do not have much idea about the directory
>> >> > structure of the target server machine.
>> >> >
>> >> > I was wondering if there is any recommended way to handle this issue.
>> >> >
>> >> > Ideally I would like to specify the directory in java code where I can
>> >> > detect the current working directory and specify the saveDir accordingly. Is
>> >> > this possible?
>> >> >
>> >> > Many thanks in advance,
>> >> >
>> >> > Qunhuan
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> > For additional commands, e-mail: user-help@struts.apache.org
>> >> >
>> >> >
>> >>
>> >> --
>> >> Sent from my mobile device
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> For additional commands, e-mail: user-help@struts.apache.org
>> >>
>> >
>> > _________________________________________________________________
>> > Windows Live™: Keep your life in sync.
>> > http://windowslive.com/explore?ocid=TXT_TAGLM_WL_BR_life_in_synch_062009
>>
>>
>>
>> --
>> Wes Wannemacher
>> Author - Struts 2 In Practice
>> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
>> http://www.manning.com/wannemacher
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>
> _________________________________________________________________
> Insert movie times and more without leaving Hotmail®.
> http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd_062009
--
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: About the "struts.multipart.saveDir" for file upload
Posted by Andy <an...@hotmail.com>.
That's great Wes. I am using the file upload but only sparingly (and hacked) due to some existing glitches.
I read how the Stripes framework does file upload: http://www.stripesframework.org/display/stripes/File+Uploads
Thought you might find it interesting/useful..
Andy
> Date: Wed, 3 Jun 2009 16:48:56 -0400
> Subject: Re: About the "struts.multipart.saveDir" for file upload
> From: wesw@wantii.com
> To: user@struts.apache.org
>
> I don't know if I would suggest it, but you might be able to call -
>
> Dispatcher.getInstance().setMultipartSaveDir(String path)
>
> Now, I can't remember if there is one dispatcher per thread, so you
> might have to call it in an interceptor.
>
> However, I would strongly suggest against doing that.
>
> I am working on an enhanced file upload plugin right now and will
> probably commit it to the sandbox by tomorrow. The problem with the
> stock file upload capability is that the FileItemFactory and
> FileUpload objects are not available to be overridden, and hardly any
> configuration is made visible. So, I've got a new
> JakartaMultiPartRequest class I'll have out by tomorrow.
>
> -Wes
>
> On Wed, Jun 3, 2009 at 4:37 PM, Andy <an...@hotmail.com> wrote:
> >
> > It defaults but I think he's wondering how he can set the dir programatically.
> >
> >
> >
> >> Date: Wed, 3 Jun 2009 15:35:33 -0500
> >> Subject: Re: About the "struts.multipart.saveDir" for file upload
> >> From: burtonrhodes@gmail.com
> >> To: user@struts.apache.org
> >>
> >> I wasn't aware that it was required. If you don't specify doesn't it
> >> default to the 'work' directory?
> >>
> >> On 6/3/09, Qunhuan Mei <qm...@qm18.wanadoo.co.uk> wrote:
> >> >
> >> > Hi,
> >> >
> >> > When implementing file upload, it is required to specify an absolute
> >> > directory in struts.xml such as following:
> >> >
> >> > <constant name="struts.multipart.saveDir" value="C:/fileUploadTempDir"
> >> > />
> >> >
> >> > But this might be difficult to achieve, say when the project war is deployed
> >> > in a external shared server and we do not have much idea about the directory
> >> > structure of the target server machine.
> >> >
> >> > I was wondering if there is any recommended way to handle this issue.
> >> >
> >> > Ideally I would like to specify the directory in java code where I can
> >> > detect the current working directory and specify the saveDir accordingly. Is
> >> > this possible?
> >> >
> >> > Many thanks in advance,
> >> >
> >> > Qunhuan
> >> >
> >> >
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> > For additional commands, e-mail: user-help@struts.apache.org
> >> >
> >> >
> >>
> >> --
> >> Sent from my mobile device
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >
> > _________________________________________________________________
> > Windows Live™: Keep your life in sync.
> > http://windowslive.com/explore?ocid=TXT_TAGLM_WL_BR_life_in_synch_062009
>
>
>
> --
> Wes Wannemacher
> Author - Struts 2 In Practice
> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> http://www.manning.com/wannemacher
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
_________________________________________________________________
Insert movie times and more without leaving Hotmail®.
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd_062009
Re: About the "struts.multipart.saveDir" for file upload
Posted by Wes Wannemacher <we...@wantii.com>.
I don't know if I would suggest it, but you might be able to call -
Dispatcher.getInstance().setMultipartSaveDir(String path)
Now, I can't remember if there is one dispatcher per thread, so you
might have to call it in an interceptor.
However, I would strongly suggest against doing that.
I am working on an enhanced file upload plugin right now and will
probably commit it to the sandbox by tomorrow. The problem with the
stock file upload capability is that the FileItemFactory and
FileUpload objects are not available to be overridden, and hardly any
configuration is made visible. So, I've got a new
JakartaMultiPartRequest class I'll have out by tomorrow.
-Wes
On Wed, Jun 3, 2009 at 4:37 PM, Andy <an...@hotmail.com> wrote:
>
> It defaults but I think he's wondering how he can set the dir programatically.
>
>
>
>> Date: Wed, 3 Jun 2009 15:35:33 -0500
>> Subject: Re: About the "struts.multipart.saveDir" for file upload
>> From: burtonrhodes@gmail.com
>> To: user@struts.apache.org
>>
>> I wasn't aware that it was required. If you don't specify doesn't it
>> default to the 'work' directory?
>>
>> On 6/3/09, Qunhuan Mei <qm...@qm18.wanadoo.co.uk> wrote:
>> >
>> > Hi,
>> >
>> > When implementing file upload, it is required to specify an absolute
>> > directory in struts.xml such as following:
>> >
>> > <constant name="struts.multipart.saveDir" value="C:/fileUploadTempDir"
>> > />
>> >
>> > But this might be difficult to achieve, say when the project war is deployed
>> > in a external shared server and we do not have much idea about the directory
>> > structure of the target server machine.
>> >
>> > I was wondering if there is any recommended way to handle this issue.
>> >
>> > Ideally I would like to specify the directory in java code where I can
>> > detect the current working directory and specify the saveDir accordingly. Is
>> > this possible?
>> >
>> > Many thanks in advance,
>> >
>> > Qunhuan
>> >
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > For additional commands, e-mail: user-help@struts.apache.org
>> >
>> >
>>
>> --
>> Sent from my mobile device
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>
> _________________________________________________________________
> Windows Live™: Keep your life in sync.
> http://windowslive.com/explore?ocid=TXT_TAGLM_WL_BR_life_in_synch_062009
--
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: About the "struts.multipart.saveDir" for file upload
Posted by Andy <an...@hotmail.com>.
It defaults but I think he's wondering how he can set the dir programatically.
> Date: Wed, 3 Jun 2009 15:35:33 -0500
> Subject: Re: About the "struts.multipart.saveDir" for file upload
> From: burtonrhodes@gmail.com
> To: user@struts.apache.org
>
> I wasn't aware that it was required. If you don't specify doesn't it
> default to the 'work' directory?
>
> On 6/3/09, Qunhuan Mei <qm...@qm18.wanadoo.co.uk> wrote:
> >
> > Hi,
> >
> > When implementing file upload, it is required to specify an absolute
> > directory in struts.xml such as following:
> >
> > <constant name="struts.multipart.saveDir" value="C:/fileUploadTempDir"
> > />
> >
> > But this might be difficult to achieve, say when the project war is deployed
> > in a external shared server and we do not have much idea about the directory
> > structure of the target server machine.
> >
> > I was wondering if there is any recommended way to handle this issue.
> >
> > Ideally I would like to specify the directory in java code where I can
> > detect the current working directory and specify the saveDir accordingly. Is
> > this possible?
> >
> > Many thanks in advance,
> >
> > Qunhuan
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
> --
> Sent from my mobile device
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
_________________________________________________________________
Windows Live™: Keep your life in sync.
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_BR_life_in_synch_062009
Re: About the "struts.multipart.saveDir" for file upload
Posted by Burton Rhodes <bu...@gmail.com>.
I wasn't aware that it was required. If you don't specify doesn't it
default to the 'work' directory?
On 6/3/09, Qunhuan Mei <qm...@qm18.wanadoo.co.uk> wrote:
>
> Hi,
>
> When implementing file upload, it is required to specify an absolute
> directory in struts.xml such as following:
>
> <constant name="struts.multipart.saveDir" value="C:/fileUploadTempDir"
> />
>
> But this might be difficult to achieve, say when the project war is deployed
> in a external shared server and we do not have much idea about the directory
> structure of the target server machine.
>
> I was wondering if there is any recommended way to handle this issue.
>
> Ideally I would like to specify the directory in java code where I can
> detect the current working directory and specify the saveDir accordingly. Is
> this possible?
>
> Many thanks in advance,
>
> Qunhuan
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Sent from my mobile device
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: About the "struts.multipart.saveDir" for file upload
Posted by Qunhuan Mei <qm...@qm18.wanadoo.co.uk>.
Thanks a lot for all those replied by query.
The reason why I want to set saveDir in my Java code is that as a developer,
I would like to take everything under my own control but I suppose if the
default upload saveDir, without externally setting it in struts.xml, works
in all occasions, e.g. Windows, Linux,
(I am not an expert here) then the
existing arrangement of the saveDir arrangement is satisfactory.
Cheers,
Qunhuan
-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com]
Sent: 04 June 2009 01:12
To: Struts Users Mailing List
Subject: Re: About the "struts.multipart.saveDir" for file upload
Qunhuan Mei wrote:
> When implementing file upload, it is required to specify an absolute
> directory in struts.xml such as following:
>
> <constant name="struts.multipart.saveDir" value="C:/fileUploadTempDir" />
>
> But this might be difficult to achieve, say when the project war is
deployed
> in a external shared server and we do not have much idea about the
directory
> structure of the target server machine.
The current, canonical way to handle file uploads is to copy them from
the default upload directory to wherever you want them.
It's not required to set the saveDir; it defaults to the default
temporary directory. The file upload interceptor currently deletes the
uploaded file after the action executes, which is why the copy is needed.
Sounds like this will all be changing pretty quick-like, though.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: About the "struts.multipart.saveDir" for file upload
Posted by Dave Newton <ne...@yahoo.com>.
Qunhuan Mei wrote:
> When implementing file upload, it is required to specify an absolute
> directory in struts.xml such as following:
>
> <constant name="struts.multipart.saveDir" value="C:/fileUploadTempDir" />
>
> But this might be difficult to achieve, say when the project war is deployed
> in a external shared server and we do not have much idea about the directory
> structure of the target server machine.
The current, canonical way to handle file uploads is to copy them from
the default upload directory to wherever you want them.
It's not required to set the saveDir; it defaults to the default
temporary directory. The file upload interceptor currently deletes the
uploaded file after the action executes, which is why the copy is needed.
Sounds like this will all be changing pretty quick-like, though.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
About the "struts.multipart.saveDir" for file upload
Posted by Qunhuan Mei <qm...@qm18.wanadoo.co.uk>.
Hi,
When implementing file upload, it is required to specify an absolute
directory in struts.xml such as following:
<constant name="struts.multipart.saveDir" value="C:/fileUploadTempDir"
/>
But this might be difficult to achieve, say when the project war is deployed
in a external shared server and we do not have much idea about the directory
structure of the target server machine.
I was wondering if there is any recommended way to handle this issue.
Ideally I would like to specify the directory in java code where I can
detect the current working directory and specify the saveDir accordingly. Is
this possible?
Many thanks in advance,
Qunhuan
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: [S2] why is javascript executed before DOM is updated
Posted by "Kawczynski, David" <da...@merck.com>.
>> How can I use the popup window to call a div of the parent form
The window.open function returns a reference to the opened window.
You can change your
window.open (url... )
To read
var newWin = window.open(url... )
newWin.opener = window;
Then you'd have an "opener" attribute in your opened window that
points to the original window; this can be used to get the div:
window.opener.document.getElementById("somediv")
Personally, I would drop the use of the window and implement a
CSS-styled modal div of some sort.
-----Original Message-----
From: tutul [mailto:shubhrakarmakar@hotmail.com]
Sent: Wednesday, June 03, 2009 12:34 PM
To: user@struts.apache.org
Subject: Re: [S2] why is javascript executed before DOM is updated
Hi,
I am sorry to hijack this thread but I have a similar question. I have a
parent form and upon clicking a link, it opens up a popup window to
add
some form fields. When the user saves this form in the popup, a part of
parent window should get updated. How can I use the popup window to
call a
div of the parent form. Below I am giving a snippet of my jsp. the
javascript addEditAudit method will open up a jsp and upon submitting
the
form in the popup, the popup should update the <div id="details"></div>
part.
Any help in this matter would be greatly appreciated
function addEditAudit(url) {
window.open (url, "addEditWindow", "height=400, width=700");
}
</script>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<s:i18n name="com.hmsonline.auditgui.web.Messages">
<center>
<div class="dataTableHeader"><s:text
name="label.auditpiids"
/>${hmsId}</div>
<s:form name="addEditAuditForm"
action="SaveAuditsAction"
id="addEditAuditForm" method="POST"
theme="simple">
<table align="center" class="dataTable"
border="1">
<tr class="formField">
<th><s:text name="audit.id"
/></th>
<th><s:text name="audit.type"
/></th>
<th><s:text name="audit.duedate"
/></th>
<th><s:text name="audit.source"
/></th>
<th><s:text name="audit.data"
/></th>
<th><s:text
name="audit.comments" /></th>
<th><s:text name="audit.status"
/></th>
</tr>
<s:iterator value="auditRequestsGui"
status="stat">
<tr>
<s:hidden
name="auditRequestsGui[%{#stat.index}].id" />
<td><s:property
value="id" /></td>
<td><s:property
value="type" /></td>
<td><s:property
value="dueDate" /></td>
<td><s:property
value="source" /></td>
<td>
<table>
<s:iterator
value="auditData" status="aData">
<tr>
<td><s:property value="key" />:</td>
<td><s:property value="value" /></td>
</tr>
</s:iterator>
</table>
</td>
<td><s:textarea
cols="15" rows="4" id="comment"
name="auditRequestsGui[%{#stat.index}].auditorComments">${auditorComment
s}</s:textarea>
</td>
<td>
<s:select
name="auditRequestsGui[%{#stat.index}].status"
id="auditRequestsGui[%{#stat.index}].status" list="statuses"
disabled="true" />
<br/>
javascript:addEditAudit('AddEditAuditRequestAction.action')
Add/Update
<br/>
# Undo Changes
</td>
</tr>
</s:iterator>
<div id="details">
<div>
</table>
<div align="center">
<table>
<tr>
<td><s:submit
key="button.submit" cssClass="actionButton" /></td>
<td><s:reset key="button.cancel"
cssClass="actionButton" /></td>
</tr>
</table>
</div>
</s:form></center>
</s:i18n>
</html>
</jsp:root>
--
View this message in context:
http://www.nabble.com/-S2--why-is-javascript-executed-before-DOM-is-upda
ted-tp14313561p23854865.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Notice: This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates (which may be known
outside the United States as Merck Frosst, Merck Sharp & Dohme or
MSD and in Japan, as Banyu - direct contact information for affiliates is
available at http://www.merck.com/contact/contacts.html) that may be
confidential, proprietary copyrighted and/or legally privileged. It is
intended solely for the use of the individual or entity named on this
message. If you are not the intended recipient, and have received this
message in error, please notify us immediately by reply e-mail and
then delete it from your system.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] why is javascript executed before DOM is updated
Posted by tutul <sh...@hotmail.com>.
Hi,
I am sorry to hijack this thread but I have a similar question. I have a
parent form and upon clicking a link, it opens up a popup window to add
some form fields. When the user saves this form in the popup, a part of
parent window should get updated. How can I use the popup window to call a
div of the parent form. Below I am giving a snippet of my jsp. the
javascript addEditAudit method will open up a jsp and upon submitting the
form in the popup, the popup should update the <div id="details"></div>
part.
Any help in this matter would be greatly appreciated
function addEditAudit(url) {
window.open (url, "addEditWindow", "height=400, width=700");
}
</script>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<s:i18n name="com.hmsonline.auditgui.web.Messages">
<center>
<div class="dataTableHeader"><s:text name="label.auditpiids"
/>${hmsId}</div>
<s:form name="addEditAuditForm" action="SaveAuditsAction"
id="addEditAuditForm" method="POST" theme="simple">
<table align="center" class="dataTable" border="1">
<tr class="formField">
<th><s:text name="audit.id" /></th>
<th><s:text name="audit.type" /></th>
<th><s:text name="audit.duedate" /></th>
<th><s:text name="audit.source" /></th>
<th><s:text name="audit.data" /></th>
<th><s:text name="audit.comments" /></th>
<th><s:text name="audit.status" /></th>
</tr>
<s:iterator value="auditRequestsGui" status="stat">
<tr>
<s:hidden name="auditRequestsGui[%{#stat.index}].id" />
<td><s:property value="id" /></td>
<td><s:property value="type" /></td>
<td><s:property value="dueDate" /></td>
<td><s:property value="source" /></td>
<td>
<table>
<s:iterator value="auditData" status="aData">
<tr>
<td><s:property value="key" />:</td>
<td><s:property value="value" /></td>
</tr>
</s:iterator>
</table>
</td>
<td><s:textarea cols="15" rows="4" id="comment"
name="auditRequestsGui[%{#stat.index}].auditorComments">${auditorComments}</s:textarea>
</td>
<td>
<s:select name="auditRequestsGui[%{#stat.index}].status"
id="auditRequestsGui[%{#stat.index}].status" list="statuses"
disabled="true" />
<br/>
javascript:addEditAudit('AddEditAuditRequestAction.action')
Add/Update
<br/>
# Undo Changes
</td>
</tr>
</s:iterator>
<div id="details">
<div>
</table>
<div align="center">
<table>
<tr>
<td><s:submit key="button.submit" cssClass="actionButton" /></td>
<td><s:reset key="button.cancel" cssClass="actionButton" /></td>
</tr>
</table>
</div>
</s:form></center>
</s:i18n>
</html>
</jsp:root>
--
View this message in context: http://www.nabble.com/-S2--why-is-javascript-executed-before-DOM-is-updated-tp14313561p23854865.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org