问:
R is not detecting the latest Java version (1.8) installed when using sparklyr package
R is not detecting the latest Java version (1.8) installed for the usage of sparklyr package.

```<code>config <- spark_config()
config$sparklyr.gateway.port = 10000
config$sparklyr.gateway.connect.timeout = 1
config$sparklyr.gateway.start.wait = 1000
library(sparklyr)
library(dplyr)
library(DBI)
sc <- spark_connect(master="yarn-client", method = c("shell"),config=config, app_name = "sparklyr",version="2.0.0", extensions = sparklyr::registered_extensions())

Error in validate_java_version(spark_home) :
Java version1.6.0.65 detected but 1.7+ is required. Please download and
install Java from https://www.java.com/en/
</code>```

I updated the Java version and confirmed in Mac terminal. Then I restarted the Rsession:

```<code>/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -
version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
</code>```

But I'm still getting the same error outdated Java version:

```<code>Error in validate_java_version(spark_home) :
Java version1.6.0.65 detected but 1.7+ is required. Please download and
install Java from https://www.java.com/en/
</code>```

Any idea how to fix this?

答:
I was able to fix this by installing the latest JAVA version from the following website:

http://www.oracle.com/technetwork/java/javase/downloads/index.html

You could further check if the version was updated successfully by running the following command on mac terminal:

```<code>java -version
</code>```

Now I'm able to use the sparklyr package.

Body:
R is not detecting the latest Java version (1.8) installed for the usage of sparklyr package.

config <- spark_config()
config$sparklyr.gateway.port = 10000
config$sparklyr.gateway.connect.timeout = 1
config$sparklyr.gateway.start.wait = 1000
library(sparklyr)
library(dplyr)
library(DBI)
sc <- spark_connect(master="yarn-client", method = c("shell"),config=config, app_name = "sparklyr",version="2.0.0", extensions = sparklyr::registered_extensions())

Error in validate_java_version(spark_home) :
Java version1.6.0.65 detected but 1.7+ is required. Please download and
install Java from https://www.java.com/en/

I updated the Java version and confirmed in Mac terminal. Then I restarted the Rsession:

/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -
version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

But I'm still getting the same error outdated Java version:

Error in validate_java_version(spark_home) :
Java version1.6.0.65 detected but 1.7+ is required. Please download and
install Java from https://www.java.com/en/

Any idea how to fix this?

Body:
I was able to fix this by installing the latest JAVA version from the following website:

http://www.oracle.com/technetwork/java/javase/downloads/index.html

You could further check if the version was updated successfully by running the following command on mac terminal:

java -version

Now I'm able to use the sparklyr package.


来源: stackexchange

问:
jQuery - ColorBox new window issues
I love colorbox, but I have been running in to a couple of issues that I would like to try to get resolved.

1) When you right click a link - open link in new window, it displays the colorbox link in a new window and I lose my entire layout.  Is there any way to check if the link is being opened in a new window, and if so, display a different page that has the full layout of the website?

2) The same thing happens when you click a colorbox link and the parent page is completely loaded yet.  It automatically opens the colorbox link like a normal link and I lose my entire layout again.

Has anyone ran in to these issues? If so, have you been able to resolve them?

答: I had the same thing. It appeared to be a validation error in my page. Check if your page meets the web standards / validates. Especially scripts-related lines.</p>

ContentLicense: CC BY-SA 2.5

Title: jQuery - ColorBox new window issues


问:
Java 8 map compute with set as value
My map looks like this

```<code>private Map<String, LinkedHashSet<String>> map = new HashMap<>();
</code>```

in traditional approach I can add value to map with key check as below

```<code>public void addEdge(String node1, String node2) {
        LinkedHashSet<String> adjacent = map.get(node1);
        if (adjacent == null) {
            adjacent = new LinkedHashSet();
            map.put(node1, adjacent);
        }
        adjacent.add(node2);
    }
</code>```

with java 8, I can do something like this, with this one also I'm getting same output.

```<code>map.compute(node1, (k,v)-> {
            if(v==null) {
                v=new LinkedHashSet<>();
            }
            v.add(node2);
            return v;
            });
</code>```

is there any better way to do with java 8?

答:
Use

```<code>map.computeIfAbsent(node1, k -> new LinkedHashSet<>()).add(node2);
</code>```

If node1 is already found in the map, it will be equivalent to:

```<code>map.get(node1).add(node2);
</code>```

If node1 is not already in the map, it will be equivalent to:

```<code>map.put(node1, new LinkedHashSet<>()).add(node2);
</code>```

This is exactly what you're looking for, and is even described as a use case in the documentation.

ContentLicense: CC BY-SA 3.0

Title: Java 8 map compute with set as value

Body:
My map looks like this

private Map<String, LinkedHashSet<String>> map = new HashMap<>();

in traditional approach I can add value to map with key check as below

public void addEdge(String node1, String node2) {
        LinkedHashSet<String> adjacent = map.get(node1);
        if (adjacent == null) {
            adjacent = new LinkedHashSet();
            map.put(node1, adjacent);
        }
        adjacent.add(node2);
    }

with java 8, I can do something like this, with this one also I'm getting same output.

map.compute(node1, (k,v)-> {
            if(v==null) {
                v=new LinkedHashSet<>();
            }
            v.add(node2);
            return v;
            });

is there any better way to do with java 8?

Body:
Use

map.computeIfAbsent(node1, k -> new LinkedHashSet<>()).add(node2);

If node1 is already found in the map, it will be equivalent to:

map.get(node1).add(node2);

If node1 is not already in the map, it will be equivalent to:

map.put(node1, new LinkedHashSet<>()).add(node2);

This is exactly what you're looking for, and is even described as a use case in the documentation.


问:
Having trouble with flexboxes and animation
I'm trying to animate the search bar on a website (that is still a project) the animation works, but the search input just teleports himself when the animation starts like this:

I'm using jQuery for the animation, just because I would like to do other things when I click on it, like hiding the logo and stuff like this. Here is my code:

