HTML Select change event fires on scroll bar click in Chrome when select tag has a size attribute

I have a simple select box with a size attribute and I want to call a function when its value changes.
So I add an onchange event to the select tag:

<select onchange="alert(this.options[this.selectedIndex].value);" size="6" id="selecttest">
  <option value = "1">1</option>
  <option value = "2" selected>2</option>
  <option value = "3">3</option>
  <option value = "4">4</option>
  <option value = "5">5</option>
  <option value = "6">6</option>
  <option value = "7">7</option>
  <option value = "8">8</option>
  <option value = "9">9</option>
  <option value = "10">10</option>
  <option value = "11">11</option>
  <option value = "12">12</option>


In Chrome [Version 27.0.1453.94 m] in Windows 7 Pro (not in IE or Firefox from my tests), the onchange event is fired when you simply click in the select box’s scroll bar, without the value having changed.

This also happens if I have a jQuery change event registered instead of using pure JavaScript (, i.e., I remove the onchange attribute and register the change event handler like so:

$(function () {
  $('#selecttest').change(function () {

Is this what I should be expecting?

Note: This only happens if you click the scroll bar or arrows first. If you click the selected value or another value, then click the scroll bar/arrows, this behavior stops.


This appears to be a known issue with 27.0.1453.94.


Hibernate – One to many relation – foreign key always “null”

I have two really simple objects and one object should contain the other one in an “one-to-many” relation in a set. The objects get inserted correctly in the database, but the foreign key in the “children” table is always “null”.

I can’t figure out why:

This is the test-object and it hold the children in its set:

public class TestObj {

    public TestObj(){}

    private Long id;

    public Long getId() {
        return id;
    public void setId(Long id) { = id;

    private Set<Children> children = new HashSet<Children>();

    @OneToMany(mappedBy = "testObj", cascade = CascadeType.ALL)
    public synchronized Set<Children> getChildren() {
        return children;
    public synchronized void setChildren(Set<Children> children) {
        this.children = children;
    public void addChildren(Children child){

This is the children object and it holds an back-link to the “TestObj”:

@Table(name = "children")
public class Children {

    public Children(){}

    private Long id;

    public Long getId() {
        return id;

    public void setId(Long id) { = id;

    private TestObj testObj;

    public TestObj getTestObj() {
        return testObj;

    public void setTestObj(TestObj testObj) {
        this.testObj = testObj;

I persist this objects with this code:

EntityManagerFactory entityManagerFactory = HibernateEntityMangerSingelton.getEntityManagerFactory();
EntityManager entityManager = entityManagerFactory.createEntityManager();

TestObj user = new TestObj();

Children child = new Children();
try {



} catch (Exception e) {

Can some explain me why this is happening?


It’s quite simple: you never initialize the testObj field in Children (which should be named Child, BTW). Children.testObj is the owner of the association, and is the field that is mapped to the join column, so if it’s null, the join column will be null.


Phonegap Geolocation not working

I’m using Phonegap.Geolocation to get the current position of the user.

And I’ve found this example in the documentation from the official website.

However, even thought the onDevice ready is executed, neither success nor error function callback is executed. And I’m really confused by this.

document.addEventListener("deviceready", onDeviceReady, false);

    // Cordova is ready
    function onDeviceReady() {
        navigator.geolocation.getCurrentPosition(onSuccess, onError);

    // onSuccess Geolocation
    function onSuccess(position) {
        var element = document.getElementById('geolocation');
        element.innerHTML = 'Latitude: '           + position.coords.latitude              + '<br />' +
                            'Longitude: '          + position.coords.longitude             + '<br />' +
                            'Altitude: '           + position.coords.altitude              + '<br />' +
                            'Accuracy: '           + position.coords.accuracy              + '<br />' +
                            'Altitude Accuracy: '  + position.coords.altitudeAccuracy      + '<br />' +
                            'Heading: '            + position.coords.heading               + '<br />' +
                            'Speed: '              + position.coords.speed                 + '<br />' +
                            'Timestamp: '          +                                   position.timestamp          + '<br />';

    // onError Callback receives a PositionError object
    function onError(error) {
        alert('code: '    + error.code    + 'n' +
                'message: ' + error.message + 'n');


Actually it is working, however the location cannot be determined in a short time so neither can it be deemed as success nor fail, and thus no action is performed.

This can be managed by setting a time-out for the callback of GeoLocation


Java GC overhead limit exceeded – Custom solution needed

I am evaluating different data from a textfile in a rather large algorithm.

If the text file contains more than datapoints (the minimum I need is sth. like 1.3 million datapoints) it gives the following error:

Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
   at java.util.regex.Matcher.<init>(Unknown Source)
   at java.util.regex.Pattern.matcher(Unknown Source)
   at java.lang.String.replaceAll(Unknown Source)
   at java.util.Scanner.processFloatToken(Unknown Source)
   at java.util.Scanner.nextDouble(Unknown Source)

When I’m running it in Eclipse with the following settings for the installed jre6 (standard VM):

-Xms20m -Xmx1024m -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:NewSize=10m 
-XX:MaxNewSize=10m -XX:SurvivorRatio=6 -XX:TargetSurvivorRatio=80 

Note that it works fine if I only run through part of the textfile.

Now I’ve read a lot about this subject and it seems that somewhere I must have either a data leak or I’m storing too much data in arrays (which I think I do).

Now my problem is: how can I work around this? Is it possible to change my settings such that I can still perform the computation or do I really need more computational power?


The really critical vm arg is -Xmx1024m, which tells the VM to use up to 1024 megabytes of memory. The simplest solution is to use a bigger number there. You can try -Xmx2048m or -Xmx4096m, or any number, assuming you have enough RAM in your machine to handle it.

I’m not sure you’re getting much benefit out of any of the other VM args. For the most part, if you tell Java how much space to use, it will be smart with the rest of the params. I’d suggest removing everything except the -Xmx param and seeing how that performs.

A better solution is to try to improve your algorithm, but I haven’t yet read through it in enough detail to offer any suggestions.


How download file with service in android?

I want download a file from internet with service. I found the source code and the code worked well. But i have a problem when i back from app the download are stopping or when i clear RAM, it also are stopping. So that i want found downloading code such as Google Play, which never stop when clear RAM, or app history. This is my source code:

public class Temp extends IntentService {
public static final int UPDATE_PROGRESS = 8344;
private int lastupdate=0;
private NotificationManager nm;
private Builder mBuilder;
public Temp() {



public int onStartCommand(Intent intent, int flags, int startId) {
    Log.d("SERVICE-ONCOMMAND", "onStartCommand");
    return START_STICKY;

protected void onHandleIntent(Intent intent) {
    nm = (NotificationManager)  getSystemService(NOTIFICATION_SERVICE);
    mBuilder = new NotificationCompat.Builder(this);
            "Picture Download dnsadg sadgasjdgashgd asgd asjdg asjgd sajgd s")
            .setContentText("Download in progress")

    File root = new File(Environment.getExternalStorageDirectory()
            + "/aaaa");
    String urlToDownload = "";
   // ResultReceiver receiver = (ResultReceiver) intent.getParcelableExtra("receiver");
    try {
        URL url = new URL(urlToDownload);
        URLConnection connection = url.openConnection();
        // this will be useful so that you can show a typical 0-100% progress bar
        int fileLength = connection.getContentLength();

        // download the file
        InputStream input = new BufferedInputStream(url.openStream());
        OutputStream output = new FileOutputStream(new File(root.getPath(),

        byte data[] = new byte[1024];
        long total = 0;
        int count;
        while ((count = != -1) {
            total += count;

            progressChange((int)(total * 100) / fileLength);
            // publishing the progress....
         //   Bundle resultData = new Bundle();
         //   resultData.putInt("progress" ,(int) (total * 100 / fileLength));
         //   receiver.send(UPDATE_PROGRESS, resultData);
            output.write(data, 0, count);

    } catch (IOException e) {

   // Bundle resultData = new Bundle();
  //  resultData.putInt("progress" ,100);
  //  receiver.send(UPDATE_PROGRESS, resultData);

public void onDestroy() {
    Log.e("DESTROY", "DESTROY");
void progressChange(int progress){

    if (lastupdate != progress) {
        lastupdate = progress;
        // not.contentView.setProgressBar(,
        // 100,Integer.valueOf(progress[0]), false);
        // inform the progress bar of updates in progress
        // nm.notify(42, not);
        if (progress < 100) {
            mBuilder.setProgress(100, Integer.valueOf(progress),
               Intent i = new Intent("com.russian.apps.TabActivity").putExtra("some_msg",progress+"%");
        } else {
            mBuilder.setContentText("Download complete")
            // Removes the progress bar
                    .setProgress(0, 0, false).setOngoing(false).setContentInfo("");;






You could try calling startForeground. Check out this post for more information.

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..