问:
Max post size ignored by Wildfly 10
I have a problem with uploading files larger than 10MB on Wildfly 10.0.0.Final. Here you have my standalone.xml file

```<code><subsystem xmlns="urn:jboss:domain:undertow:3.0">
            <buffer-cache name="default" />
            <server name="default-server">
                <http-listener name="default" socket-binding="http"
                    redirect-socket="https" max-post-size="31457280"/>
                <https-listener name="default-ssl" security-realm="SSLRealm"
                    socket-binding="https" max-post-size="31457280"/>
                <host name="default-host" alias="localhost">
                    <location name="/" handler="welcome-content" />
<!--                    <filter-ref name="server-header" /> -->
<!--                    <filter-ref name="x-powered-by-header" /> -->
                </host>
            </server>
            <servlet-container name="default">
                <jsp-config />
                <websockets />
            </servlet-container>
            <handlers>
                <file name="welcome-content" path="${jboss.home.dir}/welcome-content" />
            </handlers>
            <filters>
                <response-header name="server-header" header-name="Server"
                    header-value="WildFly/10" />
                <response-header name="x-powered-by-header"
                    header-name="X-Powered-By" header-value="Undertow/1" />
            </filters>
        </subsystem>
</code>```

And here it is the exception I get when I try to upload a file larger than 10MB:

```<code>2017-07-04 10:59:28,496 ERROR [org.springframework.boot.context.web.ErrorPageFilter] (default task-24) Forwarding to error page from request [/manuals] due to exception [java.io.IOException: UT000020: Connection terminated as request was larger than 10485760]: java.lang.RuntimeException: java.io.IOException: UT000020: Connection terminated as request was larger than 10485760
    at io.undertow.servlet.spec.HttpServletRequestImpl.parseFormData(HttpServletRequestImpl.java:764)
    at io.undertow.servlet.spec.HttpServletRequestImpl.getParameter(HttpServletRequestImpl.java:636)
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:70)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:120)
    at org.springframework.boot.context.web.ErrorPageFilter.access$000(ErrorPageFilter.java:61)
    at org.springframework.boot.context.web.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:95)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:113)
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
    at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
    at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: UT000020: Connection terminated as request was larger than 10485760
    at io.undertow.conduits.FixedLengthStreamSourceConduit.checkMaxSize(FixedLengthStreamSourceConduit.java:168)
    at io.undertow.conduits.FixedLengthStreamSourceConduit.read(FixedLengthStreamSourceConduit.java:229)
    at org.xnio.conduits.ConduitStreamSourceChannel.read(ConduitStreamSourceChannel.java:127)
    at io.undertow.channels.DetachableStreamSourceChannel.read(DetachableStreamSourceChannel.java:209)
    at io.undertow.server.HttpServerExchange$ReadDispatchChannel.read(HttpServerExchange.java:2231)
    at org.xnio.channels.Channels.readBlocking(Channels.java:294)
    at io.undertow.servlet.spec.ServletInputStreamImpl.readIntoBuffer(ServletInputStreamImpl.java:170)
    at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:146)
    at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:133)
    at io.undertow.server.handlers.form.MultiPartParserDefinition$MultiPartUploadHandler.parseBlocking(MultiPartParserDefinition.java:212)
    at io.undertow.servlet.spec.HttpServletRequestImpl.parseFormData(HttpServletRequestImpl.java:762)
    ... 43 more

2017-07-04 10:59:28,700 ERROR [org.springframework.boot.context.web.ErrorPageFilter] (default task-30) Forwarding to error page from request [/manuals] due to exception [java.io.IOException: UT000020: Connection terminated as request was larger than 10485760]: java.lang.RuntimeException: java.io.IOException: UT000020: Connection terminated as request was larger than 10485760
    at io.undertow.servlet.spec.HttpServletRequestImpl.parseFormData(HttpServletRequestImpl.java:764)
    at io.undertow.servlet.spec.HttpServletRequestImpl.getParameter(HttpServletRequestImpl.java:636)
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:70)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:120)
    at org.springframework.boot.context.web.ErrorPageFilter.access$000(ErrorPageFilter.java:61)
    at org.springframework.boot.context.web.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:95)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:113)
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
    at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
    at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: UT000020: Connection terminated as request was larger than 10485760
    at io.undertow.conduits.FixedLengthStreamSourceConduit.checkMaxSize(FixedLengthStreamSourceConduit.java:168)
    at io.undertow.conduits.FixedLengthStreamSourceConduit.read(FixedLengthStreamSourceConduit.java:229)
    at org.xnio.conduits.ConduitStreamSourceChannel.read(ConduitStreamSourceChannel.java:127)
    at io.undertow.channels.DetachableStreamSourceChannel.read(DetachableStreamSourceChannel.java:209)
    at io.undertow.server.HttpServerExchange$ReadDispatchChannel.read(HttpServerExchange.java:2231)
    at org.xnio.channels.Channels.readBlocking(Channels.java:294)
    at io.undertow.servlet.spec.ServletInputStreamImpl.readIntoBuffer(ServletInputStreamImpl.java:170)
    at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:146)
    at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:133)
    at io.undertow.server.handlers.form.MultiPartParserDefinition$MultiPartUploadHandler.parseBlocking(MultiPartParserDefinition.java:212)
    at io.undertow.servlet.spec.HttpServletRequestImpl.parseFormData(HttpServletRequestImpl.java:762)
    ... 43 more
</code>```

Why does Wildfly complains about the 10MB limit although the limit is set to 30MB in the configuration file?

答:
Solved.
It was a problem with the configuration of Spring and not of Wildfly. I leave this answer here in case it might be helpful for our descendants... :-)</p>

Title: Max post size ignored by Wildfly 10

Body:
I have a problem with uploading files larger than 10MB on Wildfly 10.0.0.Final. Here you have my standalone.xml file

<subsystem xmlns="urn:jboss:domain:undertow:3.0">
            <buffer-cache name="default" />
            <server name="default-server">
                <http-listener name="default" socket-binding="http"
                    redirect-socket="https" max-post-size="31457280"/>
                <https-listener name="default-ssl" security-realm="SSLRealm"
                    socket-binding="https" max-post-size="31457280"/>
                <host name="default-host" alias="localhost">
                    <location name="/" handler="welcome-content" />

                </host>
            </server>
            <servlet-container name="default">
                <jsp-config />
                <websockets />
            </servlet-container>
            <handlers>
                <file name="welcome-content" path="${jboss.home.dir}/welcome-content" />
            </handlers>
            <filters>
                <response-header name="server-header" header-name="Server"
                    header-value="WildFly/10" />
                <response-header name="x-powered-by-header"
                    header-name="X-Powered-By" header-value="Undertow/1" />
            </filters>
        </subsystem>

And here it is the exception I get when I try to upload a file larger than 10MB:

2017-07-04 10:59:28,496 ERROR [org.springframework.boot.context.web.ErrorPageFilter] (default task-24) Forwarding to error page from request [/manuals] due to exception [java.io.IOException: UT000020: Connection terminated as request was larger than 10485760]: java.lang.RuntimeException: java.io.IOException: UT000020: Connection terminated as request was larger than 10485760
    at io.undertow.servlet.spec.HttpServletRequestImpl.parseFormData(HttpServletRequestImpl.java:764)
    at io.undertow.servlet.spec.HttpServletRequestImpl.getParameter(HttpServletRequestImpl.java:636)
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:70)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:120)
    at org.springframework.boot.context.web.ErrorPageFilter.access$000(ErrorPageFilter.java:61)
    at org.springframework.boot.context.web.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:95)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:113)
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
    at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
    at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: UT000020: Connection terminated as request was larger than 10485760
    at io.undertow.conduits.FixedLengthStreamSourceConduit.checkMaxSize(FixedLengthStreamSourceConduit.java:168)
    at io.undertow.conduits.FixedLengthStreamSourceConduit.read(FixedLengthStreamSourceConduit.java:229)
    at org.xnio.conduits.ConduitStreamSourceChannel.read(ConduitStreamSourceChannel.java:127)
    at io.undertow.channels.DetachableStreamSourceChannel.read(DetachableStreamSourceChannel.java:209)
    at io.undertow.server.HttpServerExchange$ReadDispatchChannel.read(HttpServerExchange.java:2231)
    at org.xnio.channels.Channels.readBlocking(Channels.java:294)
    at io.undertow.servlet.spec.ServletInputStreamImpl.readIntoBuffer(ServletInputStreamImpl.java:170)
    at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:146)
    at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:133)
    at io.undertow.server.handlers.form.MultiPartParserDefinition$MultiPartUploadHandler.parseBlocking(MultiPartParserDefinition.java:212)
    at io.undertow.servlet.spec.HttpServletRequestImpl.parseFormData(HttpServletRequestImpl.java:762)
    ... 43 more