$(".search-field").focus(function () {
    $(this).animate({ "width": "100%" }, "slow" );

    // $(".logo").fadeOut();
});
$(".search-field").focusout(function () {
    $(this).animate({ "width": "130px" }, "slow" );
    // $(".logo").fadeIn();
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>@import url('https://fonts.googleapis.com/css?family=Roboto+Slab');
/*! HTML5 Boilerplate v5.3.0 | MIT License | https://html5boilerplate.com/ */

/*
 * What follows is the result of much research on cross-browser styling.
 * Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal,
 * Kroc Camen, and the H5BP dev community and team.
 */

/* ==========================================================================
   Base styles: opinionated defaults
   ========================================================================== */

html {
    color: #222;
    font-size: 1em;
    line-height: 1.4;
    z-index: 1;
}

/*
 * Remove text-shadow in selection highlight:
 * https://twitter.com/miketaylr/status/12228805301
 *
 * These selection rule sets have to be separate.
 * Customize the background color to match your design.
 */

::-moz-selection {
    background: #b3d4fc;
    text-shadow: none;
}

::selection {
    background: #b3d4fc;
    text-shadow: none;
}

/*
 * A better looking default horizontal rule
 */

hr {
    display: block;
    height: 1px;
    border: 0;
    border-top: 1px solid #ccc;
    margin: 1em 0;
    padding: 0;
}

/*
 * Remove the gap between audio, canvas, iframes,
 * images, videos and the bottom of their containers:
 * https://github.com/h5bp/html5-boilerplate/issues/440
 */

audio,
canvas,
iframe,
img,
svg,
video {
    vertical-align: middle;
}

/*
 * Remove default fieldset styles.
 */

fieldset {
    border: 0;
    margin: 0;
    padding: 0;
}

/*
 * Allow only vertical resizing of textareas.
 */

textarea {
    resize: vertical;
}

/* ==========================================================================
   Browser Upgrade Prompt
   ========================================================================== */

.browserupgrade {
    margin: 0.2em 0;
    background: #ccc;
    color: #000;
    padding: 0.2em 0;
}

/* ==========================================================================
   Author's custom styles
   ========================================================================== */

/* ==========================================================================
   Helper classes
   ========================================================================== */

/*
 * Hide visually and from screen readers
 */

.hidden {
    display: none !important;
}

/*
 * Hide only visually, but have it available for screen readers:
 * http://snook.ca/archives/html_and_css/hiding-content-for-accessibility
 */

.visuallyhidden {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
}

/*
 * Extends the .visuallyhidden class to allow the element
 * to be focusable when navigated to via the keyboard:
 * https://www.drupal.org/node/897638
 */

.visuallyhidden.focusable:active,
.visuallyhidden.focusable:focus {
    clip: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    position: static;
    width: auto;
}

/*
 * Hide visually and from screen readers, but maintain layout
 */

.invisible {
    visibility: hidden;
}

/*
 * Clearfix: contain floats
 *
 * For modern browsers
 * 1. The space content is one way to avoid an Opera bug when the
 *    `contenteditable` attribute is included anywhere else in the document.
 *    Otherwise it causes space to appear at the top and bottom of elements
 *    that receive the `clearfix` class.
 * 2. The use of `table` rather than `block` is only necessary if using
 *    `:before` to contain the top-margins of child elements.
 */

.clearfix:before,
.clearfix:after {
    content: " "; /* 1 */
    display: table; /* 2 */
}

.clearfix:after {
    clear: both;
}

/* ==========================================================================
   EXAMPLE Media Queries for Responsive Design.
   These examples override the primary ('mobile first') styles.
   Modify as content requires.
   ========================================================================== */

@media only screen and (min-width: 35em) {
    /* Style adjustments for viewports that meet the condition */
}

@media print,
       (-webkit-min-device-pixel-ratio: 1.25),
       (min-resolution: 1.25dppx),
       (min-resolution: 120dpi) {
    /* Style adjustments for high resolution devices */
}

/* ==========================================================================
   Print styles.
   Inlined to avoid the additional HTTP request:
   http://www.phpied.com/delay-loading-your-print-css/
   ========================================================================== */

@media print {
    *,
    *:before,
    *:after,
    *:first-letter,
    *:first-line {
        background: transparent !important;
        color: #000 !important; /* Black prints faster:
                                   http://www.sanbeiji.com/archives/953 */
        box-shadow: none !important;
        text-shadow: none !important;
    }

    a,
    a:visited {
        text-decoration: underline;
    }

    a[href]:after {
        content: " (" attr(href) ")";
    }

    abbr[title]:after {
        content: " (" attr(title) ")";
    }

    /*
     * Don't show links that are fragment identifiers,
     * or use the `javascript:` pseudo protocol
     */

    a[href^="#"]:after,
    a[href^="javascript:"]:after {
        content: "";
    }

    pre,
    blockquote {
        border: 1px solid #999;
        page-break-inside: avoid;
    }

    /*
     * Printing Tables:
     * http://css-discuss.incutio.com/wiki/Printing_Tables
     */

    thead {
        display: table-header-group;
    }

    tr,
    img {
        page-break-inside: avoid;
    }

    img {
        max-width: 100% !important;
    }

    p,
    h2,
    h3 {
        orphans: 3;
        widows: 3;
    }

    h2,
    h3 {
        page-break-after: avoid;
    }
}
/* ==========================================================================
   Real CSS
   ========================================================================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    font-size: 14px;
    line-height: 1.5;
}
.top {
    position: fixed;
    height: 50px;
    /*padding: 12px;*/
    width: 100vw;
    background-color: #24292e;
    color: rgba(255, 255, 255, 0.75);
    z-index: 10;
}
.container {
    padding-top: 2px;
    width: 980px;
    margin-right: auto;
    margin-left: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nav {
    list-style: none;
    padding-left: 0;
    margin-top: 0;
    margin-bottom: 0
}
.nav-item {
    padding: 12px;
    float: left;
    list-style: none;
}
.logo {
    flex: unset;
}
.header-item {
    display: flex;
    flex-direction: row;
}
.nav-item1 {
    width: 300px;
    justify-content: space-around;
}
.nav-item3 {
    width: 300px;
    justify-content: space-between;
}
.search-field {
    width: 130px;
    border: 2px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    background-color: rgba(255, 255, 255, 0.3);
    background-image: url('https://cdn.rawgit.com/encharm/Font-Awesome-SVG-PNG/b7f74631/black/png/24/search.png');
    background-position: 3px 3px;
    background-repeat: no-repeat;
    padding: 6px 20px 6px 40px;
    transition: width 0.4s ease-in-out;
}

.sign {
    display: flex;
    flex-direction: row;
}
.sign-in {
    margin-left: auto;
    padding: 5px;
    border: 3px solid rgba(255, 255, 255, 0.75);
    border-right-width: 0px;
    border-top-left-radius: 5px;
    border-bottom-left-radius: 5px;
}
.sign-up {
    margin-left: auto;
    padding: 5px;
    border: 3px solid rgba(255, 255, 255, 0.75);
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
}

.div-title {
    width: 50vw;
    position: absolute;
    margin-left: 20vw;
    margin-top: 75px;
    color: grey;
}
.posts {
    width: 50vw;
    position: absolute;
    margin-left: 20vw;
    margin-top: 125px;
}
.post {
    width: 100%;
    height: 25vh;
    border: 1px solid #F2F2F2;
    margin-bottom: 20px;
    /*box-shadow: 0px 0px 5px #888888;*/
}
.post > .profile {
    z-index: 2;
    position: absolute;
    margin-top: 7vh;
    margin-left: 20px;
}
.post > .title {
    font-family: 'Roboto Slab', serif;
    font-size: 1.5em;
    margin-left: 100px;
    margin-top: 15px;
}
.post > .content {
    margin-left: 100px;
    margin-top: 10px;
}</code>```

Logo

                        <input type="text" class="search-field" name="search" placeholder="Search...">

New

Home

Explore

Sign In

Sign Up

```

Could you help me by giving me a solution to cancel the "teleportation" or by giving me a trick to make it look smoother?

答:
I added a width restriction to .search, the container of the search field.  This will force the input to scale relative to .search.

```<code>.search {
  width:calc(100% - 40px);
}
</code>```

$(".search-field").focus(function () {
    $(this).animate({ "width": "100%" }, "slow" );

    // $(".logo").fadeOut();
});
$(".search-field").focusout(function () {
    $(this).animate({ "width": "130px" }, "slow" );
    // $(".logo").fadeIn();
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>@import url('https://fonts.googleapis.com/css?family=Roboto+Slab');
/*! HTML5 Boilerplate v5.3.0 | MIT License | https://html5boilerplate.com/ */

/*
 * What follows is the result of much research on cross-browser styling.
 * Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal,
 * Kroc Camen, and the H5BP dev community and team.
 */

/* ==========================================================================
   Base styles: opinionated defaults
   ========================================================================== */

html {
    color: #222;
    font-size: 1em;
    line-height: 1.4;
    z-index: 1;
}

/*
 * Remove text-shadow in selection highlight:
 * https://twitter.com/miketaylr/status/12228805301
 *
 * These selection rule sets have to be separate.
 * Customize the background color to match your design.
 */

::-moz-selection {
    background: #b3d4fc;
    text-shadow: none;
}

::selection {
    background: #b3d4fc;
    text-shadow: none;
}

/*
 * A better looking default horizontal rule
 */

hr {
    display: block;
    height: 1px;
    border: 0;
    border-top: 1px solid #ccc;
    margin: 1em 0;
    padding: 0;
}

/*
 * Remove the gap between audio, canvas, iframes,
 * images, videos and the bottom of their containers:
 * https://github.com/h5bp/html5-boilerplate/issues/440
 */

audio,
canvas,
iframe,
img,
svg,
video {
    vertical-align: middle;
}

/*
 * Remove default fieldset styles.
 */

fieldset {
    border: 0;
    margin: 0;
    padding: 0;
}

/*
 * Allow only vertical resizing of textareas.
 */

textarea {
    resize: vertical;
}

/* ==========================================================================
   Browser Upgrade Prompt
   ========================================================================== */

.browserupgrade {
    margin: 0.2em 0;
    background: #ccc;
    color: #000;
    padding: 0.2em 0;
}

/* ==========================================================================
   Author's custom styles
   ========================================================================== */

/* ==========================================================================
   Helper classes
   ========================================================================== */

/*
 * Hide visually and from screen readers
 */

.hidden {
    display: none !important;
}

/*
 * Hide only visually, but have it available for screen readers:
 * http://snook.ca/archives/html_and_css/hiding-content-for-accessibility
 */

.visuallyhidden {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
}

/*
 * Extends the .visuallyhidden class to allow the element
 * to be focusable when navigated to via the keyboard:
 * https://www.drupal.org/node/897638
 */

.visuallyhidden.focusable:active,
.visuallyhidden.focusable:focus {
    clip: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    position: static;
    width: auto;
}

/*
 * Hide visually and from screen readers, but maintain layout
 */

.invisible {
    visibility: hidden;
}

/*
 * Clearfix: contain floats
 *
 * For modern browsers
 * 1. The space content is one way to avoid an Opera bug when the
 *    `contenteditable` attribute is included anywhere else in the document.
 *    Otherwise it causes space to appear at the top and bottom of elements
 *    that receive the `clearfix` class.
 * 2. The use of `table` rather than `block` is only necessary if using
 *    `:before` to contain the top-margins of child elements.
 */

.clearfix:before,
.clearfix:after {
    content: " "; /* 1 */
    display: table; /* 2 */
}

.clearfix:after {
    clear: both;
}

/* ==========================================================================
   EXAMPLE Media Queries for Responsive Design.
   These examples override the primary ('mobile first') styles.
   Modify as content requires.
   ========================================================================== */

@media only screen and (min-width: 35em) {
    /* Style adjustments for viewports that meet the condition */
}

@media print,
       (-webkit-min-device-pixel-ratio: 1.25),
       (min-resolution: 1.25dppx),
       (min-resolution: 120dpi) {
    /* Style adjustments for high resolution devices */
}

/* ==========================================================================
   Print styles.
   Inlined to avoid the additional HTTP request:
   http://www.phpied.com/delay-loading-your-print-css/
   ========================================================================== */

@media print {
    *,
    *:before,
    *:after,
    *:first-letter,
    *:first-line {
        background: transparent !important;
        color: #000 !important; /* Black prints faster:
                                   http://www.sanbeiji.com/archives/953 */
        box-shadow: none !important;
        text-shadow: none !important;
    }

    a,
    a:visited {
        text-decoration: underline;
    }

    a[href]:after {
        content: " (" attr(href) ")";
    }

    abbr[title]:after {
        content: " (" attr(title) ")";
    }

    /*
     * Don't show links that are fragment identifiers,
     * or use the `javascript:` pseudo protocol
     */

    a[href^="#"]:after,
    a[href^="javascript:"]:after {
        content: "";
    }

    pre,
    blockquote {
        border: 1px solid #999;
        page-break-inside: avoid;
    }

    /*
     * Printing Tables:
     * http://css-discuss.incutio.com/wiki/Printing_Tables
     */

    thead {
        display: table-header-group;
    }

    tr,
    img {
        page-break-inside: avoid;
    }

    img {
        max-width: 100% !important;
    }

    p,
    h2,
    h3 {
        orphans: 3;
        widows: 3;
    }

    h2,
    h3 {
        page-break-after: avoid;
    }
}
/* ==========================================================================
   Real CSS
   ========================================================================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    font-size: 14px;
    line-height: 1.5;
}
.top {
    position: fixed;
    height: 50px;
    /*padding: 12px;*/
    width: 100vw;
    background-color: #24292e;
    color: rgba(255, 255, 255, 0.75);
    z-index: 10;
}
.container {
    padding-top: 2px;
    width: 980px;
    margin-right: auto;
    margin-left: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nav {
    list-style: none;
    padding-left: 0;
    margin-top: 0;
    margin-bottom: 0
}
.nav-item {
    padding: 12px;
    float: left;
    list-style: none;
}
.logo {
    flex: unset;
}
.header-item {
    display: flex;
    flex-direction: row;
}
.nav-item1 {
    width: 300px;
    justify-content: space-around;
}
.nav-item3 {
    width: 300px;
    justify-content: space-between;
}
.search-field {
    width: 130px;
    border: 2px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    background-color: rgba(255, 255, 255, 0.3);
    background-image: url('https://cdn.rawgit.com/encharm/Font-Awesome-SVG-PNG/b7f74631/black/png/24/search.png');
    background-position: 3px 3px;
    background-repeat: no-repeat;
    padding: 6px 20px 6px 40px;
    transition: width 0.4s ease-in-out;
}

.sign {
    display: flex;
    flex-direction: row;
}
.sign-in {
    margin-left: auto;
    padding: 5px;
    border: 3px solid rgba(255, 255, 255, 0.75);
    border-right-width: 0px;
    border-top-left-radius: 5px;
    border-bottom-left-radius: 5px;
}
.sign-up {
    margin-left: auto;
    padding: 5px;
    border: 3px solid rgba(255, 255, 255, 0.75);
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
}

.div-title {
    width: 50vw;
    position: absolute;
    margin-left: 20vw;
    margin-top: 75px;
    color: grey;
}
.posts {
    width: 50vw;
    position: absolute;
    margin-left: 20vw;
    margin-top: 125px;
}
.post {
    width: 100%;
    height: 25vh;
    border: 1px solid #F2F2F2;
    margin-bottom: 20px;
    /*box-shadow: 0px 0px 5px #888888;*/
}
.post > .profile {
    z-index: 2;
    position: absolute;
    margin-top: 7vh;
    margin-left: 20px;
}
.post > .title {
    font-family: 'Roboto Slab', serif;
    font-size: 1.5em;
    margin-left: 100px;
    margin-top: 15px;
}
.post > .content {
    margin-left: 100px;
    margin-top: 10px;
}
.search {
  width:calc(100% - 40px);
}</code>```

Logo

                        <input type="text" class="search-field" name="search" placeholder="Search...">

New

Home

Explore

Sign In

Sign Up

```

Body:
I'm trying to animate the search bar on a website (that is still a project) the animation works, but the search input just teleports himself when the animation starts like this:

I'm using jQuery for the animation, just because I would like to do other things when I click on it, like hiding the logo and stuff like this. Here is my code:

$(".search-field").focus(function () {
    $(this).animate({ "width": "100%" }, "slow" );

    // $(".logo").fadeOut();
});
$(".search-field").focusout(function () {
    $(this).animate({ "width": "130px" }, "slow" );
    // $(".logo").fadeIn();
});

@import url('https://fonts.googleapis.com/css?family=Roboto+Slab');
/*! HTML5 Boilerplate v5.3.0 | MIT License | https://html5boilerplate.com/ */

/*
 * What follows is the result of much research on cross-browser styling.
 * Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal,
 * Kroc Camen, and the H5BP dev community and team.
 */

/* ==========================================================================
   Base styles: opinionated defaults
   ========================================================================== */

html {
    color: #222;
    font-size: 1em;
    line-height: 1.4;
    z-index: 1;
}

/*
 * Remove text-shadow in selection highlight:
 * https://twitter.com/miketaylr/status/12228805301
 *
 * These selection rule sets have to be separate.
 * Customize the background color to match your design.
 */

::-moz-selection {
    background: #b3d4fc;
    text-shadow: none;
}

::selection {
    background: #b3d4fc;
    text-shadow: none;
}

/*
 * A better looking default horizontal rule
 */

hr {
    display: block;
    height: 1px;
    border: 0;
    border-top: 1px solid #ccc;
    margin: 1em 0;
    padding: 0;
}

/*
 * Remove the gap between audio, canvas, iframes,
 * images, videos and the bottom of their containers:
 * https://github.com/h5bp/html5-boilerplate/issues/440
 */

audio,
canvas,
iframe,
img,
svg,
video {
    vertical-align: middle;
}

/*
 * Remove default fieldset styles.
 */

fieldset {
    border: 0;
    margin: 0;
    padding: 0;
}

/*
 * Allow only vertical resizing of textareas.
 */

textarea {
    resize: vertical;
}

/* ==========================================================================
   Browser Upgrade Prompt
   ========================================================================== */

.browserupgrade {
    margin: 0.2em 0;
    background: #ccc;
    color: #000;
    padding: 0.2em 0;
}

/* ==========================================================================
   Author's custom styles
   ========================================================================== */

/* ==========================================================================
   Helper classes
   ========================================================================== */

/*
 * Hide visually and from screen readers
 */

.hidden {
    display: none !important;
}

/*
 * Hide only visually, but have it available for screen readers:
 * http://snook.ca/archives/html_and_css/hiding-content-for-accessibility
 */

.visuallyhidden {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
}

/*
 * Extends the .visuallyhidden class to allow the element
 * to be focusable when navigated to via the keyboard:
 * https://www.drupal.org/node/897638
 */

.visuallyhidden.focusable:active,
.visuallyhidden.focusable:focus {
    clip: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    position: static;
    width: auto;
}

/*
 * Hide visually and from screen readers, but maintain layout
 */

.invisible {
    visibility: hidden;
}

/*
 * Clearfix: contain floats
 *
 * For modern browsers
 * 1. The space content is one way to avoid an Opera bug when the
 *    `contenteditable` attribute is included anywhere else in the document.
 *    Otherwise it causes space to appear at the top and bottom of elements
 *    that receive the `clearfix` class.
 * 2. The use of `table` rather than `block` is only necessary if using
 *    `:before` to contain the top-margins of child elements.
 */

.clearfix:before,
.clearfix:after {
    content: " "; /* 1 */
    display: table; /* 2 */
}

.clearfix:after {
    clear: both;
}

/* ==========================================================================
   EXAMPLE Media Queries for Responsive Design.
   These examples override the primary ('mobile first') styles.
   Modify as content requires.
   ========================================================================== */

@media only screen and (min-width: 35em) {
    /* Style adjustments for viewports that meet the condition */
}

@media print,
       (-webkit-min-device-pixel-ratio: 1.25),
       (min-resolution: 1.25dppx),
       (min-resolution: 120dpi) {
    /* Style adjustments for high resolution devices */
}

/* ==========================================================================
   Print styles.
   Inlined to avoid the additional HTTP request:
   http://www.phpied.com/delay-loading-your-print-css/
   ========================================================================== */

@media print {
    *,
    *:before,
    *:after,
    *:first-letter,
    *:first-line {
        background: transparent !important;
        color: #000 !important; /* Black prints faster:
                                   http://www.sanbeiji.com/archives/953 */
        box-shadow: none !important;
        text-shadow: none !important;
    }

    a,
    a:visited {
        text-decoration: underline;
    }

    a[href]:after {
        content: " (" attr(href) ")";
    }

    abbr[title]:after {
        content: " (" attr(title) ")";
    }

    /*
     * Don't show links that are fragment identifiers,
     * or use the `javascript:` pseudo protocol
     */

    a[href^="#"]:after,
    a[href^="javascript:"]:after {
        content: "";
    }

    pre,
    blockquote {
        border: 1px solid #999;
        page-break-inside: avoid;
    }

    /*
     * Printing Tables:
     * http://css-discuss.incutio.com/wiki/Printing_Tables
     */

    thead {
        display: table-header-group;
    }

    tr,
    img {
        page-break-inside: avoid;
    }

    img {
        max-width: 100% !important;
    }

    p,
    h2,
    h3 {
        orphans: 3;
        widows: 3;
    }

    h2,
    h3 {
        page-break-after: avoid;
    }
}
/* ==========================================================================
   Real CSS
   ========================================================================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    font-size: 14px;
    line-height: 1.5;
}
.top {
    position: fixed;
    height: 50px;
    /*padding: 12px;*/
    width: 100vw;
    background-color: #24292e;
    color: rgba(255, 255, 255, 0.75);
    z-index: 10;
}
.container {
    padding-top: 2px;
    width: 980px;
    margin-right: auto;
    margin-left: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nav {
    list-style: none;
    padding-left: 0;
    margin-top: 0;
    margin-bottom: 0
}
.nav-item {
    padding: 12px;
    float: left;
    list-style: none;
}
.logo {
    flex: unset;
}
.header-item {
    display: flex;
    flex-direction: row;
}
.nav-item1 {
    width: 300px;
    justify-content: space-around;
}
.nav-item3 {
    width: 300px;
    justify-content: space-between;
}
.search-field {
    width: 130px;
    border: 2px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    background-color: rgba(255, 255, 255, 0.3);
    background-image: url('https://cdn.rawgit.com/encharm/Font-Awesome-SVG-PNG/b7f74631/black/png/24/search.png');
    background-position: 3px 3px;
    background-repeat: no-repeat;
    padding: 6px 20px 6px 40px;
    transition: width 0.4s ease-in-out;
}

.sign {
    display: flex;
    flex-direction: row;
}
.sign-in {
    margin-left: auto;
    padding: 5px;
    border: 3px solid rgba(255, 255, 255, 0.75);
    border-right-width: 0px;
    border-top-left-radius: 5px;
    border-bottom-left-radius: 5px;
}
.sign-up {
    margin-left: auto;
    padding: 5px;
    border: 3px solid rgba(255, 255, 255, 0.75);
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
}

.div-title {
    width: 50vw;
    position: absolute;
    margin-left: 20vw;
    margin-top: 75px;
    color: grey;
}
.posts {
    width: 50vw;
    position: absolute;
    margin-left: 20vw;
    margin-top: 125px;
}
.post {
    width: 100%;
    height: 25vh;
    border: 1px solid #F2F2F2;
    margin-bottom: 20px;
    /*box-shadow: 0px 0px 5px #888888;*/
}
.post > .profile {
    z-index: 2;
    position: absolute;
    margin-top: 7vh;
    margin-left: 20px;
}
.post > .title {
    font-family: 'Roboto Slab', serif;
    font-size: 1.5em;
    margin-left: 100px;
    margin-top: 15px;
}
.post > .content {
    margin-left: 100px;
    margin-top: 10px;
}

Logo

                        <input type="text" class="search-field" name="search" placeholder="Search...">

New

Home

Explore

Sign In

Sign Up

Could you help me by giving me a solution to cancel the "teleportation" or by giving me a trick to make it look smoother?

Body:
I added a width restriction to .search, the container of the search field.  This will force the input to scale relative to .search.

.search {
  width:calc(100% - 40px);
}

$(".search-field").focus(function () {
    $(this).animate({ "width": "100%" }, "slow" );

    // $(".logo").fadeOut();
});
$(".search-field").focusout(function () {
    $(this).animate({ "width": "130px" }, "slow" );
    // $(".logo").fadeIn();
});

@import url('https://fonts.googleapis.com/css?family=Roboto+Slab');
/*! HTML5 Boilerplate v5.3.0 | MIT License | https://html5boilerplate.com/ */

/*
 * What follows is the result of much research on cross-browser styling.
 * Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal,
 * Kroc Camen, and the H5BP dev community and team.
 */

/* ==========================================================================
   Base styles: opinionated defaults
   ========================================================================== */

html {
    color: #222;
    font-size: 1em;
    line-height: 1.4;
    z-index: 1;
}

/*
 * Remove text-shadow in selection highlight:
 * https://twitter.com/miketaylr/status/12228805301
 *
 * These selection rule sets have to be separate.
 * Customize the background color to match your design.
 */

::-moz-selection {
    background: #b3d4fc;
    text-shadow: none;
}

::selection {
    background: #b3d4fc;
    text-shadow: none;
}

/*
 * A better looking default horizontal rule
 */

hr {
    display: block;
    height: 1px;
    border: 0;
    border-top: 1px solid #ccc;
    margin: 1em 0;
    padding: 0;
}

/*
 * Remove the gap between audio, canvas, iframes,
 * images, videos and the bottom of their containers:
 * https://github.com/h5bp/html5-boilerplate/issues/440
 */

audio,
canvas,
iframe,
img,
svg,
video {
    vertical-align: middle;
}

/*
 * Remove default fieldset styles.
 */

fieldset {
    border: 0;
    margin: 0;
    padding: 0;
}

/*
 * Allow only vertical resizing of textareas.
 */

textarea {
    resize: vertical;
}

/* ==========================================================================
   Browser Upgrade Prompt
   ========================================================================== */

.browserupgrade {
    margin: 0.2em 0;
    background: #ccc;
    color: #000;
    padding: 0.2em 0;
}

/* ==========================================================================
   Author's custom styles
   ========================================================================== */

/* ==========================================================================
   Helper classes
   ========================================================================== */

/*
 * Hide visually and from screen readers
 */

.hidden {
    display: none !important;
}

/*
 * Hide only visually, but have it available for screen readers:
 * http://snook.ca/archives/html_and_css/hiding-content-for-accessibility
 */

.visuallyhidden {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
}

/*
 * Extends the .visuallyhidden class to allow the element
 * to be focusable when navigated to via the keyboard:
 * https://www.drupal.org/node/897638
 */

.visuallyhidden.focusable:active,
.visuallyhidden.focusable:focus {
    clip: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    position: static;
    width: auto;
}

/*
 * Hide visually and from screen readers, but maintain layout
 */

.invisible {
    visibility: hidden;
}

/*
 * Clearfix: contain floats
 *
 * For modern browsers
 * 1. The space content is one way to avoid an Opera bug when the
 *    `contenteditable` attribute is included anywhere else in the document.
 *    Otherwise it causes space to appear at the top and bottom of elements
 *    that receive the `clearfix` class.
 * 2. The use of `table` rather than `block` is only necessary if using
 *    `:before` to contain the top-margins of child elements.
 */

.clearfix:before,
.clearfix:after {
    content: " "; /* 1 */
    display: table; /* 2 */
}

.clearfix:after {
    clear: both;
}

/* ==========================================================================
   EXAMPLE Media Queries for Responsive Design.
   These examples override the primary ('mobile first') styles.
   Modify as content requires.
   ========================================================================== */

@media only screen and (min-width: 35em) {
    /* Style adjustments for viewports that meet the condition */
}

@media print,
       (-webkit-min-device-pixel-ratio: 1.25),
       (min-resolution: 1.25dppx),
       (min-resolution: 120dpi) {
    /* Style adjustments for high resolution devices */
}

/* ==========================================================================
   Print styles.
   Inlined to avoid the additional HTTP request:
   http://www.phpied.com/delay-loading-your-print-css/
   ========================================================================== */

@media print {
    *,
    *:before,
    *:after,
    *:first-letter,
    *:first-line {
        background: transparent !important;
        color: #000 !important; /* Black prints faster:
                                   http://www.sanbeiji.com/archives/953 */
        box-shadow: none !important;
        text-shadow: none !important;
    }

    a,
    a:visited {
        text-decoration: underline;
    }

    a[href]:after {
        content: " (" attr(href) ")";
    }

    abbr[title]:after {
        content: " (" attr(title) ")";
    }

    /*
     * Don't show links that are fragment identifiers,
     * or use the `javascript:` pseudo protocol
     */

    a[href^="#"]:after,
    a[href^="javascript:"]:after {
        content: "";
    }

    pre,
    blockquote {
        border: 1px solid #999;
        page-break-inside: avoid;
    }

    /*
     * Printing Tables:
     * http://css-discuss.incutio.com/wiki/Printing_Tables
     */

    thead {
        display: table-header-group;
    }

    tr,
    img {
        page-break-inside: avoid;
    }

    img {
        max-width: 100% !important;
    }

    p,
    h2,
    h3 {
        orphans: 3;
        widows: 3;
    }

    h2,
    h3 {
        page-break-after: avoid;
    }
}
/* ==========================================================================
   Real CSS
   ========================================================================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    font-size: 14px;
    line-height: 1.5;
}
.top {
    position: fixed;
    height: 50px;
    /*padding: 12px;*/
    width: 100vw;
    background-color: #24292e;
    color: rgba(255, 255, 255, 0.75);
    z-index: 10;
}
.container {
    padding-top: 2px;
    width: 980px;
    margin-right: auto;
    margin-left: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nav {
    list-style: none;
    padding-left: 0;
    margin-top: 0;
    margin-bottom: 0
}
.nav-item {
    padding: 12px;
    float: left;
    list-style: none;
}
.logo {
    flex: unset;
}
.header-item {
    display: flex;
    flex-direction: row;
}
.nav-item1 {
    width: 300px;
    justify-content: space-around;
}
.nav-item3 {
    width: 300px;
    justify-content: space-between;
}
.search-field {
    width: 130px;
    border: 2px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    background-color: rgba(255, 255, 255, 0.3);
    background-image: url('https://cdn.rawgit.com/encharm/Font-Awesome-SVG-PNG/b7f74631/black/png/24/search.png');
    background-position: 3px 3px;
    background-repeat: no-repeat;
    padding: 6px 20px 6px 40px;
    transition: width 0.4s ease-in-out;
}

.sign {
    display: flex;
    flex-direction: row;
}
.sign-in {
    margin-left: auto;
    padding: 5px;
    border: 3px solid rgba(255, 255, 255, 0.75);
    border-right-width: 0px;
    border-top-left-radius: 5px;
    border-bottom-left-radius: 5px;
}
.sign-up {
    margin-left: auto;
    padding: 5px;
    border: 3px solid rgba(255, 255, 255, 0.75);
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
}

.div-title {
    width: 50vw;
    position: absolute;
    margin-left: 20vw;
    margin-top: 75px;
    color: grey;
}
.posts {
    width: 50vw;
    position: absolute;
    margin-left: 20vw;
    margin-top: 125px;
}
.post {
    width: 100%;
    height: 25vh;
    border: 1px solid #F2F2F2;
    margin-bottom: 20px;
    /*box-shadow: 0px 0px 5px #888888;*/
}
.post > .profile {
    z-index: 2;
    position: absolute;
    margin-top: 7vh;
    margin-left: 20px;
}
.post > .title {
    font-family: 'Roboto Slab', serif;
    font-size: 1.5em;
    margin-left: 100px;
    margin-top: 15px;
}
.post > .content {
    margin-left: 100px;
    margin-top: 10px;
}
.search {
  width:calc(100% - 40px);
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="top" role="banner">
            <div class="container">
                <div class="nav-item1 header-item">
                    <div class="logo">Logo</div>
                    <div class="search">
                        <input type="text" class="search-field" name="search" placeholder="Search...">
                    </div>
                </div>
                <div class="nav-item2 header-item">
                    <ul class="nav">
                        <li class="nav-item">New</li>
                        <li class="nav-item">Home</li>
                        <li class="nav-item">Explore</li>
                    </ul>
                </div>
                <div class="nav-item3 header-item">
                    <div class="sign">
                        <div class="sign-in">Sign In</div>
                        <div class="sign-up">Sign Up</div>
                    </div>
                </div>

            </div>
        </div>


问:
Applying a function to a column in a pandas dataframe
So I have a function replaceMonth(string), which is just a series of if statements that returns a string derived from a column in a pandas dataframe. Then I need to replace the original string with the derived one.

The dataframe is defined like this:

```<code>Index    ID        Year  DSFS           DrugCount
0        111111    Y1    3- 4 months    1
</code>```

There are around 80K rows in the dataframe. What I need to do is to replace what is in column DSFS with the result from the replaceMonth(string) function.

So if, for example, the value in the first row of DSFS was '3-4 months', if I ran that string through replaceMonth() it would give me '_3_4' as the return value. Then I need to change the value in the dataframe from the '3- 4 months' to '_3_4'.

I've been trying to use apply on the dataframe but I'm either getting the syntax wrong or not understanding what it's doing correctly, like this:

```<code>dataframe['DSFS'].apply(replaceMonth(dataframe['DSFS']))
</code>```

That doesn't ring right to me but I'm not sure where I'm messing up on it. I'm fairly new to Python so it's probably the syntax. :)

Any help is greatly appreciated!

答:
When you apply you pass the function that you want applied to each element.

Try

```<code>dataframe['DSFS'].apply(replaceMonth)
</code>```

Reassign to the dataframe to preserve the changes

```<code>dataframe['DSFS'] = dataframe['DSFS'].apply(replaceMonth)
</code>```

Body:
So I have a function replaceMonth(string), which is just a series of if statements that returns a string derived from a column in a pandas dataframe. Then I need to replace the original string with the derived one.

The dataframe is defined like this:

Index    ID        Year  DSFS           DrugCount
0        111111    Y1    3- 4 months    1

There are around 80K rows in the dataframe. What I need to do is to replace what is in column DSFS with the result from the replaceMonth(string) function.

So if, for example, the value in the first row of DSFS was '3-4 months', if I ran that string through replaceMonth() it would give me '_3_4' as the return value. Then I need to change the value in the dataframe from the '3- 4 months' to '_3_4'.

I've been trying to use apply on the dataframe but I'm either getting the syntax wrong or not understanding what it's doing correctly, like this:

dataframe['DSFS'].apply(replaceMonth(dataframe['DSFS']))

That doesn't ring right to me but I'm not sure where I'm messing up on it. I'm fairly new to Python so it's probably the syntax. :)

Any help is greatly appreciated!

Body:
When you apply you pass the function that you want applied to each element.

Try

dataframe['DSFS'].apply(replaceMonth)

Reassign to the dataframe to preserve the changes

dataframe['DSFS'] = dataframe['DSFS'].apply(replaceMonth)


问:
How to create a conversion of Fahrenheit to Celsius in java
The code should output a table for Fahrenheit and Celsius:

```<code>public static void main(String[] args) {
    System.out.println("Fahrenheit\tCelsius");
    System.out.println("=======================");
     for(int temp = -45; temp <= 120; temp += 5) //for(int i = 0; i <= 100; i+= 10)
        {
            System.out.printf("%5d       |", temp);
            double sum = (temp + (9.0/5.0)) * 32;
            System.out.printf("%5d", (int) sum );
            System.out.println();
        }
}
</code>```

答:
You need to make two changes:

Remove cast to int (as it makes the value lose precision)

Use ".1f" in printf (as you need to print decimal number and not int)

Below should work:

```<code>System.out.printf("%10.1f", sum );
</code>```

Body:
The code should output a table for Fahrenheit and Celsius:

public static void main(String[] args) {
    System.out.println("Fahrenheit\tCelsius");
    System.out.println("=======================");
     for(int temp = -45; temp <= 120; temp += 5) //for(int i = 0; i <= 100; i+= 10)
        {
            System.out.printf("%5d       |", temp);
            double sum = (temp + (9.0/5.0)) * 32;
            System.out.printf("%5d", (int) sum );
            System.out.println();
        }
}

Body:
You need to make two changes:

Remove cast to int (as it makes the value lose precision)

Use ".1f" in printf (as you need to print decimal number and not int)

Below should work:

System.out.printf("%10.1f", sum );


问:
[CompletionException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException]
I tried to add some mappings to my Administrator.java class and that start to give me errors for when I clicked the login button, regardless of what user is logging in or if the credentials are correct or not. Prior to adding the extra functionality everything worked fine.

Stack Trace:

```<code>[error] o.j.ConnectionLogger - java.sql.Connection.prepareStatement:
throws exception: org.h2.jdbc.JdbcSQLException: Ambiguous column name "ID"; SQL statement:
select t0.role c0, t0.email c1, t0.role c2, t0.name c3, t0.password c4, t1.id c5, t0.department c6, t0.street1 c7, t0.street2 c8, t0.town c9, t0.post_code c10, t1.id c11, t2.id c12 from user t0 left outer join stock_basket t1 on t1.administrator_email = t0.email  left outer join basket t1 on t1.customer_email = t0.email  left outer join credit_card t2 on t2.customer_email = t0.email  where t0.email = ?  and t0.password = ?  [90059-191]
org.h2.jdbc.JdbcSQLException: Ambiguous column name "ID"; SQL statement:
select t0.role c0, t0.email c1, t0.role c2, t0.name c3, t0.password c4, t1.id c5, t0.department c6, t0.street1 c7, t0.street2 c8, t0.town c9, t0.post_code c10, t1.id c11, t2.id c12 from user t0 left outer join stock_basket t1 on t1.administrator_email = t0.email  left outer join basket t1 on t1.customer_email = t0.email  left outer join credit_card t2 on t2.customer_email = t0.email  where t0.email = ?  and t0.password = ?  [90059-191]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
        at org.h2.message.DbException.get(DbException.java:179)
        at org.h2.message.DbException.get(DbException.java:155)
        at org.h2.expression.ExpressionColumn.mapColumn(ExpressionColumn.java:124)
        at org.h2.expression.ExpressionColumn.mapColumns(ExpressionColumn.java:94)
        at org.h2.expression.Alias.mapColumns(Alias.java:46)
        at org.h2.command.dml.Select.mapColumns(Select.java:1228)
        at org.h2.command.dml.Select.init(Select.java:827)
        at org.h2.command.Parser.parseSelect(Parser.java:1693)
        at org.h2.command.Parser.parsePrepared(Parser.java:443)
[error] application -

! @73gmcki3k - Internal server error, for (POST) [/login] ->

play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[CompletionException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException]]
        at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:280)
        at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:206)
        at play.api.GlobalSettings$class.onError(GlobalSettings.scala:160)
        at play.api.DefaultGlobal$.onError(GlobalSettings.scala:188)
        at play.api.http.GlobalSettingsHttpErrorHandler.onServerError(HttpErrorHandler.scala:98)
        at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:100)
        at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:99)
        at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:344)
        at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:343)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
Caused by: java.util.concurrent.CompletionException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
        at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)
        at java.util.concurrent.CompletableFuture.uniApply(Unknown Source)
        at java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
        at java.util.concurrent.CompletableFuture.postComplete(Unknown Source)
        at java.util.concurrent.CompletableFuture.completeExceptionally(Unknown Source)
        at scala.concurrent.java8.FuturesConvertersImpl$CF.apply(FutureConvertersImpl.scala:21)
        at scala.concurrent.java8.FuturesConvertersImpl$CF.apply(FutureConvertersImpl.scala:18)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
        at scala.concurrent.BatchingExecutor$Batch$$anonfun$run$1.processBatch$1(BatchingExecutor.scala:63)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at play.data.Form.bind(Form.java:425)
        at play.data.Form.bindFromRequest(Form.java:234)
        at controllers.security.LoginCtrl.loginSubmit(LoginCtrl.java:35)
        at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$4$$anonfun$apply$4.apply(Routes.scala:900)
        at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$4$$anonfun$apply$4.apply(Routes.scala:900)
        at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:157)
        at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:156)
        at play.core.routing.HandlerInvokerFactory$JavaActionInvokerFactory$$anon$14$$anon$3$$anon$1.invocation(HandlerInvoker.scala:136)
        at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:73)
        at play.http.HttpRequestHandler$1.call(HttpRequestHandler.java:54)
Caused by: java.lang.reflect.InvocationTargetException: null
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at play.data.Form.bind(Form.java:421)
        at play.data.Form.bindFromRequest(Form.java:234)
        at controllers.security.LoginCtrl.loginSubmit(LoginCtrl.java:35)
        at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$4$$anonfun$apply$4.apply(Routes.scala:900)
        at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$4$$anonfun$apply$4.apply(Routes.scala:900)
        at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:157)
Caused by: javax.persistence.PersistenceException: Query threw SQLException:Ambiguous column name "ID"; SQL statement:
select t0.role c0, t0.email c1, t0.role c2, t0.name c3, t0.password c4, t1.id c5, t0.department c6, t0.street1 c7, t0.street2 c8, t0.town c9, t0.post_code c10, t1.id c11, t2.id c12 from user t0 left outer join stock_basket t1 on t1.administrator_email = t0.email  left outer join basket t1 on t1.customer_email = t0.email  left outer join credit_card t2 on t2.customer_email = t0.email  where t0.email = ?  and t0.password = ?  [90059-191]
Bind values:[null]
Query was:
select t0.role c0, t0.email c1, t0.role c2, t0.name c3, t0.password c4, t1.id c5, t0.department c6, t0.street1 c7, t0.street2 c8, t0.town c9, t0.post_code c10, t1.id c11, t2.id c12 from user t0 left outer join stock_basket t1 on t1.administrator_email = t0.email  left outer join basket t1 on t1.customer_email = t0.email  left outer join credit_card t2 on t2.customer_email = t0.email  where t0.email = ?  and t0.password = ?

        at com.avaje.ebeaninternal.server.query.CQuery.createPersistenceException(CQuery.java:673)
        at com.avaje.ebeaninternal.server.query.CQuery.createPersistenceException(CQuery.java:653)
        at com.avaje.ebeaninternal.server.query.CQueryEngine.findMany(CQueryEngine.java:324)
        at com.avaje.ebeaninternal.server.query.DefaultOrmQueryEngine.findMany(DefaultOrmQueryEngine.java:94)
        at com.avaje.ebeaninternal.server.core.OrmQueryRequest.findList(OrmQueryRequest.java:347)
        at com.avaje.ebeaninternal.server.core.DefaultServer.findList(DefaultServer.java:1388)
        at com.avaje.ebeaninternal.server.core.DefaultServer.findUnique(DefaultServer.java:1138)
        at com.avaje.ebeaninternal.server.querydefn.DefaultOrmQuery.findUnique(DefaultOrmQuery.java:1104)
        at com.avaje.ebeaninternal.server.expression.DefaultExpressionList.findUnique(DefaultExpressionList.java:352)
        at models.users.User.authenticate(User.java:60)
Caused by: org.h2.jdbc.JdbcSQLException: Ambiguous column name "ID"; SQL statement:
select t0.role c0, t0.email c1, t0.role c2, t0.name c3, t0.password c4, t1.id c5, t0.department c6, t0.street1 c7, t0.street2 c8, t0.town c9, t0.post_code c10, t1.id c11, t2.id c12 from user t0 left outer join stock_basket t1 on t1.administrator_email = t0.email  left outer join basket t1 on t1.customer_email = t0.email  left outer join credit_card t2 on t2.customer_email = t0.email  where t0.email = ?  and t0.password = ?  [90059-191]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
        at org.h2.message.DbException.get(DbException.java:179)
        at org.h2.message.DbException.get(DbException.java:155)
        at org.h2.expression.ExpressionColumn.mapColumn(ExpressionColumn.java:124)
        at org.h2.expression.ExpressionColumn.mapColumns(ExpressionColumn.java:94)
        at org.h2.expression.Alias.mapColumns(Alias.java:46)
        at org.h2.command.dml.Select.mapColumns(Select.java:1228)
        at org.h2.command.dml.Select.init(Select.java:827)
        at org.h2.command.Parser.parseSelect(Parser.java:1693)
        at org.h2.command.Parser.parsePrepared(Parser.java:443)
</code>```

User class:

```<code>package models.users;

import java.util.*;
import javax.persistence.*;
import play.data.format.*;
import play.data.validation.*;
import com.avaje.ebean.*;

//https://www.playframework.com/documentation/2.2.x/JavaGuide4

// Product entity managed by Ebean
@Entity
// specify mapped table name
@Table(name = "user")
// Map inherited classes to a single table
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
// Discriminator column used to define user type
@DiscriminatorColumn(name = "role")
// This user type is user
@DiscriminatorValue("user")

public class User extends Model {

    //@Id
    //@GeneratedValue(strategy = GenerationType.IDENTITY)
    //public Long id;

    @Constraints.Required
    @Id
    private String email;

    @Column(insertable=false, updatable=false)
    private String role;

    @Constraints.Required
    private String name;

    @Constraints.Required
    private String password;

    // Default constructor
    public  User() {
    }
    // Constructor to initialise object
    public User(String email, String role, String name, String password) {
        this.email = email;
        this.role = role;
        this.name = name;
        this.password = password;
    }

    //Generic query helper for entity User with unique id String
    public static Finder<String,User> find = new Finder<String,User>(User.class);

    // Static method to authenticate based on username and password
    // Returns user object if found, otherwise NULL
    public static User authenticate(String email, String password) {
        // If found return the user object with matching username and password
        return find.where().eq("email", email).eq("password", password).findUnique();
    }

    // Check if a user is logged in (by id - email address)
    public static User getLoggedIn(String id) {
        if (id == null) {
            return null;
        } else {
            // Find user by id and return object
            return find.byId(id);
        }
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public String getRole() {
        return role;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

}
</code>```

Admin class:

```<code>package models.users;

import models.products.Category;
import models.products.Review;
import models.shopping.Basket;
import models.shopping.ShopOrder;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

import models.stock.StockBasket;
import models.stock.StockOrder;
import play.data.validation.*;

@Entity
// This is a User of type admin
@DiscriminatorValue("admin")

// Administrator inherits from the User class
public class Administrator extends User {

    @OneToOne(mappedBy = "administrator", cascade = CascadeType.ALL)
    private StockBasket basket;

    @OneToMany(mappedBy = "administrator", cascade = CascadeType.ALL)
    private List<StockOrder> orders;

    public Administrator() {

    }

    public Administrator(String email, String role, String name, String password)
    {
        super(email, role, name, password);
    }

    public StockBasket getBasket() {
        return basket;
    }

    public void setBasket(StockBasket basket) {
        this.basket = basket;
    }

    public List<StockOrder> getOrders() {
        return orders;
    }

    public void setOrders(List<StockOrder> orders) {
        this.orders = orders;
    }
}
</code>```

答:
You gave stock_basket and basket the same alias (t1) in the query.

Change one alias to t3, and this should work:

```<code>select t0.role c0, t0.email c1, t0.role c2, t0.name c3, t0.password c4, t1.id c5,
    t0.department c6, t0.street1 c7, t0.street2 c8, t0.town c9, t0.post_code c10, t3.id c11, t2.id c12
from user t0
left outer join stock_basket t1 on t1.administrator_email = t0.email
left outer join basket t3 on t3.customer_email = t0.email
left outer join credit_card t2 on t2.customer_email = t0.email
</code>```

This is one of the reasons it's easier to use aliases that can be identified back to the table names instead of t1, t2, etc.

Body:
I tried to add some mappings to my Administrator.java class and that start to give me errors for when I clicked the login button, regardless of what user is logging in or if the credentials are correct or not. Prior to adding the extra functionality everything worked fine.

Stack Trace:

[error] o.j.ConnectionLogger - java.sql.Connection.prepareStatement:
throws exception: org.h2.jdbc.JdbcSQLException: Ambiguous column name "ID"; SQL statement:
select t0.role c0, t0.email c1, t0.role c2, t0.name c3, t0.password c4, t1.id c5, t0.department c6, t0.street1 c7, t0.street2 c8, t0.town c9, t0.post_code c10, t1.id c11, t2.id c12 from user t0 left outer join stock_basket t1 on t1.administrator_email = t0.email  left outer join basket t1 on t1.customer_email = t0.email  left outer join credit_card t2 on t2.customer_email = t0.email  where t0.email = ?  and t0.password = ?  [90059-191]
org.h2.jdbc.JdbcSQLException: Ambiguous column name "ID"; SQL statement:
select t0.role c0, t0.email c1, t0.role c2, t0.name c3, t0.password c4, t1.id c5, t0.department c6, t0.street1 c7, t0.street2 c8, t0.town c9, t0.post_code c10, t1.id c11, t2.id c12 from user t0 left outer join stock_basket t1 on t1.administrator_email = t0.email  left outer join basket t1 on t1.customer_email = t0.email  left outer join credit_card t2 on t2.customer_email = t0.email  where t0.email = ?  and t0.password = ?  [90059-191]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
        at org.h2.message.DbException.get(DbException.java:179)
        at org.h2.message.DbException.get(DbException.java:155)
        at org.h2.expression.ExpressionColumn.mapColumn(ExpressionColumn.java:124)
        at org.h2.expression.ExpressionColumn.mapColumns(ExpressionColumn.java:94)
        at org.h2.expression.Alias.mapColumns(Alias.java:46)
        at org.h2.command.dml.Select.mapColumns(Select.java:1228)
        at org.h2.command.dml.Select.init(Select.java:827)
        at org.h2.command.Parser.parseSelect(Parser.java:1693)
        at org.h2.command.Parser.parsePrepared(Parser.java:443)
[error] application -

! @73gmcki3k - Internal server error, for (POST) [/login] ->

play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[CompletionException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException]]
        at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:280)
        at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:206)
        at play.api.GlobalSettings$class.onError(GlobalSettings.scala:160)
        at play.api.DefaultGlobal$.onError(GlobalSettings.scala:188)
        at play.api.http.GlobalSettingsHttpErrorHandler.onServerError(HttpErrorHandler.scala:98)
        at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:100)
        at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:99)
        at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:344)
        at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:343)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
