Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

Milan Tomc

Greenhorn
+ Follow
since Mar 06, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Milan Tomc

Hi all,


I'm using ajaxtags to populate fields. When I set the onchange attribute in the (ajaxtags-) source element, the onchange function is not being executed.

When I make this element no-ajaxtag-source, the function executes.

Thus, ALERT NOT WORKING example:
----------------------------------------------------------------------
<input type="text" id="ajaxSource" onchange="alert('Just changed')"/>

<input type="select" id="someOtherField"/>

<ajax:select
baseUrl="ajax.go"
source="ajaxSource"
target="someOtherField"
parameters="value={ajaxSource}"
/>

ALERT WORKING example:
----------------------------------------------------------------------
<input type="text" id="ajaxSource_xxxx" onchange="alert('Just changed')"/>

<input type="select" id="someOtherField"/>

<ajax:select
baseUrl="ajax.go"
source="ajaxSource"
target="someOtherField"
parameters="value={ajaxSource}"
/>

What I want is to trigger this population when a source field is populated by javascript instead of by hand (by clicking somewhere else).
I have tried to call document.getElementById('ajaxSource').onchange() after I have set the value but it does not work.

Anybody? Thank you.

[ September 24, 2007: Message edited by: Milan Tomc ]
[ September 24, 2007: Message edited by: Milan Tomc ]
As it worked fine in FF I went looking in IE settings. "Check newer versions of stored pages" was set to "every visit", I changed it to "automatically" and it works fine.

This is however a story of it's own...
[ April 30, 2007: Message edited by: Milan Tomc ]
14 years ago
Hi all,

In my app I am having this very strange problem. I am using tiles and Struts, and have in my app the possibility to select a number of files (using checkboxes) and then click on "delete". When I click on "delete", instead of the list of the selected files and a sentence "are you sure?" I
get an empty (blank) page in my body.

Here comes the bizzare part: I have disabled caching, so when I refresh a page everythin is being re-posted. When I refreshed the page, I have got the same blank body. As I got a bit frustrated I pressed a few times F5 key. After 3 or 4 times blank, suddenly the list and "are you sure?" apeared.

Any ideas?
[ April 30, 2007: Message edited by: Milan Tomc ]
14 years ago
Or with other words:

Is there a way to catch this exception and let the browser know we are no more interested in de request/stream?
14 years ago
Hi all,

I'm uploading files to a database.

When the user chooses the file and presses "upload-button" (submit) the data starts streaming. Then I wanted to see what would happen if I click something else whilst busy (like another link, button or browsers stop button) and that has cost me a day and a half now.

What i get is:

00:17:43,578 ERROR [CommonsMultipartRequestHandler] Failed to parse multipart request
org.apache.commons.fileupload.FileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:384)
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:268)
at org.apache.struts.upload.CommonsMultipartRequestHandler.handleRequest(CommonsMultipartRequestHandler.java:185)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:405)
at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:818)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:194)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

-------------------------------------------------------------------
User sees no problems. The application does what user "clicks".

What really bothers me is the fact that, once user clicks on "upload", every byte must be transmited. If I click on browsers stop button, I get the above exception. After that I click on something else and see on the status bar that the browser is sending the rest of the bytes (I tested with 50 Mb). When this is done the application does what it is told to.

So, did somebody think of a way to let the user change his mind, cancel the upload, and without waiting for tens of (canceled) Megabytes to be transmited, continue as he pleases?
14 years ago
Hi Brent,

I'm using IE (requirement), but the same happens with Opera and FF.

The only difference is that with IE it streams about 40kb of data and then it stops until the choice is made. With Opera it streams all the way, and if I wait long enough (until all the data is streamed) and then cancel I get no exception.

I did this to avoid stackTrace in the log:

try{
ServletOutputStream outStream = response.getOutputStream();
dao.getFileData(dataId, outStream);
outStream.flush();
}catch (Exception ilse){
log.info("download canceled - exception:" + ilse.getClass().getName());
}
On the slient side is everything fine. (user sees nothing)
14 years ago
Hi all,