2017-07-04 10:59:28,700 ERROR [org.springframework.boot.context.web.ErrorPageFilter] (default task-30) Forwarding to error page from request [/manuals] due to exception [java.io.IOException: UT000020: Connection terminated as request was larger than 10485760]: java.lang.RuntimeException: java.io.IOException: UT000020: Connection terminated as request was larger than 10485760
    at io.undertow.servlet.spec.HttpServletRequestImpl.parseFormData(HttpServletRequestImpl.java:764)
    at io.undertow.servlet.spec.HttpServletRequestImpl.getParameter(HttpServletRequestImpl.java:636)
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:70)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:120)
    at org.springframework.boot.context.web.ErrorPageFilter.access$000(ErrorPageFilter.java:61)
    at org.springframework.boot.context.web.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:95)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:113)
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
    at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
    at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: UT000020: Connection terminated as request was larger than 10485760
    at io.undertow.conduits.FixedLengthStreamSourceConduit.checkMaxSize(FixedLengthStreamSourceConduit.java:168)
    at io.undertow.conduits.FixedLengthStreamSourceConduit.read(FixedLengthStreamSourceConduit.java:229)
    at org.xnio.conduits.ConduitStreamSourceChannel.read(ConduitStreamSourceChannel.java:127)
    at io.undertow.channels.DetachableStreamSourceChannel.read(DetachableStreamSourceChannel.java:209)
    at io.undertow.server.HttpServerExchange$ReadDispatchChannel.read(HttpServerExchange.java:2231)
    at org.xnio.channels.Channels.readBlocking(Channels.java:294)
    at io.undertow.servlet.spec.ServletInputStreamImpl.readIntoBuffer(ServletInputStreamImpl.java:170)
    at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:146)
    at io.undertow.servlet.spec.ServletInputStreamImpl.read(ServletInputStreamImpl.java:133)
    at io.undertow.server.handlers.form.MultiPartParserDefinition$MultiPartUploadHandler.parseBlocking(MultiPartParserDefinition.java:212)
    at io.undertow.servlet.spec.HttpServletRequestImpl.parseFormData(HttpServletRequestImpl.java:762)
    ... 43 more

Why does Wildfly complains about the 10MB limit although the limit is set to 30MB in the configuration file?


来源: stackexchange

问:
Null Value in bundle = this.getArguments() method
I want to send some data from main activity to it's child fragments class. I have used below code but still getting null value in getarguments() method. I have debugged also but no luck .

```<code>    setupToolbar();
    setupViewPager();
    setprofiledata();
    setupCollapsingToolbar();
    // setupDrawer();

private void setprofiledata() {
    String tag_string_req = "req_profile";

    pDialog.setMessage("Logging in ...");
    showDialog();

    StringRequest strReq = new StringRequest(Request.Method.POST,
            AppConfig.URL_LOGIN, new Response.Listener<String>() {

        @Override
        public void onResponse(String response) {
            Log.d("TAG", "Login Response: " + response.toString());
            hideDialog();
            Toast.makeText(Profile.this,"Login done",Toast.LENGTH_LONG).show();

            try {
                JSONObject jObj = new JSONObject(response);
                // boolean error = jObj.getBoolean("error");

                // Check for error node in json
            /*    if (!error) {*/
                // user successfully logged in
                // Create login session

                // Now store the user in SQLite
                //String uid = jObj.getString("uid");

                JSONObject user = jObj.getJSONObject("param");

                JSONObject jsonObject = user.getJSONObject("details");

                Log.d("Personal info",jsonObject.toString());

                String name = jsonObject.getString("Name");
                String email = jsonObject.getString("Email");
                String Contact = jsonObject.getString("Contact No.");
                String gender = jsonObject.getString("Gender");
                String Country =jsonObject.getString("Country");
                String City = jsonObject.getString("City");
                String State = jsonObject.getString("State");
                String Zip = jsonObject.getString("Zip");
                String Birth_Date = jsonObject.getString("Birth Date");
                String Status = jsonObject.getString("Status");
                String Connects_in= jsonObject.getString("Connects in");

                Bundle bundle = new Bundle();
                bundle.putString("name", name);
      // set Fragmentclass Arguments
                TabFragment tab1 = new TabFragment();
                tab1.setArguments(bundle);

            } catch (JSONException e) {
                // JSON error
                e.printStackTrace();
                Toast.makeText(getApplicationContext(), "Json error: " + e.getMessage(), Toast.LENGTH_LONG).show();
            }

        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e("TAG", "Login Error: " + error.getMessage());
            Toast.makeText(getApplicationContext(),
                    error.getMessage(), Toast.LENGTH_LONG).show();
            hideDialog();
        }
    }) {

        @Override
        protected Map<String, String> getParams() {
            // Posting parameters to login url
            Map<String, String> params = new HashMap<String, String>();
            params.put("visitor_id", "14");
            params.put("request","Dashboard_VisitorInfo");

            return params;
        }

    };

    // Adding request to request queue
    AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
}

 /*private void setupDrawer() {
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

}*/

private void setupCollapsingToolbar() {
    final CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(
            R.id.collapse_toolbar);

    collapsingToolbar.setTitleEnabled(false);
}

private void setupViewPager() {
  //  final ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
   viewPager = (ViewPager) findViewById(R.id.viewpager);
    setupViewPager(viewPager);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
}

private void setupToolbar() {
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle("TabbedCoordinatorLayout");
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

private void setupViewPager(ViewPager viewPager) {
    ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
    adapter.addFrag(new TabFragment(), "Personal");
    adapter.addFrag(new Tab1(), "Commnication");
    adapter.addFrag(new Tab2(), "Notes");

    viewPager.setAdapter(adapter);
}

static class ViewPagerAdapter extends FragmentPagerAdapter {

    private final List<Fragment> mFragmentList = new ArrayList<>();
    private final List<String> mFragmentTitleList = new ArrayList<>();

    public ViewPagerAdapter(FragmentManager manager) {
        super(manager);

    }

    @Override
    public Fragment getItem(int position) {
        return mFragmentList.get(position);
    }

    @Override
    public int getCount() {
        return mFragmentList.size();
    }

    public void addFrag(Fragment fragment, String title) {
        mFragmentList.add(fragment);
        mFragmentTitleList.add(title);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mFragmentTitleList.get(position);
    }
}
</code>```

And getting values in fregment class like this

```<code>    @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment, container, false);
    Bundle bundle = this.getArguments();
    nameedit = (EditText)view.findViewById(R.id.editnameid);
    if (bundle != null){
        String name=bundle.getString("name");

        nameedit.setText(name);
    }
</code>```

答:
You are passing arguments after network response but you are initialising the ViewPager Adapter prior to that. Because of which you are getting null in Fragment.

What you can do is simple get the fragment object from viewPagerAdapter and then set the Arguments to it.

use getItem(int position) method of view pager It would return you the fragment object and then assign Arguments to it.

ContentLicense: CC BY-SA 3.0

Body:
I want to send some data from main activity to it's child fragments class. I have used below code but still getting null value in getarguments() method. I have debugged also but no luck .

    setupToolbar();
    setupViewPager();
    setprofiledata();
    setupCollapsingToolbar();
    // setupDrawer();

private void setprofiledata() {
    String tag_string_req = "req_profile";

    pDialog.setMessage("Logging in ...");
    showDialog();

    StringRequest strReq = new StringRequest(Request.Method.POST,
            AppConfig.URL_LOGIN, new Response.Listener<String>() {

        @Override
        public void onResponse(String response) {
            Log.d("TAG", "Login Response: " + response.toString());
            hideDialog();
            Toast.makeText(Profile.this,"Login done",Toast.LENGTH_LONG).show();

            try {
                JSONObject jObj = new JSONObject(response);
                // boolean error = jObj.getBoolean("error");

                // Check for error node in json
            /*    if (!error) {*/
                // user successfully logged in
                // Create login session

                // Now store the user in SQLite
                //String uid = jObj.getString("uid");

                JSONObject user = jObj.getJSONObject("param");

                JSONObject jsonObject = user.getJSONObject("details");

                Log.d("Personal info",jsonObject.toString());

                String name = jsonObject.getString("Name");
                String email = jsonObject.getString("Email");
                String Contact = jsonObject.getString("Contact No.");
                String gender = jsonObject.getString("Gender");
                String Country =jsonObject.getString("Country");
                String City = jsonObject.getString("City");
                String State = jsonObject.getString("State");
                String Zip = jsonObject.getString("Zip");
                String Birth_Date = jsonObject.getString("Birth Date");
                String Status = jsonObject.getString("Status");
                String Connects_in= jsonObject.getString("Connects in");

                Bundle bundle = new Bundle();
                bundle.putString("name", name);
      // set Fragmentclass Arguments
                TabFragment tab1 = new TabFragment();
                tab1.setArguments(bundle);

            } catch (JSONException e) {
                // JSON error
                e.printStackTrace();
                Toast.makeText(getApplicationContext(), "Json error: " + e.getMessage(), Toast.LENGTH_LONG).show();
            }

        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e("TAG", "Login Error: " + error.getMessage());
            Toast.makeText(getApplicationContext(),
                    error.getMessage(), Toast.LENGTH_LONG).show();
            hideDialog();
        }
    }) {

        @Override
        protected Map<String, String> getParams() {
            // Posting parameters to login url
            Map<String, String> params = new HashMap<String, String>();
            params.put("visitor_id", "14");
            params.put("request","Dashboard_VisitorInfo");

            return params;
        }

    };

    // Adding request to request queue
    AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
}

 /*private void setupDrawer() {
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

}*/