Caused by: java.util.concurrent.CompletionException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
        at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)
        at java.util.concurrent.CompletableFuture.uniApply(Unknown Source)
        at java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
        at java.util.concurrent.CompletableFuture.postComplete(Unknown Source)
        at java.util.concurrent.CompletableFuture.completeExceptionally(Unknown Source)
        at scala.concurrent.java8.FuturesConvertersImpl$CF.apply(FutureConvertersImpl.scala:21)
        at scala.concurrent.java8.FuturesConvertersImpl$CF.apply(FutureConvertersImpl.scala:18)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
        at scala.concurrent.BatchingExecutor$Batch$$anonfun$run$1.processBatch$1(BatchingExecutor.scala:63)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at play.data.Form.bind(Form.java:425)
        at play.data.Form.bindFromRequest(Form.java:234)
        at controllers.security.LoginCtrl.loginSubmit(LoginCtrl.java:35)
        at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$4$$anonfun$apply$4.apply(Routes.scala:900)
        at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$4$$anonfun$apply$4.apply(Routes.scala:900)
        at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:157)
        at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:156)
        at play.core.routing.HandlerInvokerFactory$JavaActionInvokerFactory$$anon$14$$anon$3$$anon$1.invocation(HandlerInvoker.scala:136)
        at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:73)
        at play.http.HttpRequestHandler$1.call(HttpRequestHandler.java:54)