I have a question about streaming binary data to the client.
I have discovered that when I start the action which downloads a file, the data is streaming before I decide what to do with it.

If I choose Open, then it eventually opens. but if I choose cancel, I get IllegalStateException.

Is there a way to let the data stream after one chooses what to do?

Thanks
14 years ago
Hi all,

When downloading files I get this well known "open/save/cancel window" to decide what to do.
Everything works fine. Or should I say, wordked fine, until I tried to cancel a download of a bigger file.
If a file is small (say 20 KB) everything is fine.
If a file is 50 KB or more, when I click cancel I get:

IllegalStateException: getOutputStream() has already been called for this response

My question is why?

ps. "done streaming" is only shown with small files before a click on one of the buttons. With bigger files it is shown after I click "Open". It seems that it streams "to a certain limit" and then waits for user input. x()

code below:
-------------------------------------------
in action:
----------

response.setContentLength( (int) info.getFileSize());
setContentType(response, info); //see below

ServletOutputStream outStream = response.getOutputStream();
dao.getFileData(dataId, outStream);
syso("done streaming!")
outStream.flush();

return null;

-----------

private void setContentType(HttpServletResponse resp, FileInfo info) {
...
if (extension.equals("pdf")){
resp.setContentType("application/pdf");
}else if (extension.equals("doc")){
resp.setContentType("application/msword");
}else if (extension.equals("txt")){
resp.setContentType("html/text");
}else if (extension.equals("xls")){
resp.setContentType("application/vnd.ms-excel");
}else{
resp.setContentType("application/x-file-download");
}

resp.setHeader("Content-disposition", "attachment; filename=" + info.getFilename());
resp.setHeader("Cache-Control","cache");
resp.setHeader("Pragma","cache");
resp.setDateHeader ("Expires", (new Date()).getTime()+10000);
}

----------------------

14 years ago
I did not move it, but I have copied it there. Hope it is not a problem. If it is a problem then this one can go.

thanks
14 years ago
(moved here from struts)
Hi all,

I'm developing 2 applications, and have both projects in my workspace. Both applications are deployed on a JBoss server.

The trouble (short version):
Some of the classes are used in both apps but are not identical. When I use app A I get the error because there is no such functionality in app B.

The stack trace leads to "the other" application. How come?

ps. the package is the same, but it's in another war.
14 years ago
I'm developing 2 applications, and have both projects in my workspace. Both applications are deployed on a JBoss server.

The trouble (short version):
Some of the classes are used in both apps but are not identical. When I use app A I get the error because there is no such functionality in app B.

The stack trace leads to "the other" application. How come?

ps. the package is the same, but it's in another war.
14 years ago
muchos gracias
14 years ago
Well Merrill, it does work indeed. Thanks for your reaction and help.


But,...
Could you also explain why did it work without it in Opera?
With other words, will this allways work independently of browser settings? Or should I warn the users to set their browsers in a certain way?

I also have the following in my struts-config.xml

<controller
processorClass="org.apache.struts.tiles.TilesRequestProcessor"
bufferSize="4096" debug="0" nocache="true"/>

To prevent dirty reads as a result of a back button.

Thanks again,
Milan
14 years ago
Hi,

I'm uploading (binary) files to a BLOB (most of the time word or pdf).
When I try to download a file a came across the following:
- After I click on a file to be downloaded (a html:link calling appropriate action) I get this Open/Save dialog.
- When I click Open, Word displays a warning that a file could not be found
- When I try again, Word opens the file just fine

This is only the case with IE. With Opera it works the first time. But I need it to work in IE.

In my Action:

response.setContentLength( (int) fileinfo.getFileSize());
response.setContentType("application/x-file-download");
response.setHeader("Content-disposition",
"attachment; filename="
+ fileinfo.getFilename());

ServletOutputStream outStream = response.getOutputStream();

dao.getFileData(id, outStream);
outStream.flush();
return null;

Any suggestions?
14 years ago
In my Action class (within method getMainCategories() ) :


I have got this



What am I missing here?

thanks
14 years ago