private void setupCollapsingToolbar() {
    final CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(
            R.id.collapse_toolbar);

    collapsingToolbar.setTitleEnabled(false);
}

private void setupViewPager() {
  //  final ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
   viewPager = (ViewPager) findViewById(R.id.viewpager);
    setupViewPager(viewPager);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
}

private void setupToolbar() {
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle("TabbedCoordinatorLayout");
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

private void setupViewPager(ViewPager viewPager) {
    ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
    adapter.addFrag(new TabFragment(), "Personal");
    adapter.addFrag(new Tab1(), "Commnication");
    adapter.addFrag(new Tab2(), "Notes");

    viewPager.setAdapter(adapter);
}

static class ViewPagerAdapter extends FragmentPagerAdapter {

    private final List<Fragment> mFragmentList = new ArrayList<>();
    private final List<String> mFragmentTitleList = new ArrayList<>();

    public ViewPagerAdapter(FragmentManager manager) {
        super(manager);

    }

    @Override
    public Fragment getItem(int position) {
        return mFragmentList.get(position);
    }

    @Override
    public int getCount() {
        return mFragmentList.size();
    }

    public void addFrag(Fragment fragment, String title) {
        mFragmentList.add(fragment);
        mFragmentTitleList.add(title);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mFragmentTitleList.get(position);
    }
}

And getting values in fregment class like this

    @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment, container, false);
    Bundle bundle = this.getArguments();
    nameedit = (EditText)view.findViewById(R.id.editnameid);
    if (bundle != null){
        String name=bundle.getString("name");

        nameedit.setText(name);
    }


问:
INT to decimal JavaScript
I'm looking for method to achieve the following:

```<code>var exampleIntOne = 170;
var exampleIntTwo = 1700;
var exampleIntThree = 17000;
var exampleIntFour = 170000;
</code>```

I would like to be able to convert the above to the following expected result:

```<code>1.70
17.00
170.00
1700.00
</code>```

I have tried: exampleIntOne.toFixed(2); but this turns that example into: 170.00

答:
```<code>(yourNumber/100).toFixed(2)
</code>```

That should do

Title: INT to decimal JavaScript

Body:
I'm looking for method to achieve the following:

var exampleIntOne = 170;
var exampleIntTwo = 1700;
var exampleIntThree = 17000;
var exampleIntFour = 170000;

I would like to be able to convert the above to the following expected result:

1.70
17.00
170.00
1700.00

I have tried: exampleIntOne.toFixed(2); but this turns that example into: 170.00

Body:
(yourNumber/100).toFixed(2)

That should do


问:
how to upgrade to MySQL to 5.6.0 or higher from 5.5 on Rasbian (RaspberryPi, ARM)
I was installing Magento (E-commerce platform) on my Raspberry Pi 3 (Raspbian Pixel), which I used as a server.

I have installed PHP5, MySQL-Server v5.5.
But Magento requires version 5.6.0 or higher of MySQL server, I am unable to update it through apt-get command. also there is no build on official site for ARM architecture (Debian, Jessie).

Please help me upgrading MySQL server.
If compiling the source code is the only way, guide me how-to.

Thank You

答:
There is no official build for MySQL 5.6.0 for ARM but there is MariaDB available for ARM which exactly MySQL, learn more.

Directly Migrating to MariaDB from MySQL cause services error on pi on restart.
I recommend to remove MySQL & other MySQL things like phpadmin completely first.
Make sure to make backup.

Remove PHPmyADMIN

```<code>sudo apt-get remove -purge phpmyadmin
</code>```

Remove MySQL

```<code>sudo apt-get remove -purge mysql-common
</code>```

This will remove every thing related to MySQL like mysql-server,etc

Install MariaDB

```<code>sudo apt-get install mariadb-server
</code>```

Then either restart Apache server

```<code>sudo /etc/init.d/apache2 restart
</code>```

or restart Raspberry Pi

```<code>sudo shutdown -r 00
</code>```

That's All.

Body:
There is no official build for MySQL 5.6.0 for ARM but there is MariaDB available for ARM which exactly MySQL, learn more.

Directly Migrating to MariaDB from MySQL cause services error on pi on restart.
I recommend to remove MySQL & other MySQL things like phpadmin completely first.
Make sure to make backup.

Remove PHPmyADMIN

sudo apt-get remove -purge phpmyadmin

Remove MySQL

sudo apt-get remove -purge mysql-common

This will remove every thing related to MySQL like mysql-server,etc

Install MariaDB

sudo apt-get install mariadb-server

Then either restart Apache server

sudo /etc/init.d/apache2 restart

or restart Raspberry Pi

sudo shutdown -r 00

That's All.


问:
Table-like data structure in python
Is there a data-structure in Python that approximate the behavior of a database table?

My data looks like the following:

id | name | description

1  |  test |  this is a test

The closest I can get is to have a list of dictionaries, but I was wondering if there exists a specific data-structure for that purpose (that, for example, supports sorting or add).

答:
Pandas is what you are looking for.

You can generate DataFrames from array-like types, like list of dict, dict of list, list of list, np.Array...

Example :

```<code>import pandas as pd
df=pd.DataFrame({'wololo':[1,2,3,4,5,6],'text':['yay','toto','tat','tata','billy','bill']})
</code>```

The output will look like this

```<code>    text  wololo
0    yay       1
1   toto       2
2    tat       3
3   tata       4
4  billy       5
5   bill       6
</code>```

It also have useful I/O Tools to read a lot of different files such as Excel, CSV, JSON, etc...

Check also all the DataFrame methods to manipulate them in the more efficient way possible.

Title: Table-like data structure in python

Body:
Pandas is what you are looking for.

You can generate DataFrames from array-like types, like list of dict, dict of list, list of list, np.Array...

Example :

import pandas as pd
df=pd.DataFrame({'wololo':[1,2,3,4,5,6],'text':['yay','toto','tat','tata','billy','bill']})

The output will look like this

    text  wololo
0    yay       1
1   toto       2
2    tat       3
3   tata       4
4  billy       5
5   bill       6

It also have useful I/O Tools to read a lot of different files such as Excel, CSV, JSON, etc...

Check also all the DataFrame methods to manipulate them in the more efficient way possible.


问:
How to make AJAX call with angular2(ts)?
How to make AJAX call  with angular2(ts)?
I read the tutorial on angularjs.org. But there is nothing about AJAX.
So I really want to know how to make AJAX call  with angular2(ts).</p>

答:
json-data.service.ts

```<code>import { Injectable } from '@angular/core';
import { Http, Response, RequestOptions, Headers } from "@angular/http";
import 'rxjs/add/operator/map';
import { Observable } from 'rxjs/Observable';

@Injectable()
export class JsonDataService {
  errorMessage: any;

  constructor(private http: Http) {
  }

 getData(): Observable<JsonData[]> {
    console.log('Retriving Data from Server.......');
    return this.http.get('http://883.82.3:8086/restfullDataApi/UserService/jsondata')
      .map(this.extractData)
      .catch(this.handleError);
  }

getSolrData() {
    let headers = new Headers({ 'Content-Type': 'application/json' });
    let options = new RequestOptions({ headers: headers });
    let url = "http://883.8.2:8086/PI3_Solr_WebService/solrService"; /
    return this.http.post(url).map((res: Response) => res.json());
  }
   let body = res.json();
    return body || [];
  }

  private handleError(error: any) {
    // In a real world app, we might use a remote logging infrastructure
    // We'd also dig deeper into the error to get a better message
    let errMsg = (error.message) ? error.message :
      error.status ? `${error.status} - ${error.statusText}` : 'Server error';
    console.error(errMsg); // log to console instead
    alert("Server Error!");
    return Observable.throw(errMsg);
  }
</code>```

Body:
json-data.service.ts