Caused by: java.lang.reflect.InvocationTargetException: null
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at play.data.Form.bind(Form.java:421)
        at play.data.Form.bindFromRequest(Form.java:234)
        at controllers.security.LoginCtrl.loginSubmit(LoginCtrl.java:35)
        at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$4$$anonfun$apply$4.apply(Routes.scala:900)
        at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$4$$anonfun$apply$4.apply(Routes.scala:900)
        at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:157)
Caused by: javax.persistence.PersistenceException: Query threw SQLException:Ambiguous column name "ID"; SQL statement:
select t0.role c0, t0.email c1, t0.role c2, t0.name c3, t0.password c4, t1.id c5, t0.department c6, t0.street1 c7, t0.street2 c8, t0.town c9, t0.post_code c10, t1.id c11, t2.id c12 from user t0 left outer join stock_basket t1 on t1.administrator_email = t0.email  left outer join basket t1 on t1.customer_email = t0.email  left outer join credit_card t2 on t2.customer_email = t0.email  where t0.email = ?  and t0.password = ?  [90059-191]
Bind values:[null]
Query was:
select t0.role c0, t0.email c1, t0.role c2, t0.name c3, t0.password c4, t1.id c5, t0.department c6, t0.street1 c7, t0.street2 c8, t0.town c9, t0.post_code c10, t1.id c11, t2.id c12 from user t0 left outer join stock_basket t1 on t1.administrator_email = t0.email  left outer join basket t1 on t1.customer_email = t0.email  left outer join credit_card t2 on t2.customer_email = t0.email  where t0.email = ?  and t0.password = ?

        at com.avaje.ebeaninternal.server.query.CQuery.createPersistenceException(CQuery.java:673)
        at com.avaje.ebeaninternal.server.query.CQuery.createPersistenceException(CQuery.java:653)
        at com.avaje.ebeaninternal.server.query.CQueryEngine.findMany(CQueryEngine.java:324)
        at com.avaje.ebeaninternal.server.query.DefaultOrmQueryEngine.findMany(DefaultOrmQueryEngine.java:94)
        at com.avaje.ebeaninternal.server.core.OrmQueryRequest.findList(OrmQueryRequest.java:347)
        at com.avaje.ebeaninternal.server.core.DefaultServer.findList(DefaultServer.java:1388)
        at com.avaje.ebeaninternal.server.core.DefaultServer.findUnique(DefaultServer.java:1138)
        at com.avaje.ebeaninternal.server.querydefn.DefaultOrmQuery.findUnique(DefaultOrmQuery.java:1104)
        at com.avaje.ebeaninternal.server.expression.DefaultExpressionList.findUnique(DefaultExpressionList.java:352)
        at models.users.User.authenticate(User.java:60)
