var w = window.open("");
w.document.writeln("<the html you wanted to write>")
Questions and answers from the StackExchange network.
You can subscribe to an RSS feed of this list.
Jan 2010
-
Reply to:
-
We’ve always used the BouncyCastle library, I’m being asked if there are other viable alternatives, either open source or not. Or is the BouncyCastle library already the best one to use?
Dec 2009
-
We’re working on a project with a number of applets that has to work across a large range of OS (WIndows, Mac, Linux), browsers (IE, FF, Safari, etc) and Java versions (1.5+), and it often happens that a fix we apply will cause some sort of security exception an another platform or some other error.
Is there any way for us to prepare automated tests to immediately catch those problems in different platforms? I think it’s not necessary to check that the gui parts are appearing as intended, but just to detect whether unexpected exceptions are occuring.
-
We have a web screen with a number of applets that has a problem on Mac OSX 10.5.7, Firefox 3.0.15, java 1.5.0_19.
The problem is encountered on the user site. On initial load of applets (with an empty applet cache), the screen locks up/hangs while loading the applets. After refreshing the page, it loads normally. If the cache is cleared, same problem happens again.
Unfortunately, we’re not encountering this on our local test machine (same OS, java and Firefox versions)
We were able to get a jstack thread dump, see below: http://pastebin.com/m527e05dd
However, we’re not sure how to interpret it. Any suggestions or advice?
Edit: We were able to replicate in our testing machine by creating a new user (clean Firefox profile). If we clear the java cache then visit the problematic pages, the edit controls are disabled (we can’t click them to focus them), the Firefox address bar and search box have the same behavior. The edit box controls only “unfreeze” when we access the “Help” menu entry, which has a Search edit box that is active.
-
Basically, we want to create a taglib that can possibly forward request execution to another page, similar to
<jsp:forward />
. How can we prevent the rest of the JSP page from executing from within the taglib? -
I have the following .js file being run using cscript on Windows Vista with Office 2007:
var err = 0; var app = WScript.CreateObject("Word.Application"); try { var filename = WScript.StdIn.ReadLine(); var enc = filename.toLowerCase().indexOf(".txt") >= 0 ? 65001 : 1252; var objDoc = app.Documents.Open(filename, false, true, false, " ", " ", false, " ", " ", 0, enc, true, false, 0, true); objDoc.PrintOut(false, false, 0, " ", " ", " ", 0); } catch (e) { err = 1; } finally { app.Quit(0); } WScript.Quit(err);
The point of the code is that it will accept a filename from stdin and print that document using Word. My problem is that for a particular printer we are testing with, the document doesn’t get printed. I can trace that it executes .PrintOut properly and without any errors, and that the WINWORD process is started and terminated as expected (I can see it in the TaskManager). For our other test printer, the script works correctly.
I’m a bit new to this type of scripting (the guy who wrote it is on vacation…), any advice as to how I can resolve this problem?
Edit: I’ve isolated the PrintOut call, the rest of the script is irrelevant, even calling ActiveDocument.PrintOut from inside a Word document has the same problems with the printer.
-
Is there any way to have my Yahoo Mail forwarded to another email address, without getting Yahoo Mail plus?
-
Reply to:
ts_1, ts_2, ts_3, etc. are different fields on the same table? There’s no way to do that with a single statement.
-
Reply to:
You will need a better editor than Notepad. With Notepad, use Save As…, and type “helloworld.py” in the dialog, including quotes so that the file extension is .py instead of .txt
-
Reply to:
POI probably has a dependency on log4j. Just include the log4j jar in your classpath.
-
Reply to:
It means that any single SQL statement you run is atomic in nature - it will either succeed completely or fail completely. If your SQL statement fails, and triggers that would have run as a result of that SQL statement will fail as well.
-
I have an applet that is crashing Firefox on Linux.
Can anyone tell me how I can enable the java core dump log file for this applet and where the file would be generated?
-
Reply to:
The usual reason is separation of concerns. You should make it easy to modify the presentation without affecting the business layer.
-
Reply to:
You can have an array of 3-item tuples.
arr = [ (1,2,3), (4,5,6), (7,8,9)] for (k, v, x) in arr: # do stuff
-
Reply to:
If you want the average salary for all records AND a listing of the name column for each record, you need to use 2 separate queries
-
Reply to:
setInterval returns an id that you can use to cancel the interval with clearInterval()
-
Reply to:
Try wrapping it in a new function object:
$.get("InfoRetrieve", { },function() { addContent(data) });
-
Reply to:
Try “where length(column) < lengthb(column)”
-
Let’s say I have a series of
- elements designed to render via float:left inside a fixed-width container as follows:
Item 1 | Item 2 | Item 3 | Item 4 | Item 5 | Item 6
This is fine, Item 5 and Item 6 are pushed to the second row because the container has a fixed width.
Now, is it possible to have something similar to above, except that majority of the items will render in the second row? Something like:
Item 1 | Item 2 | Item 3 | Item 4| Item 5 | Item 6
Basically, I want to render a list of items horizontally, wrapping to the second row as needed, but with majority of the items on the second row if it exists. The number of items to be generated may vary, but will not exceed 2 rows’ worth of items.
- elements designed to render via float:left inside a fixed-width container as follows:
Nov 2009
-
I have a 320GB western digital external HDD that was working fine a couple of days ago.
I plugged it into my Windows XP machine at work, and it detects the USB device (it is listed in the Safely Remove Hardware dialog), but it doesn’t detect the disk, not even under Disk Management in Control Panel. I’ve successfully used this ext HD on this machine before, so I suspect it is busted. I tried it on a couple of other machines none of them could detect the disk.
The only possible reason I could think of is that the bag I was carrying it in fell to the floor off a table a couple of days ago, it might have been damaged then.
Obviously I would like to have the device working again, but failing that I would like to be able tor recover all the data on the disk.
What are my options?
Edit: In case it’s relevant, the product page for the ext HD is here.
-
Reply to:
The contents of WEB-INF aren’t publicly accessible resources, why are you putting the other jsps there? Are those other jsps accessible?
If you want to hide the index.jsp, create a servlet mapped to the root path and have it forward to index.jsp.
-
While testing our setup for user acceptance testing, we got some reports that java applets in our web application would occasionally fail to load. The envt where it was reported was WinXP/IE6, and there were no errors found in the java console.
Obviously we’d like to avoid it. What sort of things should we be checking for here? On our local servers, everything seems fine. There’s some turnaround time when sending questions to the on-site guy, so I’d look to cover as many possible causes as possible.
Some more info: We have multiple applets, in the instance that they fail loading, all of them fail loading. The applet jar files vary in size from 2MB to 8MB. I’m told it seems more likely to happen if the applet isn’t cached yet, i.e. if they’ve been able to load the applets once on a given machine, further runs on that machine go smoothly. I’m wondering if there’s some sort of network transfer error when downloading the applets, but I don’t know how to verify that.
Any advise is welcome!
-
We have an Applet that can possibly display Chinese text. We are specifying a font for it (Arial), it works fine under both Windows and Mac OSX.
But in Firefox on Linux the Chinese characters are rendered as squares. Is there a way to work around this? Note that we can’t assume the existence of a particular font file on the client.
-
I have an applet that calls a JDialog that contains a JProgressBar component. I subclass the JDialog to expose a method to update the JProgressBar, something like:
public class ProgressDialog extends javax.swing.JDialog { public void setProgress(double progress) { jProgressBar1.setValue(jProgressBar1.getMinimum() + (int) (progress * jProgressBar1.getMaximum())); } ... }
I use this dialog in the following manner:
public void test() throws Exception { progressDialog = new ProgressDialog(null, true); try { progressDialog.setLocationRelativeTo(null); // show the dialog EventQueue.invokeLater(new Runnable() { public void run() { progressDialog.setVisible(true); } }); // business logic code that calls progressDialog.setProgress along the way doStuff(); } finally { progressDialog.setVisible(false); progressDialog.dispose(); } }
It works fine on Windows/any browser. However, when invoking the above function on Firefox 2/3/3.5 on a Mac, the progressDialog is displayed indefinitely, i.e. it doesn’t close.
I suspected that calling setVisible(true) inside the EventQueue was causing the problem, since it’s a blocking call and might block the queue completely, so I tried changing it to:
// show the dialog new Thread() { public void run() { progressDialog.setVisible(true); } }.start();
With this change, the progressDialog now closes correctly, but a new problem emerged - the contents of the dialog (which included the progressbar, an icon and a JLabel used to show a message string) were no longer shown inside the dialog. It was still a problem only on Mac Firefox.
Any ideas? I realize it’s probably some AWT threading issue, but I’ve been at this for a couple of days and can’t find a good solution. Wrapping the doStuff() business logic in a separate new Thread seems to work, but it’s not easy to refactor the actual business logic code into a separate thread, so I’m hoping there’s a simpler solution.
The envt is: Mac OSX 10.5 Java 1.5 Firefox 2/3/3.5
-
We have a small .Net program that we sell with individual licenses. The individual licenses are enforced by registering a key file that is generated using information from the machine used to install the program (MAC address, etc.)
Now, we have a customer request for a site-wide license, such that they can deploy to as many machines on their site as possible. From the technical POV I’m not sure what are the usual approaches for this; our old approach won’t work since we can’t map the license to any machine-specific information.
Any suggestions?
A few more details:
- the program is a client-side program that includes an Office Add-In
- the machines to be installed on may or may not have internet access
- we aren’t restricted to .Net-only approaches, I’m just looking for a general idea of how this sort of thing is usually handled
Oct 2009
-
Can anyone make recommendations? I used to use Launchy back in the XP days, but I don’t know if there are better alternatives now.
-
Reply to:
Have your app create a temp file on startup and periodically check if it still exists. Your batch script can just delete that file to terminate the app.
-
I have a CRUD maintenance screen with a custom rich text editor control (FCKEditor actually) and the program extracts the formatted text as HTML from the control for saving to the database. However, part of our standards is that leading and trailing whitespace needs to be stripped from the content before saving, so I have to remove extraneous and <br> and such from the beginning and end of the HTML string.
I can opt to either do it on the client side (using Javascript) or on the server side (using Java) Is there an easy way to do this, using regular expressions or something? I’m not sure how complex it needs to be, I need to be able to remove stuff like:
<p><br /> </p>
yet retain it if there’s any kind of meaningful text in between. (Above snippet is from actual HTML data saved by the tester)
-
Let’s say I attach a javascript “change” event handler to a select element, something that dispatches an ajax request to load some stuff from the server.
This is fine in Firefox. However, in IE, the change event will fire every time you scroll rapidly through the combo box options using a mouse wheel. This is troublesome because it spams the server with requests, and there’s no guarantee the requests come back in the correct order, hence the client-side state may become inconsistent.
Now, our previous workaround was that we would introduce a timeout to the change handler, such that it would wait a fraction of a second before actually dispatching the request. If in that short time, another change event comes in, we cancel the previous timeout and start a new one, thus preventing spamming multiple requests.
Now, while this seems to be working, it’s a bit hackish and I’m wondering if there’s any better approach. Is there a different event we can hook to so that it doesn’t fire repeatedly when scrolling with the mouse? Or should we just disable mouse-wheeling altogether (onmousewheel="return false;")? Firefox does not seem to support mouse-wheeling thru combo boxes, but I’m not sure if disabling mouse wheeling is a serious usability no-no or something.
Can anyone recommend other solutions?
Sep 2009
-
HTML/Javascript - I want to load images dynamically, and the images I’m going to load can be of varying aspect ratios.
I want the images to fit into a specific area of the containing div - an area 40% of the containing div’s width and 80% of its height. Since they have varying aspect ratios, of course they will not always use up this entire area, but I want to resize them such that they don’t exceed the bounds. But I don’t know ahead of time whether I should specify the width or the height (and the partner attribute to auto) since I don’t know what the aspect ratio of the images will be ahead of time.
Is there a CSS way to do this? Or I need to compute the required widths using javascript?
PS I only need to do this in Firefox 3.5!
-
Here’s our home setup: we have a wireless router, connected are 2 desktop PCs (let’s call them A and B), plus we also have a laptop that connects to the router via wi-fi. Desktops A and B are connected via LAN wires.
Given that, the problem is that every time desktop A starts up or shuts down (it seems to be simply on power up or power down, the OS it’s booting into doesn’t matter), the wireless connection is reset, i.e. the laptop literally loses the connection and has to reconnect. No such problem happens when restarting desktop B. It’s a bit of a pain when I’m playing online games or something over the laptop and desktop A reboots.
I’m not sure what to check for here…would it be a problem with the router, with the way the network is set up, or something else?
-
I’m writing a webapp that would run on a device using Firefox to display a bunch of videos. The videos can be huge, up to HD quality, and would be using a large display.
I would like to be able to queue videos, i.e. have them run one after another. I’ll also have some ajax checking if there are new videos to be displayed, so I need to be able to dynamically load them. I also have some script that I need to run between videos, so I need to be able to respond to the end of each video.
Note that I’m in control of the environment, so I can make sure the needed plugin (Flash player or QuickTime, etc) and codecs re installed on the machine.
The question is: what’s the best video format for me to use? FLV or MP4? What technologies should I look into?
Aug 2009
-
Let’s say I have a Java webapp deployed on some Application Server with clustering across a few nodes.
In the webapp, we maintain a cache of some values retrieved from the database, stored in-memory as static variables. Whenever a user performs an update in a particular screen, we clear the cache so that the cached values will be retrieved again the next time they are needed.
Now the problem: Since each node in the cluster is running on a separate JVM, how can I clear the cache across all nodes? Basically I want to call a static function on each cluster node. Is there some standard J2EE way to do this, or it depends on the Application Server software?
-
Say I add events to an object using either addEventListener or attachEvent (depending on the browser); is it possible to later invoke those events programmatically?
The events handlers are added/removed using an object like this:
var Event = { add: function(obj,type,fn) { if (obj.attachEvent) { obj.attachEvent('on'+type,fn); } else { obj.addEventListener(type,fn,false); } }, remove: function(obj,type,fn) { if (obj.detachEvent) { obj.detachEvent('on'+type,fn); } else { obj.removeEventListener(type,fn,false); } } }
Or do I need to store copies of each handler and just add an Event.invoke(…) function?
Edit: Also, jQuery is not an option :D
Jul 2009
-
Say I had the following:
<select disabled="disabled" style="border: 1px red solid; color: black;"> <option>ABC</option> </select>
Firefox renders the above with a red border and black text as I expect; but IE does not, it seems to be using native colors for the border and the disabled text. Is there any way for me to be able to style it?
For edit boxes my workaround was to use readOnly instead of disabled so that I can style it, but it seems for combo boxes the readOnly attribute has no effect.
Note: I only need this to work in IE (it’s for an intranet webapp where users must use IE), so IE-specific solutions are fine.
-
Any idea for this?
Problems encountered: Using screen.availHeight and screen.availWidth as the height and width params in window.open causes the browser size to include the taskbar, and positioning at (0, 0) ignores the possibility of the taskbar being up there.
What I want is to open a new window with the size as if it was “maximized” by the user, i.e. it shouldn’t cover the windows taskbar.
(Oh, and no need to remind me that users don’t like Javascript interfering with their browser windows, etc. This is for an internal intranet webapp…)
Jun 2009
-
Specifically, say I have a string like ABC-123-NNN. I would like the paragraph to have line breaks, but not to break at the dashes.
i.e. if my text is “The serial number ABC-123-NNN is not valid”, I would like to keep together the entire serial number if it exceeds the container width.
So the following is ok:
The serial number ABC-123-NNN is not valid
But the following (which is the behavior of IE6) is not:
The serial number ABC- 123-NNN is not valid
Currently IE seems to break at dashes. Is there any applicable CSS or whatever I can apply to avoid it?
-
Given the code below:
function test() { document.forms[0].TEST[0].focus(); }
<form> <input type="button" value="Test" onclick="test()" /> <input type="radio" name="TEST" value="A">A <input type="radio" name="TEST" value="B">B </form>
In IE6, clicking the button doesn’t focus the control, unless I’ve already tabbed through the radio at least once, in which case it works. =/
Any idea how I should be focusing the control? The above works perfectly fine in FF of course.
Edit: I found that the control is being focused, except the highlight box around the radio button is not being rendered. (I can hit space to activate the radio button, and also use arrow keys to change the active button). So the question becomes: how can I force the focus highlighting box to render?
Apr 2009
-
I’m experimenting with wx.aui.AuiNotebook; is there a way I can prevent particular tabs from being closed? i.e. I have an app that allows the user to create multiple tabs in an AuiNotebook, but the first 2 tabs are system managed and I don’t want them to be closed.
Also, in a close event, can I get the window object attached to the tab being closed? (to extract data from it)
Jan 2009
-
I need to write some javascript to strip the hostname:port part from a url, meaning I want to extract the path part only.
i.e. I want to write a function getPath(url) such that getPath(“http://host:8081/path/to/something”) returns “/path/to/something”
Can this be done using regular expressions?
Dec 2008
-
I’m not sure if this a settings problem or an HTML problem, but on a page layout I’m working on, Firefox does not render the stylesheet immediately. Meaning for maybe half a second I can see the unstyled page, then the stylesheet kicks in and it renders as I expect.
All my stylesheets are in external css files loaded in the head tag. I’m not encountering this on Flock (which is a Firefox variant) nor on Google Chrome/IE.
Any idea how to avoid it?
-
$pee = preg_replace( '|<p>|', "$1<p>", $pee );
This regular expression is from the Wordpress source code (formatting.php, wpautop function); I’m not sure what it does, can anyone help?
Actually I’m trying to port this function to Python…if anyone knows of an existing port already, that would be much better as I’m really bad with regex.
Oct 2008
-
In my program, I have been receiving an error when I use a command-line compile command for mxmlc. The error is related to an embedded font name not being correctly identified by flex in the system fonts list.
However, on a whim, I decided to copy the code to Flex Builder and compile it there. To my surprise, it worked, and it found the proper font using the same system name I had given (PMingLiU).
I suspected my problem may be a locale one, and that my system cannot correctly identify the font name because of locale considerations.
I’ve tried setting the locale of the compile code to en_US, to no avail. So I would like to ask if anyone here knows how exactly Flex Builder invokes the MXML compiler and what differences there are compared to running mxmlc directly? We know it’s not using the mxmlc.exe directly, since we tried replacing mxmlc with our own executable to capture the command line parameters.
If it matters, the OS used is Windows XP.
-
I need to parse a large amount of text that uses HTML font tags for formatting,
For example:
<font face="fontname" ...>Some text</font>
Specifically, I need to determine which characters would be rendered using each font used in the text. I need to be able to handle stuff like font tags inside another font tag.
I need to use C# for this. Is there some sort of C# parser class to make this easier? Or would I have to write it myself?
Thanks!
-
Anyone have any idea how to get the value of “Language for Non-Unicode Programs” in Control Panel Regional Settings programmatically using c#?
Already tried CultureInfo, RegionInfo and getting the default encoding using the Encoding object, but I can only get the Standards and Formats value or the main code page.
Sep 2008
-
Reply to:
You’ll need a master record in a master table that contains the information common among all versions.
Then each child table uses master record id + version no as part of the primary key.
It can be done without the master table, but in my experience it will tend to make the SQL statements a lot messier.
-
Using The loader class of Adobe Flex, I load an external SWF file. However, the loaded SWF file has a different frameRate than my application.
Is it possible to have both the parent app and the loaded child app playing at different framerates? If so, how?
-
Reply to:
for oracle you could do something like below
alter table mytable add (myfield integer); update mytable set myfield = rownum;
-
I’m using C# in .Net 2.0, and I want to read in a PNG image file and check for the first row and first column that has non-transparent pixels.
What assembly and/or class should I use?
-
Reply to:
Yes, that would be useful. Especially if you have a mechanism where the error message (
exception.getMessage()
) is displayed on-screen but the actual stacktrace gets hidden away in log files which you can’t access immediately.