import { Injectable } from '@angular/core';
import { Http, Response, RequestOptions, Headers } from "@angular/http";
import 'rxjs/add/operator/map';
import { Observable } from 'rxjs/Observable';

@Injectable()
export class JsonDataService {
  errorMessage: any;

  constructor(private http: Http) {
  }

 getData(): Observable<JsonData[]> {
    console.log('Retriving Data from Server.......');
    return this.http.get('http://883.82.3:8086/restfullDataApi/UserService/jsondata')
      .map(this.extractData)
      .catch(this.handleError);
  }

getSolrData() {
    let headers = new Headers({ 'Content-Type': 'application/json' });
    let options = new RequestOptions({ headers: headers });
    let url = "http://883.8.2:8086/PI3_Solr_WebService/solrService"; /
    return this.http.post(url).map((res: Response) => res.json());
  }
   let body = res.json();
    return body || [];
  }

  private handleError(error: any) {
    // In a real world app, we might use a remote logging infrastructure
    // We'd also dig deeper into the error to get a better message
    let errMsg = (error.message) ? error.message :
      error.status ? `${error.status} - ${error.statusText}` : 'Server error';
    console.error(errMsg); // log to console instead
    alert("Server Error!");
    return Observable.throw(errMsg);
  }


问:
Execute two distinct projects with code blocks
I have an issue with code blocks.

I have two distinct projects, one for the server and the other for the client. I would execute both of them at the same time for debugging. How can I do that ?

I have been trying settings -> environement -> [ ]"Allow only one running instance" and [ ]"Use an already running instance" but it doesn't work.

I wanna run my server and 3 clients at the same time in debug mode with code block.

I'm using code blocks 10.05 on ubuntu 12.04

答:
If you are running Windows7, try to delete the entire registry entry with regedit:

```<code>HKEY_CLASSES_ROOT\CodeBlocks.cbp\shell\open\ddeexec
</code>```

This may also work for some version of MS Office Excel.

Body:
If you are running Windows7, try to delete the entire registry entry with regedit:

HKEY_CLASSES_ROOT\CodeBlocks.cbp\shell\open\ddeexec

This may also work for some version of MS Office Excel.


问:
Does the select element have the required attribute?
Does the select element have the required attribute?</p>

答:
Yes it has a required attribute, you can use it as follows

```<code><select required>
<option value="" disabled selected>Choose</option>
<option value="first Option">First Option</option>
<option value="Second Option">Second Option</option>
</select>
</code>```

Reference :

HTML Select required Attribute (W3C)

Body:
Yes it has a required attribute, you can use it as follows

<select required>
<option value="" disabled selected>Choose</option>
<option value="first Option">First Option</option>
<option value="Second Option">Second Option</option>
</select>

Reference :

HTML Select required Attribute (W3C)


问:
Is it possible to add a prebuilt APK to an AOSP build as an user app?
I am looking to add a prebuilt APK to my AOSP build. I can already do this by doing the following:

Add the APK to the $root_of_my_source_tree/packages/apps folder.

Create an Android.mk file. The file has the following contents:

```<code>LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_MODULE := <name of APK>

LOCAL_SRC_FILES := <Name of APK>.apk

LOCAL_MODULE_CLASS := APPS

LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)

LOCAL_CERTIFICATE := platform

include $(BUILD_PREBUILT)
</code>```

Add:

```<code>PRODUCT_PACKAGES += \ <name of APK>
</code>```

To a make file that gets picked up by the AOSP build system.

This adds the APK to the /system/app folder which is read-only so the user will not be able to update the APK. I would like the APK to be placed in the /data/app folder so the user can actually update the prebuilt APK.

I have tried the suggestions in this question and they did not work. I tried the suggestion in this question and while it did output the APK to the /data/app folder of the finished build, once I flashed the image onto my device, the app was not there. The second answer in that question does provide a possible explanation for this but no other suggestions.

Ultimately, I need an APK preloaded in my build that can be updated so if this doesn't work or is a bad approach, I am open to suggestions.

答:
In your Android.mk file Use LOCAL_MODULE_PATH to TARGET_OUT_DATA or TARGET_OUT_DATA_APPS</p>

```<code>LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)
------
include $(BUILD_PREBUILT)
</code>```

Body:
I am looking to add a prebuilt APK to my AOSP build. I can already do this by doing the following:

Add the APK to the $root_of_my_source_tree/packages/apps folder.

Create an Android.mk file. The file has the following contents:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_MODULE := <name of APK>

LOCAL_SRC_FILES := <Name of APK>.apk

LOCAL_MODULE_CLASS := APPS

LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)

LOCAL_CERTIFICATE := platform

include $(BUILD_PREBUILT)

Add:

PRODUCT_PACKAGES += \ <name of APK>

To a make file that gets picked up by the AOSP build system.

This adds the APK to the /system/app folder which is read-only so the user will not be able to update the APK. I would like the APK to be placed in the /data/app folder so the user can actually update the prebuilt APK.

I have tried the suggestions in this question and they did not work. I tried the suggestion in this question and while it did output the APK to the /data/app folder of the finished build, once I flashed the image onto my device, the app was not there. The second answer in that question does provide a possible explanation for this but no other suggestions.

Ultimately, I need an APK preloaded in my build that can be updated so if this doesn't work or is a bad approach, I am open to suggestions.

Body:
In your Android.mk file Use LOCAL_MODULE_PATH to TARGET_OUT_DATA or TARGET_OUT_DATA_APPS

LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)
------
include $(BUILD_PREBUILT)


问:
Using google-vr from the fmod c++ api
I try to use FMOD C++ Api in combination with google-vr (gvr). (Without any game engine)
But I get an error when trying to load a bank, which utilizes the gvr plugin:
Error Message from FMOD API:

```<code>[WRN] PluginEffectModel::init                  : Missing DSP plugin 'Google GVR Source'
</code>```

However, I have no idea how I can tell the FMOD lib how to use the gvr plugin.
I assume there must be some kind of import for the gvraudio.dll, but I dont have any .lib or include sources.
So the question:
What are the required steps to be able to load FMOD banks which utilize gvr?

答:
As always you find the answer immediately after asking...
Plugins have to be loaded through the API, not linked as I thought.

Thus the solution is the function from the FMOD lowlevel API.

```<code>    FMOD_RESULT System::loadPlugin(
      const char *filename,
      unsigned int *handle,
      unsigned int priority
    );
</code>```

Title: Using google-vr from the fmod c++ api

Body:
I try to use FMOD C++ Api in combination with google-vr (gvr). (Without any game engine)
But I get an error when trying to load a bank, which utilizes the gvr plugin:
Error Message from FMOD API:

[WRN] PluginEffectModel::init                  : Missing DSP plugin 'Google GVR Source'

However, I have no idea how I can tell the FMOD lib how to use the gvr plugin.
I assume there must be some kind of import for the gvraudio.dll, but I dont have any .lib or include sources.
So the question:
What are the required steps to be able to load FMOD banks which utilize gvr?

Body:
As always you find the answer immediately after asking...
Plugins have to be loaded through the API, not linked as I thought.

Thus the solution is the function from the FMOD lowlevel API.

    FMOD_RESULT System::loadPlugin(
      const char *filename,
      unsigned int *handle,
      unsigned int priority
    );


问:
c# / XAML - ListView grouping: Changing the (background) color of the first header only
In my WPF Application, I have this ListView:

```<code><ListView.GroupStyle>
  <GroupStyle>
    <GroupStyle.ContainerStyle>
      <Style TargetType="{x:Type GroupItem}">
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate>
              <Expander IsExpanded="True">
                <Expander.Header>
                  <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Name}" FontWeight="Bold"
                               Foreground="Gray" FontSize="22"
                               VerticalAlignment="Bottom"/>
                    <TextBlock Text="{Binding ItemCount}" FontSize="22"
                               Foreground="Green" FontWeight="Bold"
                               FontStyle="Italic" Margin="10,0,0,0"
                               VerticalAlignment="Bottom" />
                    <TextBlock Text=" Ergebnis(se)" FontSize="22"
                               Foreground="Silver" FontStyle="Italic"
                               VerticalAlignment="Bottom"/>
                  </StackPanel>
                </Expander.Header>
                <ItemsPresenter/>
              </Expander>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
      </Style>
    </GroupStyle.ContainerStyle>
  </GroupStyle>
</ListView.GroupStyle>
</code>```