Caused by: org.h2.jdbc.JdbcSQLException: Ambiguous column name "ID"; SQL statement:
select t0.role c0, t0.email c1, t0.role c2, t0.name c3, t0.password c4, t1.id c5, t0.department c6, t0.street1 c7, t0.street2 c8, t0.town c9, t0.post_code c10, t1.id c11, t2.id c12 from user t0 left outer join stock_basket t1 on t1.administrator_email = t0.email  left outer join basket t1 on t1.customer_email = t0.email  left outer join credit_card t2 on t2.customer_email = t0.email  where t0.email = ?  and t0.password = ?  [90059-191]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
        at org.h2.message.DbException.get(DbException.java:179)
        at org.h2.message.DbException.get(DbException.java:155)
        at org.h2.expression.ExpressionColumn.mapColumn(ExpressionColumn.java:124)
        at org.h2.expression.ExpressionColumn.mapColumns(ExpressionColumn.java:94)
        at org.h2.expression.Alias.mapColumns(Alias.java:46)
        at org.h2.command.dml.Select.mapColumns(Select.java:1228)
        at org.h2.command.dml.Select.init(Select.java:827)
        at org.h2.command.Parser.parseSelect(Parser.java:1693)
        at org.h2.command.Parser.parsePrepared(Parser.java:443)