Now I want the first - and only the first - Header to appear in a different color (than the rest of the Headers - Font Color or Background Color, I don't care) for it to be marked.
I can't for the hell of it come up with an idea on how to do it.

答:
You could use a converter class that returns a specific Brush for the first group only:

```<code>public class GroupConverter : IValueConverter
{
    int n;
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return n++ == 0 ? Brushes.Yellow  : Brushes.Transparent;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}
</code>```

XAML:

```<code><ListView x:Name="lv">
    <ListView.Resources>
        <local:GroupConverter x:Key="converter" />
    </ListView.Resources>
    <ListView.GroupStyle>
        <GroupStyle>
            <GroupStyle.ContainerStyle>
                <Style TargetType="{x:Type GroupItem}">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <Expander IsExpanded="True" Background="{Binding Path=., Converter={StaticResource converter}}">
                                    <Expander.Header>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding Name}" FontWeight="Bold" Foreground="Gray" FontSize="22" VerticalAlignment="Bottom" />
                                            <TextBlock Text="{Binding ItemCount}" FontSize="22" Foreground="Green" FontWeight="Bold" FontStyle="Italic" Margin="10,0,0,0" VerticalAlignment="Bottom" />
                                            <TextBlock Text=" Ergebnis(se)" FontSize="22" Foreground="Silver" FontStyle="Italic" VerticalAlignment="Bottom" />
                                        </StackPanel>
                                    </Expander.Header>
                                    <Grid Background="White">
                                        <ItemsPresenter />
                                    </Grid>
                                </Expander>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </GroupStyle.ContainerStyle>
        </GroupStyle>
    </ListView.GroupStyle>
</ListView>
</code>```

Body:
In my WPF Application, I have this ListView:

<ListView.GroupStyle>
  <GroupStyle>
    <GroupStyle.ContainerStyle>

    </GroupStyle.ContainerStyle>
  </GroupStyle>
</ListView.GroupStyle>

Now I want the first - and only the first - Header to appear in a different color (than the rest of the Headers - Font Color or Background Color, I don't care) for it to be marked.
I can't for the hell of it come up with an idea on how to do it.

Body:
You could use a converter class that returns a specific Brush for the first group only:

public class GroupConverter : IValueConverter
{
    int n;
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return n++ == 0 ? Brushes.Yellow  : Brushes.Transparent;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

XAML:

<ListView x:Name="lv">
    <ListView.Resources>
        <local:GroupConverter x:Key="converter" />
    </ListView.Resources>
    <ListView.GroupStyle>
        <GroupStyle>
            <GroupStyle.ContainerStyle>
                <Style TargetType="{x:Type GroupItem}">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <Expander IsExpanded="True" Background="{Binding Path=., Converter={StaticResource converter}}">
                                    <Expander.Header>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding Name}" FontWeight="Bold" Foreground="Gray" FontSize="22" VerticalAlignment="Bottom" />
                                            <TextBlock Text="{Binding ItemCount}" FontSize="22" Foreground="Green" FontWeight="Bold" FontStyle="Italic" Margin="10,0,0,0" VerticalAlignment="Bottom" />
                                            <TextBlock Text=" Ergebnis(se)" FontSize="22" Foreground="Silver" FontStyle="Italic" VerticalAlignment="Bottom" />
                                        </StackPanel>
                                    </Expander.Header>
                                    <Grid Background="White">
                                        <ItemsPresenter />
                                    </Grid>
                                </Expander>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </GroupStyle.ContainerStyle>
        </GroupStyle>
    </ListView.GroupStyle>
</ListView>


问:
formArray in a tbody with only one colum to be validated
I'm having a hard time using formArray. We have a list of a class:

```<code>class item {
    value: number;
    name: string
    status: string
}
</code>```

Only the property value should be validated and is bounded to an input field.

We managed to display the readonly properties (I don't know if this is the correct way to do this tho).

We didn't manage to bind the input field (the samples I found they don't use ngModel, so I'm avoiding it)

We also don't know how to add the validation only for the value property.

So here are my questions:

How to bind properly the readonly fields?

How to bind the input field without ngModel?

How to create validation for the value property only?

That is our HTML:

```<code><div [formGroup]="parentForm">
  <div *ngIf="items">
    <table>
      <thead>
        <tr>
          <th>Name</th>
          <th>Value</th>
          <th>Status</th>
        </tr>
      </thead>
      <tbody formArrayName="itemsForm">
        <tr *ngFor="let item of parentForm.controls.itemsForm.controls; let i=index">
          <td><span>{{ item.value.name }}</span></td>
          <td>
            <input type="number" [formControlName]="i" tabindex="1" autocomplete="off" /> <!--How do I show the value here?-->
          </td>
          <td>
            <app-status [status]="item.value.status"></app-status>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</div>
</code>```

That is how we bind our form:

```<code>public ngOnInit(): void {

    let controls = new Array<FormControl>();

    this.items.forEach((item) => controls.push(new FormControl(item)));

    this.parentForm.addControl("itemsForm", new FormArray(controls));

    console.log(this.parentForm);
}
</code>```

答:
Use FromGroups, Validators and FormBuilder to do that :

```<code>myForm: FormGroup;
constructor(fb: FormBuilder) {}
ngOnInit() {
    this.myForm = this.fb.group({
        name: '', // Put the default value here
        status: '',
        value: [0, Validators.required] // Or any Validator you would use
    });
}
</code>```

In your HTML

```<code><form novalidate (ngSubmit)="yourSubmitFunction" [formGroup]="myForm">
    <input type="text" formControlName="value" required>
    <!-- and other inputs -->
    <!-- remember to match the validators ! (e.g. required tag for required validator) -->
</form>
</code>```

EDIT About the readonly fields, just don't send them on your submit function

Body:
I'm having a hard time using formArray. We have a list of a class:

class item {
    value: number;
    name: string
    status: string
}

Only the property value should be validated and is bounded to an input field.

We managed to display the readonly properties (I don't know if this is the correct way to do this tho).

We didn't manage to bind the input field (the samples I found they don't use ngModel, so I'm avoiding it)

We also don't know how to add the validation only for the value property.

So here are my questions:

How to bind properly the readonly fields?

How to bind the input field without ngModel?

How to create validation for the value property only?

That is our HTML:

          Name
          Value
          Status

          {{ item.value.name }}

            <input type="number" [formControlName]="i" tabindex="1" autocomplete="off" />

            <app-status [status]="item.value.status"></app-status>

That is how we bind our form:

public ngOnInit(): void {

    let controls = new Array<FormControl>();

    this.items.forEach((item) => controls.push(new FormControl(item)));

    this.parentForm.addControl("itemsForm", new FormArray(controls));

    console.log(this.parentForm);
}

Body:
Use FromGroups, Validators and FormBuilder to do that :

myForm: FormGroup;
constructor(fb: FormBuilder) {}
ngOnInit() {
    this.myForm = this.fb.group({
        name: '', // Put the default value here
        status: '',
        value: [0, Validators.required] // Or any Validator you would use
    });
}

In your HTML

<form novalidate (ngSubmit)="yourSubmitFunction" [formGroup]="myForm">
    <input type="text" formControlName="value" required>
    <!-- and other inputs -->
    <!-- remember to match the validators ! (e.g. required tag for required validator) -->
</form>

EDIT About the readonly fields, just don't send them on your submit function


问:
Setting up Application Insights on a console app
I've got Log4Net running on a console app, and would like the log events to go to Application Insights.

I'm not able to add AI by right-clicking on my project-it does not appear as an option.

I've installed the AI SDK through NuGet, and am able to create telemetry clients, but don't know where to add the instrumentation key.

This tutorial says:

Set the instrumentation key either in your code:

```<code>TelemetryConfiguration.Active.InstrumentationKey = " your key ";
</code>```

or in ApplicationInsights.config (if you installed one of the standard telemetry packages):

```<code><InstrumentationKey>your key</InstrumentationKey>
</code>```

I don't have an ApplicationInsights.config file, since I was not able to add AI to the project. Would it work if I just added the key as I instantiate the telemetry client, like this?

```<code>var telemetryClient = new TelemetryClient { InstrumentationKey = ConfigurationManager.AppSettings["applicationInsights"] };
</code>```

答:
You last suggestion will probably work. You can also do it like this: </p>

```<code>TelemetryConfiguration.Active.InstrumentationKey =  ConfigurationManager.AppSettings["applicationInsights"];
</code>```

Body:
I've got Log4Net running on a console app, and would like the log events to go to Application Insights.

I'm not able to add AI by right-clicking on my project-it does not appear as an option.

I've installed the AI SDK through NuGet, and am able to create telemetry clients, but don't know where to add the instrumentation key.

This tutorial says:

Set the instrumentation key either in your code:

TelemetryConfiguration.Active.InstrumentationKey = " your key ";

or in ApplicationInsights.config (if you installed one of the standard telemetry packages):

<InstrumentationKey>your key</InstrumentationKey>

I don't have an ApplicationInsights.config file, since I was not able to add AI to the project. Would it work if I just added the key as I instantiate the telemetry client, like this?

var telemetryClient = new TelemetryClient { InstrumentationKey = ConfigurationManager.AppSettings["applicationInsights"] };

Body:
You last suggestion will probably work. You can also do it like this:

TelemetryConfiguration.Active.InstrumentationKey =  ConfigurationManager.AppSettings["applicationInsights"];


问:
Custom Radio Buttons: How to uncheck? (Checkbox Hack)
I created some custom checkboxes which work great:

https://codepen.io/anon/pen/jwxXar

I tried to do the same with radio buttons. But if one radio button is active and I click another one, the unchecking does not work:

➤ https://codepen.io/anon/pen/YQLdxd

Custom Radio Buttons CSS Code

```<code>.radio  {
    position: relative;
    margin-bottom: 10px;
}

.radio input[type="radio"] {
    cursor: pointer;
    height: 100%;
    left: 0;
    margin: 0;
    opacity: 0;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: 1;
}

.radio label {margin-left: 32px;}

.radio label:before,
.radio label:after {
    content: "";
    display: block;
    position: absolute;
}

.radio label:before {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 50%;
    height: 20px;
    left: 0;
    top: 4px;
    width: 20px;
}

.radio label:after {
    background: red;
    border-radius: 50%;
    height: 12px;
    left: 5px;
    opacity: 0;
    pointer-events: none;
    top: 9px;
    width: 12px;
}

.radio input:checked ~ label:after {opacity: 1;}

input[type="radio"]:checked + label:before {
    border: 1px solid red;
    box-shadow: inset 0 0 0 1px #fff, inset 0 0 0 0 #fff, inset 0 0 0 16px #fff;
    color: #fff;
}
</code>```

Custom Radio Buttons HTMLCode

```<code><div class="radio">
    <input value="" type="radio">
    <label>Radio Button 1</label>
</div>
<div class="radio">
    <input value="" type="radio">
    <label>Radio Button 2</label>
</div>
<div class="radio">
    <input value="" type="radio">
    <label>Radio Button 3</label>
</div>
<div class="radio">
    <input value="" type="radio">
    <label>Radio Button 4</label>
</div>
</code>```

Does anyone of the CSS Super Heros have an idea, why the radio buttons are not working?

答:
Nothing wrong with your CSS. The only thing that you need to take care in case of radio is, radio buttons always works in group. So you have to give them name (name attribute)

```<code><div class="radio">
    <input value="" type="radio" name="rb1">
    <label>Radio Button 1</label>
</div>
<div class="radio">
    <input value="" type="radio" name="rb1">
    <label>Radio Button 2</label>
</div>
<div class="radio">
    <input value="" type="radio" name="rb1">
    <label>Radio Button 3</label>
</div>
<div class="radio">
    <input value="" type="radio" name="rb1">
    <label>Radio Button 4</label>
</div>
</code>```

Body:
I created some custom checkboxes which work great:

https://codepen.io/anon/pen/jwxXar

I tried to do the same with radio buttons. But if one radio button is active and I click another one, the unchecking does not work:

➤ https://codepen.io/anon/pen/YQLdxd

Custom Radio Buttons CSS Code

.radio  {
    position: relative;
    margin-bottom: 10px;
}

.radio input[type="radio"] {
    cursor: pointer;
    height: 100%;
    left: 0;
    margin: 0;
    opacity: 0;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: 1;
}

.radio label {margin-left: 32px;}

.radio label:before,
.radio label:after {
    content: "";
    display: block;
    position: absolute;
}

.radio label:before {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 50%;
    height: 20px;
    left: 0;
    top: 4px;
    width: 20px;
}

.radio label:after {
    background: red;
    border-radius: 50%;
    height: 12px;
    left: 5px;
    opacity: 0;
    pointer-events: none;
    top: 9px;
    width: 12px;
}

.radio input:checked ~ label:after {opacity: 1;}

input[type="radio"]:checked + label:before {
    border: 1px solid red;
    box-shadow: inset 0 0 0 1px #fff, inset 0 0 0 0 #fff, inset 0 0 0 16px #fff;
    color: #fff;
}

Custom Radio Buttons HTMLCode

    <input value="" type="radio">
    Radio Button 1

    <input value="" type="radio">
    Radio Button 2

    <input value="" type="radio">
    Radio Button 3

    <input value="" type="radio">
    Radio Button 4

Does anyone of the CSS Super Heros have an idea, why the radio buttons are not working?

Body:
Nothing wrong with your CSS. The only thing that you need to take care in case of radio is, radio buttons always works in group. So you have to give them name (name attribute)

<div class="radio">
    <input value="" type="radio" name="rb1">
    <label>Radio Button 1</label>
</div>
<div class="radio">
    <input value="" type="radio" name="rb1">
    <label>Radio Button 2</label>
</div>
<div class="radio">
    <input value="" type="radio" name="rb1">
    <label>Radio Button 3</label>
</div>
<div class="radio">
    <input value="" type="radio" name="rb1">
    <label>Radio Button 4</label>
</div>


问:
hide-unhide with radio button
Im trying to unhide div id=Q3 with my first 2 radio inputs (id= Q1 & id = Q2)

if   (Q1 = Ja and Q2 = Ja) show Q3.

Can somebody please help me!

See my html code below (sorry for the bad coding im a totally noob!).

HTML

```<code><body>

<header>
    <h2>Helpdesk</h2>
    <div>Wat is u probleem?</div>
</header>

<form>

<h4>Kunt computer normaal aanzetten?<span class = "req" id= "req_Q1">*</span></h4>
<input type="radio" name="A1" id="A1" value ="Ja" /> : Ja<br />
<input type="radio" name="A1" id="A2" value ="Nee" /> : Nee<br />

<p class= "instruct" id="instruct_Q1">
<small>Controleer eerst de kabels!</small>
</p>

<h4 id= "Q2">Geeft de monitor normaal beeld?<span class = "req" id= "req_Q2">*</span> </h4>
<input type="radio" name="A2" id="A3" /> : Ja<br />
<input type="radio" name="A2" id="A4"/> : Nee<br />

<p class= "instruct" id="instruct_Q2">
<small>Controleer eerst de kabels!</small>
</p>
</div>

<div id= "Q3" style="display: none;">
<label for ="Q3.1" ><h4>Start windows normaal op?</h4></label>
<select name="Q3.1">
    <option value="A3.1" >Ja, geen probleem</option>
    <option value="A3.2" >Ja, maar met foutmelding</option>
    <option value="A3.3" >Nee, zwart scherm</option>
    <option value="A3.4" >Nee, blauw scherm</option>
</select>
</div>

<div style="display: none;">
<h4>Kunt u inloggen?</h4>
<input type="radio" name="Q4" />Ja, geen probleem<br />
<input type="radio" name="Q4" /> Nee, ik krijg een foutmelding<br />
</div>

<div style="display: none;">
<h4>Ik krijg de volgende foutmelding <span class = "req" id= "req_Q5">*</span></h4>
<input type="radio" name="Q5" />Kan u niet aanmelden bij het domein. Controleer of uw gebruikersnaam en/of toegangscode correct zijn.<br />
<input type="radio" name="Q5" />Kan u niet aanmelden omdat het domein niet beschikbaar is. <br />
<input type="radio" name="Q5" />Uw account is geblokkeerd. Neem contact op met de beheerder. <br />
</div>
</code>```

Javascript

```<code>  $("input[name=A1]").click(function()
  {
  if(this.id =="A1"){
    $("#Q3").show('slow');
  }
  else {
  $("#Q3").hide('slow');
  }
  });
</code>```

答:
First of all to hide / unhide elements you should use the CSS.
There was question about it on StackOverflow: JavaScript: How to Hide / Unhide

However to my current knowledge to make IF statment - like you mentioned:

if(Q1 == Ja && Q2 == Ja){ show Q3 }

You need to use JavaScript.

EDIT: Hide/unhide div with button?
I think there can be answer for your question: hide / unhide using JQuery - I found it preety quickly when asked google.

Title: hide-unhide with radio button

Body:
Im trying to unhide div id=Q3 with my first 2 radio inputs (id= Q1 & id = Q2)

if   (Q1 = Ja and Q2 = Ja) show Q3.

Can somebody please help me!

See my html code below (sorry for the bad coding im a totally noob!).

HTML

Helpdesk

Wat is u probleem?

<form>

Kunt computer normaal aanzetten?*

<input type="radio" name="A1" id="A1" value ="Ja" /> : Ja

<input type="radio" name="A1" id="A2" value ="Nee" /> : Nee

Controleer eerst de kabels!

Geeft de monitor normaal beeld?*

<input type="radio" name="A2" id="A3" /> : Ja

<input type="radio" name="A2" id="A4"/> : Nee

Controleer eerst de kabels!

Start windows normaal op?

<select name="Q3.1">
    <option value="A3.1" >Ja, geen probleem</option>
    <option value="A3.2" >Ja, maar met foutmelding</option>
    <option value="A3.3" >Nee, zwart scherm</option>
    <option value="A3.4" >Nee, blauw scherm</option>
</select>

Kunt u inloggen?

<input type="radio" name="Q4" />Ja, geen probleem

<input type="radio" name="Q4" /> Nee, ik krijg een foutmelding

Ik krijg de volgende foutmelding *

<input type="radio" name="Q5" />Kan u niet aanmelden bij het domein. Controleer of uw gebruikersnaam en/of toegangscode correct zijn.

<input type="radio" name="Q5" />Kan u niet aanmelden omdat het domein niet beschikbaar is.

<input type="radio" name="Q5" />Uw account is geblokkeerd. Neem contact op met de beheerder.

Javascript

  $("input[name=A1]").click(function()
  {
  if(this.id =="A1"){
    $("#Q3").show('slow');
  }
  else {
  $("#Q3").hide('slow');
  }
  });

Body:
First of all to hide / unhide elements you should use the CSS.
There was question about it on StackOverflow: JavaScript: How to Hide / Unhide <div>

However to my current knowledge to make IF statment - like you mentioned:

if(Q1 == Ja && Q2 == Ja){ show Q3 }

You need to use JavaScript.

EDIT: Hide/unhide div with button?
I think there can be answer for your question: hide / unhide using JQuery - I found it preety quickly when asked google.


问:
Exporting multiple sheets using openxlsx in r
I am trying to make 170 sheets (3 in the code below) in one excel file using openxlsx package. I used xlsx package before and used the option "append=TRUE" to create multiple sheets in one excel file but I could not find the same option in openxlsx package.

```<code>system.time(
for (i in 1:3) {
write.xlsx(fulldata[[i]], file="fulltable5.xlsx", sheetName=cntry_name[i])
}
)
</code>```

This code only creates only the third sheet. I have tried overwrite=TRUE but
this only returns error. Could you please tell me which option corresponds to "append=TRUE" in the function write.xlsx() in xlsx package?

+ADD)))

This is a data that has similar size with my original data.
It works for just one sheet but not for 172 sheets.

```<code>a <- list()
for (i in 1:172) {
a[[i]] <- matrix(i,30,60)
}

write.xlsx(a, file="fulltable6.xlsx")
</code>```

And sadly, the R session is aborted.
I need 172 sheets in 1 excel file.
I am using Rstudio 3.4.0 and my computer is i3-5005U @ 2GHZ, 8gb RAM

答:
Just pass your (named) list to write.xlsx:

```<code>fulldata <- split(iris, seq_len(nrow(iris)) %/% 3)
names(fulldata) <- paste("sheet", seq_along(fulldata), sep="_")
library(openxlsx)
write.xlsx(fulldata, file=tf<-tempfile(fileext = ".xlsx"))
shell.exec(tf) # open file on windows
</code>```

Body:
I am trying to make 170 sheets (3 in the code below) in one excel file using openxlsx package. I used xlsx package before and used the option "append=TRUE" to create multiple sheets in one excel file but I could not find the same option in openxlsx package.

system.time(
for (i in 1:3) {
write.xlsx(fulldata[[i]], file="fulltable5.xlsx", sheetName=cntry_name[i])
}
)

This code only creates only the third sheet. I have tried overwrite=TRUE but
this only returns error. Could you please tell me which option corresponds to "append=TRUE" in the function write.xlsx() in xlsx package?

+ADD)))

This is a data that has similar size with my original data.
It works for just one sheet but not for 172 sheets.

a <- list()
for (i in 1:172) {
a[[i]] <- matrix(i,30,60)
}

write.xlsx(a, file="fulltable6.xlsx")

And sadly, the R session is aborted.
I need 172 sheets in 1 excel file.
I am using Rstudio 3.4.0 and my computer is i3-5005U @ 2GHZ, 8gb RAM

Body:
Just pass your (named) list to write.xlsx:

fulldata <- split(iris, seq_len(nrow(iris)) %/% 3)
names(fulldata) <- paste("sheet", seq_along(fulldata), sep="_")
library(openxlsx)
write.xlsx(fulldata, file=tf<-tempfile(fileext = ".xlsx"))
shell.exec(tf) # open file on windows


问:
how to append to a excel file in nodejs
i am currently working on a form which will take user input and add it to one row of an excel sheet, as of now i have managed to make excel sheet using 3rd party plugins(node-xls to be specific).
issue arises if i wanna add another row to the excel , it deletes the old entry and adds the new instead of appending the data to the next row.

tried reading the excel and then concatenating the buffers and writing the file again, but turns out it is corrupting the file and is rendering it unusable.

How do i append data to the end of the excel sheet? i am new to nodejs and buffers