User class:

package models.users;

import java.util.*;
import javax.persistence.*;
import play.data.format.*;
import play.data.validation.*;
import com.avaje.ebean.*;

//https://www.playframework.com/documentation/2.2.x/JavaGuide4

// Product entity managed by Ebean
@Entity
// specify mapped table name
@Table(name = "user")
// Map inherited classes to a single table
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
// Discriminator column used to define user type
@DiscriminatorColumn(name = "role")
// This user type is user
@DiscriminatorValue("user")

public class User extends Model {

    //@Id
    //@GeneratedValue(strategy = GenerationType.IDENTITY)
    //public Long id;

    @Constraints.Required
    @Id
    private String email;

    @Column(insertable=false, updatable=false)
    private String role;

    @Constraints.Required
    private String name;

    @Constraints.Required
    private String password;

    // Default constructor
    public  User() {
    }
    // Constructor to initialise object
    public User(String email, String role, String name, String password) {
        this.email = email;
        this.role = role;
        this.name = name;
        this.password = password;
    }

    //Generic query helper for entity User with unique id String
    public static Finder<String,User> find = new Finder<String,User>(User.class);

    // Static method to authenticate based on username and password
    // Returns user object if found, otherwise NULL
    public static User authenticate(String email, String password) {
        // If found return the user object with matching username and password
        return find.where().eq("email", email).eq("password", password).findUnique();
    }