```<code>var fs = require('fs');
var NodeXls = require('node-xls');
var tool = new NodeXls();
var xls = tool.json2xls({firstName: "arjun", lastName: "u", dob:"12/3/2008"}, {order:["firstName", "lastName", "dob"]});
fs.appendFile('output.xlsx', xls, 'binary', function(err){
if(err)
  alert("File is readOnly or is being used by another application,  please close it and continue!");
});
</code>```

答:
It will add one row at a time</p>

```<code>var spread_sheet = require('spread_sheet');
var row = "1,2,Jack,Pirate";
var filePath = '/home/Pranjal/Desktop/test.xlsx';
var sheetName = "Sheet1";

spread_sheet.addRow(row,filePath,sheetName,function(err,result){
    console.log(err,result)
})
</code>```

Title: how to append to a excel file in nodejs

Body:
i am currently working on a form which will take user input and add it to one row of an excel sheet, as of now i have managed to make excel sheet using 3rd party plugins(node-xls to be specific).
issue arises if i wanna add another row to the excel , it deletes the old entry and adds the new instead of appending the data to the next row.

tried reading the excel and then concatenating the buffers and writing the file again, but turns out it is corrupting the file and is rendering it unusable.

How do i append data to the end of the excel sheet? i am new to nodejs and buffers

var fs = require('fs');
var NodeXls = require('node-xls');
var tool = new NodeXls();
var xls = tool.json2xls({firstName: "arjun", lastName: "u", dob:"12/3/2008"}, {order:["firstName", "lastName", "dob"]});
fs.appendFile('output.xlsx', xls, 'binary', function(err){
if(err)
  alert("File is readOnly or is being used by another application,  please close it and continue!");
});

Body:
It will add one row at a time

var spread_sheet = require('spread_sheet');
var row = "1,2,Jack,Pirate";
var filePath = '/home/Pranjal/Desktop/test.xlsx';
var sheetName = "Sheet1";

spread_sheet.addRow(row,filePath,sheetName,function(err,result){
    console.log(err,result)
})


问:
click button in activity 1 and if the button clicked show textview ... in activity 3
The Title is just a example. In my first Activity i have 2 buttons. If u hit the first Button (Button1) you will visit activity 2.1. But when you hit the second Button(Button2) you will visit Activity 2.2. In activity 3 its neccessary to know which Button the user hitted (Buttonenter code here2 or 1) because they will be different TextViews to show. So how show this different TextViews?

This Code is in Activity 3.

```<code> public void Button1 (View view) {
    TextView txtView = (TextView)findViewById(R.id.nextText);
    if (txtView .getVisibility() == View.VISIBLE)
        txtView.setVisibility(View.VISIBLE);
    else
        txtView.setVisibility(View.VISIBLE);
}

public void Button2 (View view) {
    TextView txtView = (TextView)findViewById(R.id.nextText2);
    if (txtView .getVisibility() == View.VISIBLE)
        txtView.setVisibility(View.VISIBLE);
    else
        txtView.setVisibility(View.VISIBLE);
}
</code>```

答:
Solution 1:

You can set the integer value 1 or 2 according to the button clicked and then pass this integer from activity 1 to activity 2 and then activity 2 to activity 3, and check in activity 3 and set visibility according to the integer value.

Example:

On Button 1 Click:

```<code>Intent i = new Intent(this, ActivityTwo.class);
i.putExtra("button", 1);
startActivity(i);
</code>```

On Button 2 Click:

```<code>Intent i = new Intent(this, ActivityTwo.class);
i.putExtra("button", 2);
startActivity(i);
</code>```

And get this value in onCreate method of activity 2:

```<code>Bundle b = getIntent().getExtras();
if (b != null) {
    int button = b.getInt("button");
}
</code>```

And again pass this value to activity 3 so you will get to know which button was clicked with the help of the integer that you received.

Solution 2:

You can save the button number integer value in SharedPreferences on the click of button and retrieve that value in activity 3 and set visibility of the button according to the integer value.

Example:

Declare editor in your activity 1

```<code>SharedPreferences.Editor editor;
</code>```

Initialize editor in your activity's onCreate method.

```<code>editor = getSharedPreferences("myPrefs", Context.MODE_PRIVATE).edit();
</code>```

And on Button 1 Click:

```<code>editor.putInt("button", 1);
editor.apply();
</code>```

And on Button 2 Click:

```<code>editor.putInt("button", 2);
editor.apply();
</code>```

Now declare sharedPreferences in your activity 3

```<code>SharedPreferences sharedPreferences;
</code>```

Initialize sharedPreferences in your activity's onCreate method.

```<code>sharedPreferences = getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
</code>```

And in activity 3 get the value of button

```<code>int button = sharedPreferences.getInt("button", 0);
</code>```

and set visibility of the button according to the value of button

Body:
The Title is just a example. In my first Activity i have 2 buttons. If u hit the first Button (Button1) you will visit activity 2.1. But when you hit the second Button(Button2) you will visit Activity 2.2. In activity 3 its neccessary to know which Button the user hitted (Buttonenter code here2 or 1) because they will be different TextViews to show. So how show this different TextViews?

This Code is in Activity 3.

 public void Button1 (View view) {
    TextView txtView = (TextView)findViewById(R.id.nextText);
    if (txtView .getVisibility() == View.VISIBLE)
        txtView.setVisibility(View.VISIBLE);
    else
        txtView.setVisibility(View.VISIBLE);
}

public void Button2 (View view) {
    TextView txtView = (TextView)findViewById(R.id.nextText2);
    if (txtView .getVisibility() == View.VISIBLE)
        txtView.setVisibility(View.VISIBLE);
    else
        txtView.setVisibility(View.VISIBLE);
}

Body:
Solution 1:

You can set the integer value 1 or 2 according to the button clicked and then pass this integer from activity 1 to activity 2 and then activity 2 to activity 3, and check in activity 3 and set visibility according to the integer value.

Example:

On Button 1 Click:

Intent i = new Intent(this, ActivityTwo.class);
i.putExtra("button", 1);
startActivity(i);

On Button 2 Click:

Intent i = new Intent(this, ActivityTwo.class);
i.putExtra("button", 2);
startActivity(i);

And get this value in onCreate method of activity 2:

Bundle b = getIntent().getExtras();
if (b != null) {
    int button = b.getInt("button");
}

And again pass this value to activity 3 so you will get to know which button was clicked with the help of the integer that you received.

Solution 2:

You can save the button number integer value in SharedPreferences on the click of button and retrieve that value in activity 3 and set visibility of the button according to the integer value.

Example:

Declare editor in your activity 1

SharedPreferences.Editor editor;

Initialize editor in your activity's onCreate method.

editor = getSharedPreferences("myPrefs", Context.MODE_PRIVATE).edit();

And on Button 1 Click:

editor.putInt("button", 1);
editor.apply();

And on Button 2 Click:

editor.putInt("button", 2);
editor.apply();

Now declare sharedPreferences in your activity 3

SharedPreferences sharedPreferences;

Initialize sharedPreferences in your activity's onCreate method.

sharedPreferences = getSharedPreferences("myPrefs", Context.MODE_PRIVATE);

And in activity 3 get the value of button

int button = sharedPreferences.getInt("button", 0);

and set visibility of the button according to the value of button


问:
Direct call Python's coroutine from coroutine
I am creating a class with simple and complex API. Every method which is part of this API should be coroutine. Let's say it looks like this:

```<code>class MyClass:
    async def complex(self, **kwargs):
        x = compute(kwargs)
        return await asyncio.sleep(x)

    async def simple1(self, param):
        return await self.complex(a=param, b=None)

    async def simple2(self, param):
        return await self.complex(a=None, b=param)
</code>```

From outside this class I still want to call method like coroutines e.g.

```<code>x = MyClass()
loop = asyncio.get_event_loop()
result = loop.run_until_complete(x.simple1(42))
</code>```

Now I would like to remove the await from simple1 and simple2 calls because I want to prevent jumps into event loop and back (it feels like wasting time just for the simple call).

Is there any way how to accomplish this? Of course, any solution shouldn't exceed overhead of await approach.

答:
You can just return the co-routine that calling self.complex() produces directly:

```<code>class MyClass:
    async def complex(self, **kwargs):
        x = compute(kwargs)
        return await asyncio.sleep(x)

    def simple1(self, param):
        return self.complex(a=param, b=None)

    def simple2(self, param):
        return self.complex(a=None, b=param)
</code>```

This passes the complex() co-routine directly to the caller.

After all, all that MyClass().complex() does is produce a coroutine object for deferred execution. That same object can be passed around through other synchronous calls, calling MyClass().simple1('foo') now happens to create a different coroutine object that directly executes the complex() method body rather than produce a wrapper that then defers to the same.

However, the addition of the async and await keywords make it clear to the reader of your code that the methods produce co-routines. The overhead is minimal, consider retaining them.

Body:
I am creating a class with simple and complex API. Every method which is part of this API should be coroutine. Let's say it looks like this:

class MyClass:
    async def complex(self, **kwargs):
        x = compute(kwargs)
        return await asyncio.sleep(x)

    async def simple1(self, param):
        return await self.complex(a=param, b=None)

    async def simple2(self, param):
        return await self.complex(a=None, b=param)

From outside this class I still want to call method like coroutines e.g.

x = MyClass()
loop = asyncio.get_event_loop()
result = loop.run_until_complete(x.simple1(42))

Now I would like to remove the await from simple1 and simple2 calls because I want to prevent jumps into event loop and back (it feels like wasting time just for the simple call).

Is there any way how to accomplish this? Of course, any solution shouldn't exceed overhead of await approach.

Body:
You can just return the co-routine that calling self.complex() produces directly:

class MyClass:
    async def complex(self, **kwargs):
        x = compute(kwargs)
        return await asyncio.sleep(x)

    def simple1(self, param):
        return self.complex(a=param, b=None)

    def simple2(self, param):
        return self.complex(a=None, b=param)

This passes the complex() co-routine directly to the caller.

After all, all that MyClass().complex() does is produce a coroutine object for deferred execution. That same object can be passed around through other synchronous calls, calling MyClass().simple1('foo') now happens to create a different coroutine object that directly executes the complex() method body rather than produce a wrapper that then defers to the same.

However, the addition of the async and await keywords make it clear to the reader of your code that the methods produce co-routines. The overhead is minimal, consider retaining them.


问:
input.getaxis for 3d in unity
I would like to convert my 2D script into a 3D script, but am running into a road block when trying to program the z axis for the 3D script. I need to know how to change input.getaxis("Horizontal") to something that includes the z axis.

答:
You can edit the InputManager in Unity via Edit -> Project Settings -> Input.

There you can define a new Axis for your likes and then access it as you are used to using Input.GetAxis().

Title: input.getaxis for 3d in unity


问:
Easy way of handling different user / pass for DB on dev. machine vs production server
I usually have a config-file with some global variables for database connectivity settings (such as db host, db name, user, pass).

I also really like to be able to just drag and drop all files from my dev machine to the production server. However, development db host etc may be different from the one on the production server.

Is there an easy way of, in PHP, saying something like "if I'm on the dev-machine, use these values"? (I'd prefer to avoid hacks based on host IP / name.) I'm thinking of something like perhaps setting something in php.ini or httpd.conf so that for instance $DEV_MACHINE, is set to true on the dev machine.

答: You can set up an Apache variable with SetEnv, and query it with PHP's apache_getenv().

ContentLicense: CC BY-SA 2.5


问:
Do I need to add thread locking to simple variables?
Let's say I have an object for which multiple threads can read/write to the state and someValue variables. Do I need to add locking if these variables are types like int, double, enums etc.?

```<code>enum State: String {
  case one
  case two
}

class Object {
  var state: State
  var someValue: Double
}
</code>```

答:
What JeremyP says, but you also need to consider higher levels: Your "state" and "someValue" could be related. So if I change the state, then someValue, the contents of the whole object just after I change "state" might be rubbish because the new state doesn't match the old someValue. </p>

<p>Simple solutions are googling how to do "@synchronized" in Swift, or dispatch to the main thread, or dispatch to a serial queue. </p>

Body:
Let's say I have an object for which multiple threads can read/write to the state and someValue variables. Do I need to add locking if these variables are types like int, double, enums etc.?

enum State: String {
  case one
  case two
}

class Object {
  var state: State
  var someValue: Double
}

Body:
What JeremyP says, but you also need to consider higher levels: Your "state" and "someValue" could be related. So if I change the state, then someValue, the contents of the whole object just after I change "state" might be rubbish because the new state doesn't match the old someValue.

Simple solutions are googling how to do "@synchronized" in Swift, or dispatch to the main thread, or dispatch to a serial queue.