    // Check if a user is logged in (by id - email address)
    public static User getLoggedIn(String id) {
        if (id == null) {
            return null;
        } else {
            // Find user by id and return object
            return find.byId(id);
        }
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public String getRole() {
        return role;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

}

Admin class:

package models.users;

import models.products.Category;
import models.products.Review;
import models.shopping.Basket;
import models.shopping.ShopOrder;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

import models.stock.StockBasket;
import models.stock.StockOrder;
import play.data.validation.*;

@Entity
// This is a User of type admin
@DiscriminatorValue("admin")

// Administrator inherits from the User class
public class Administrator extends User {

    @OneToOne(mappedBy = "administrator", cascade = CascadeType.ALL)
    private StockBasket basket;

    @OneToMany(mappedBy = "administrator", cascade = CascadeType.ALL)
    private List<StockOrder> orders;

    public Administrator() {

    }

    public Administrator(String email, String role, String name, String password)
    {
        super(email, role, name, password);
    }

    public StockBasket getBasket() {
        return basket;
    }

    public void setBasket(StockBasket basket) {
        this.basket = basket;
    }

    public List<StockOrder> getOrders() {
        return orders;
    }

    public void setOrders(List<StockOrder> orders) {
        this.orders = orders;
    }
}

Body:
You gave stock_basket and basket the same alias (t1) in the query.

Change one alias to t3, and this should work:

select t0.role c0, t0.email c1, t0.role c2, t0.name c3, t0.password c4, t1.id c5,
    t0.department c6, t0.street1 c7, t0.street2 c8, t0.town c9, t0.post_code c10, t3.id c11, t2.id c12
from user t0
left outer join stock_basket t1 on t1.administrator_email = t0.email
left outer join basket t3 on t3.customer_email = t0.email
left outer join credit_card t2 on t2.customer_email = t0.email

This is one of the reasons it's easier to use aliases that can be identified back to the table names instead of t1, t2, etc.


问:
Hide vertical scrollbar in javafx Listview
I've tried for several hours now and can't seem to find the answer anywhere. I have 2 issues relating to the same listview, 1 more serious than the other.

I am trying to match a design provided to me in java. The list view should look like the below

This is from the design

Currently I have got as far as

My current endeavour

I have created a Custom ListCell to hold all of the views (not yet refactored so may look a little untidy)

```<code>import HolderClasses.MenuItem;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;

public class CustomListCell extends ListCell<MenuItem>{

    private Image mImage;
    private String mText;
    private AnchorPane background;
    private ImageView imageHolder;
    private VBox colourStrip;
    private Label mTextLabel;

    public CustomListCell(){

        background = new AnchorPane();
        imageHolder = new ImageView();
        mTextLabel = new Label();
        imageHolder.setFitHeight(40.0);
        imageHolder.setFitWidth(40.0);
        imageHolder.getStyleClass().add("listCellImage");
        mTextLabel.getStyleClass().add("listCellText");
        AnchorPane.setLeftAnchor(imageHolder, 10.0);
        AnchorPane.setTopAnchor(imageHolder, 10.0);
        AnchorPane.setBottomAnchor(imageHolder, 10.0);
        AnchorPane.setLeftAnchor(mTextLabel, 80.0);
        AnchorPane.setRightAnchor(mTextLabel, 1.0);
        AnchorPane.setTopAnchor(mTextLabel, 0.0);
        AnchorPane.setBottomAnchor(mTextLabel, 0.0);
        colourStrip = new VBox();
        colourStrip.setMinWidth(0.0);
        colourStrip.setMaxWidth(2.0);
        colourStrip.setPrefWidth(2.0);
        colourStrip.getStyleClass().add("listCellColourStrip");
        AnchorPane.setRightAnchor(colourStrip, 0.0);
        AnchorPane.setTopAnchor(colourStrip, 0.0);
        AnchorPane.setBottomAnchor(colourStrip, 0.0);

        background.getChildren().addAll(mTextLabel, imageHolder, colourStrip);

    }

    @Override
    protected void updateItem(MenuItem item, boolean empty) {
        super.updateItem(item, empty);
        if (empty || item == null) {
            //remove all the views
            setText(null);
            setGraphic(null);
        } else {
            //set all the views
            imageHolder.setImage(item.getImage());
            mTextLabel.setText(item.getText());
            setText(null);
            setGraphic(background);
        }
    }

}
</code>```

and my CSS is

```<code>.list-cell {

    -fx-background-color: #FCFCFC;
    -fx-background-insets: 0 0 1 0;
}

.list-cell:empty {
    -fx-background-color: #FCFCFC;
    -fx-background-insets: 0 ;
}

.list-cell:selected .listCellColourStrip{

    -fx-background-color: #CF000F;

}

.list-cell:selected {

    -fx-background-color: #FFFFFF;

}

.list-view .scroll-bar:vertical .increment-arrow,
.list-view .scroll-bar:vertical .decrement-arrow,
.list-view .scroll-bar:vertical .increment-button,
.list-view .scroll-bar:vertical .decrement-button {
    -fx-padding: 0px;
}

.list-view .scroll-bar:vertical {
    -fx-padding: 0px;
}

.listCellImage {
    -fx-opacity: 0.4;
}

.listCellText{
    -fx-font-size: 1.5em;
    -fx-text-fill: #888;
    -fx-font-family: "Museo Sans 500";
}
</code>```

In a nutshell I have managed to remove the scrollbar but the space the scrollbar occupied still seems to be taken up after it has disappeared and I can't for the life of me get the red bar to show at the very end of the cell.

The original design had inspiration from an android listview where the scrollbar is placed on top of the content and the thumb is semi-opaque when scrolling and invisible when not. I would ideally like to achieve this as well although no scrollbar would be an acceptable compromise if the red line can be placed at the end.

I have explored using a ScrollPane and standard AnchorPane's instead of a ListView to no avail and decided to try again with the ListView. But i'm open to any solution that achieves the desired even if this means ripping up the ListView again.

Any help you could give would be appreciated.

sorry if my question is incorrectly formatted i'm a newbie :)

Thanks

答:
Change

```<code>.list-view .scroll-bar:vertical {
   -fx-padding: 0px;
}
</code>```

to

```<code>.list-view .scroll-bar:vertical {
    -fx-scale-x: 0;
}
</code>```

And if you want disable move between items:

```<code>listview.setMouseTransparent( true );
listview.setFocusTraversable( false );
</code>```

Body:
I've tried for several hours now and can't seem to find the answer anywhere. I have 2 issues relating to the same listview, 1 more serious than the other.

I am trying to match a design provided to me in java. The list view should look like the below

This is from the design

Currently I have got as far as

My current endeavour

I have created a Custom ListCell to hold all of the views (not yet refactored so may look a little untidy)

import HolderClasses.MenuItem;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;

public class CustomListCell extends ListCell<MenuItem>{

    private Image mImage;
    private String mText;
    private AnchorPane background;
    private ImageView imageHolder;
    private VBox colourStrip;
    private Label mTextLabel;

    public CustomListCell(){

        background = new AnchorPane();
        imageHolder = new ImageView();
        mTextLabel = new Label();
        imageHolder.setFitHeight(40.0);
        imageHolder.setFitWidth(40.0);
        imageHolder.getStyleClass().add("listCellImage");
        mTextLabel.getStyleClass().add("listCellText");
        AnchorPane.setLeftAnchor(imageHolder, 10.0);
        AnchorPane.setTopAnchor(imageHolder, 10.0);
        AnchorPane.setBottomAnchor(imageHolder, 10.0);
        AnchorPane.setLeftAnchor(mTextLabel, 80.0);
        AnchorPane.setRightAnchor(mTextLabel, 1.0);
        AnchorPane.setTopAnchor(mTextLabel, 0.0);
        AnchorPane.setBottomAnchor(mTextLabel, 0.0);
        colourStrip = new VBox();
        colourStrip.setMinWidth(0.0);
        colourStrip.setMaxWidth(2.0);
        colourStrip.setPrefWidth(2.0);
        colourStrip.getStyleClass().add("listCellColourStrip");
        AnchorPane.setRightAnchor(colourStrip, 0.0);
        AnchorPane.setTopAnchor(colourStrip, 0.0);
        AnchorPane.setBottomAnchor(colourStrip, 0.0);

        background.getChildren().addAll(mTextLabel, imageHolder, colourStrip);

    }

    @Override
    protected void updateItem(MenuItem item, boolean empty) {
        super.updateItem(item, empty);
        if (empty || item == null) {
            //remove all the views
            setText(null);
            setGraphic(null);
        } else {
            //set all the views
            imageHolder.setImage(item.getImage());
            mTextLabel.setText(item.getText());
            setText(null);
            setGraphic(background);
        }
    }

}

and my CSS is

.list-cell {

    -fx-background-color: #FCFCFC;
    -fx-background-insets: 0 0 1 0;
}

.list-cell:empty {
    -fx-background-color: #FCFCFC;
    -fx-background-insets: 0 ;
}

.list-cell:selected .listCellColourStrip{

    -fx-background-color: #CF000F;

}

.list-cell:selected {

    -fx-background-color: #FFFFFF;

}

.list-view .scroll-bar:vertical .increment-arrow,
.list-view .scroll-bar:vertical .decrement-arrow,
.list-view .scroll-bar:vertical .increment-button,
.list-view .scroll-bar:vertical .decrement-button {
    -fx-padding: 0px;
}

.list-view .scroll-bar:vertical {
    -fx-padding: 0px;
}

.listCellImage {
    -fx-opacity: 0.4;
}

.listCellText{
    -fx-font-size: 1.5em;
    -fx-text-fill: #888;
    -fx-font-family: "Museo Sans 500";
}

In a nutshell I have managed to remove the scrollbar but the space the scrollbar occupied still seems to be taken up after it has disappeared and I can't for the life of me get the red bar to show at the very end of the cell.

The original design had inspiration from an android listview where the scrollbar is placed on top of the content and the thumb is semi-opaque when scrolling and invisible when not. I would ideally like to achieve this as well although no scrollbar would be an acceptable compromise if the red line can be placed at the end.

I have explored using a ScrollPane and standard AnchorPane's instead of a ListView to no avail and decided to try again with the ListView. But i'm open to any solution that achieves the desired even if this means ripping up the ListView again.

Any help you could give would be appreciated.

sorry if my question is incorrectly formatted i'm a newbie :)

Thanks

Body:
Change

.list-view .scroll-bar:vertical {
   -fx-padding: 0px;
}

to

.list-view .scroll-bar:vertical {
    -fx-scale-x: 0;
}

And if you want disable move between items:

listview.setMouseTransparent( true );
listview.setFocusTraversable( false );


问:
How do I join more than one files, in a Linq (C#) where one of the joins is a left join
My Sql below works great, but now I would like to join another file that has a common key. The file I would like to join has could have one to many records, any suggestions

here is my code:

```<code> var regPoints = (from x in db.CertPoints
                                 join y in db.CommunityPts on x.PointId equals y.PointId into z
                                 from t in
                                     (from r in z
                                      where r.CommunityId == id select r).DefaultIfEmpty()
                                 where x.TypeId == 1
                                 select new Points
                                 {
                                     pointId = x.PointId,
                                     pointsDescription = x.PointDescription,
                                     points = x.Points,
                                     dateApplied = t.DateApplied,
                                     pointsEarned = t.PointsEarned,
                                     pointsPending = t.Pending ? true : false,
                                     pointsApproved = t.Approved ? true : false,
                                     notes = t.Notes

                                 }).AsEnumerable();
</code>```

the new join would be a one to many records, where the key in CommunityPts is Id, and the file I would like to join is a list of file links "CommunityPtsDocs" with a foreign key CommnunityPtId. How do i add it to the above sql statement above?

答:
Following modification shall help in achieving the Task, though I prefer Fluent syntax, as that's much cleaner in my view to achieve the same, though I have not selected any column from CommunityPtsDocs in the Select statement

```<code>var regPoints = (from x in CertPoints
                 join y in CommunityPts on x.PointId equals y.PointId
                 join s in CommunityPtsDocs on y.Id equals s.CommnunityPtId into k
                 from t in (from r in k where r.CommunityId == id select r).DefaultIfEmpty()
                 where x.TypeId == 1
                                 select new Points
                                 {
                                     pointId = x.PointId,
                                     pointsDescription = x.PointDescription,
                                     points = x.Points,
                                     dateApplied = t.DateApplied,
                                     pointsEarned = t.PointsEarned,
                                     pointsPending = t.Pending ? true : false,
                                     pointsApproved = t.Approved ? true : false,
                                     notes = t.Notes

                                 }).AsEnumerable();
</code>```

Body:
My Sql below works great, but now I would like to join another file that has a common key. The file I would like to join has could have one to many records, any suggestions

here is my code:

 var regPoints = (from x in db.CertPoints
                                 join y in db.CommunityPts on x.PointId equals y.PointId into z
                                 from t in
                                     (from r in z
                                      where r.CommunityId == id select r).DefaultIfEmpty()
                                 where x.TypeId == 1
                                 select new Points
                                 {
                                     pointId = x.PointId,
                                     pointsDescription = x.PointDescription,
                                     points = x.Points,
                                     dateApplied = t.DateApplied,
                                     pointsEarned = t.PointsEarned,
                                     pointsPending = t.Pending ? true : false,
                                     pointsApproved = t.Approved ? true : false,
                                     notes = t.Notes

                                 }).AsEnumerable();

the new join would be a one to many records, where the key in CommunityPts is Id, and the file I would like to join is a list of file links "CommunityPtsDocs" with a foreign key CommnunityPtId. How do i add it to the above sql statement above?

Body:
Following modification shall help in achieving the Task, though I prefer Fluent syntax, as that's much cleaner in my view to achieve the same, though I have not selected any column from CommunityPtsDocs in the Select statement

var regPoints = (from x in CertPoints
                 join y in CommunityPts on x.PointId equals y.PointId
                 join s in CommunityPtsDocs on y.Id equals s.CommnunityPtId into k
                 from t in (from r in k where r.CommunityId == id select r).DefaultIfEmpty()
                 where x.TypeId == 1
                                 select new Points
                                 {
                                     pointId = x.PointId,
                                     pointsDescription = x.PointDescription,
                                     points = x.Points,
                                     dateApplied = t.DateApplied,
                                     pointsEarned = t.PointsEarned,
                                     pointsPending = t.Pending ? true : false,
                                     pointsApproved = t.Approved ? true : false,
                                     notes = t.Notes

                                 }).AsEnumerable();


问:
Execution Failed for task :app:compileDebugJavaWithJavac in Android Studio
I am developing an Android App in Android Studio. Not quite sure what went wrong. I was successfully building a few days ago. Any help would be great.

Here is the error:

```<code>Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
</code>```

Here is my build.gradle

```<code>apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "21.1.2"

defaultConfig {
    multiDexEnabled true
    applicationId "com.tubbs.citychurchob"
    minSdkVersion 14
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'),        'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.parse.bolts:bolts-android:1+'
compile 'com.android.support:recyclerview-v7:23.1.0'
}
</code>```

答: I faced a similar problem, but I had to set manually the jdk folder on program files, so I recommend to everybody specially the ones that are upgrading to java 8, to point directly in the project settings of the android studio, either using the embed option or choosing the folder</p>

Body:
I am developing an Android App in Android Studio. Not quite sure what went wrong. I was successfully building a few days ago. Any help would be great.

Here is the error:

Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

Here is my build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "21.1.2"

defaultConfig {
    multiDexEnabled true
    applicationId "com.tubbs.citychurchob"
    minSdkVersion 14
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'),        'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.parse.bolts:bolts-android:1+'
compile 'com.android.support:recyclerview-v7:23.1.0'
}