问:
modalpop is not working inside update panel
in my webform.i have listview and a placeholder inside a update panel.i have to popup a window showing details of selected item.i am dynamically creating popup on listview item_command.
updatepanel has asynchronous trigger on listview item_command.

earlier i was using panel as modal popupwindow.i kept panel inside the update panel.i have to pass value to iframe.but the window was displaying but the iframe src was not displaying.so i created the window dynamically.

here is my code.

```<code>protected void OrderList_ItemCommand(object sender, ListViewCommandEventArgs e)
{
     switch (e.CommandName)
     {
        case "ViewOrderDetails":
        ListViewDataItem currentItem = (ListViewDataItem)e.Item;
        DataKey currentDataKey = this.OrderList.DataKeys[currentItem.DisplayIndex];
        string Orderid = Convert.ToString(currentDataKey["Order_Id"]);
        Createpopwindow(Orderid );
        Break;
     }
}

private void Createpopwindow(string contestid)
{
    popupholder.Controls.Clear();

    Panel popuppanel = new Panel();
    popuppanel.ID = "poppanel1";
    popuppanel.Width=550;
    popuppanel.CssClass = "Dialoguebox";

    HtmlGenericControl popupbody = new HtmlGenericControl("p");
    ImageButton closebtn = new ImageButton();
    closebtn.ID="panelclose";
    closebtn.ImageUrl="~/images/close01.png";
    HtmlGenericControl frame = new HtmlGenericControl("iframe");
    frame.Attributes.Add("width","100%");
    frame.Attributes.Add("src", "joincontest.aspx?contest=" + contestid);

    popupbody.Controls.Add(closebtn);

    popuppanel.Controls.Add(popupbody);
    popuppanel.Controls.Add(frame);
    popupholder.Controls.Add(popuppanel);

    //creating modal popup extender

    ModalPopupExtender Popup = new ModalPopupExtender();
    Popup.ID = "popupextender";
    Popup.TargetControlID = "Button1";
    Popup.PopupControlID = "poppanel1";
    Popup.CancelControlID = "panelclose";
    this.Page.Controls.Add(Popup);

    Popup.Show();
}
</code>```

but the popup is not showing on selecting the listview item.
did i missed any thing.

答:
Is there a reason you are creating this dynamically, and not in your markup?
If you create your modalpopup in the markup, you can still set all the values dynamically, before you show it.</p>

Body:
in my webform.i have listview and a placeholder inside a update panel.i have to popup a window showing details of selected item.i am dynamically creating popup on listview item_command.
updatepanel has asynchronous trigger on listview item_command.

earlier i was using panel as modal popupwindow.i kept panel inside the update panel.i have to pass value to iframe.but the window was displaying but the iframe src was not displaying.so i created the window dynamically.

here is my code.

protected void OrderList_ItemCommand(object sender, ListViewCommandEventArgs e)
{
     switch (e.CommandName)
     {
        case "ViewOrderDetails":
        ListViewDataItem currentItem = (ListViewDataItem)e.Item;
        DataKey currentDataKey = this.OrderList.DataKeys[currentItem.DisplayIndex];
        string Orderid = Convert.ToString(currentDataKey["Order_Id"]);
        Createpopwindow(Orderid );
        Break;
     }
}

private void Createpopwindow(string contestid)
{
    popupholder.Controls.Clear();

    Panel popuppanel = new Panel();
    popuppanel.ID = "poppanel1";
    popuppanel.Width=550;
    popuppanel.CssClass = "Dialoguebox";

    HtmlGenericControl popupbody = new HtmlGenericControl("p");
    ImageButton closebtn = new ImageButton();
    closebtn.ID="panelclose";
    closebtn.ImageUrl="~/images/close01.png";
    HtmlGenericControl frame = new HtmlGenericControl("iframe");
    frame.Attributes.Add("width","100%");
    frame.Attributes.Add("src", "joincontest.aspx?contest=" + contestid);

    popupbody.Controls.Add(closebtn);

    popuppanel.Controls.Add(popupbody);
    popuppanel.Controls.Add(frame);
    popupholder.Controls.Add(popuppanel);

    //creating modal popup extender

    ModalPopupExtender Popup = new ModalPopupExtender();
    Popup.ID = "popupextender";
    Popup.TargetControlID = "Button1";
    Popup.PopupControlID = "poppanel1";
    Popup.CancelControlID = "panelclose";
    this.Page.Controls.Add(Popup);

    Popup.Show();
}

but the popup is not showing on selecting the listview item.
did i missed any thing.


来源: stackexchange

问:
How do pull images from a wordpress post to display it on the screen?
I am trying to display something like a thumbnail for my post. Is there any wordpress function that can do that? I read about wordpress featured images but I dont see the option to set one on the wordpress admin page.

I also tried using the_post_thumbnail() but it didnt work.

this is what my div looks like at the moment:

```<code><div class="card" style="width: 22rem;">
          <img src="<?php the_post_thumbnail(); ?>" class="card-img-top" alt="...">
          <div class="card-body">
            <h5 class="card-title"><?php the_title() ?></h5>
            <p class="card-text">Random Card content</p>
          </div>
</div>
</code>```

答:
I also found another way to do it while using the img tag</p>

```<code><img class="card-img-top" src="<?php the_post_thumbnail_url() ?>" alt="Card image cap">
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I am trying to display something like a thumbnail for my post. Is there any wordpress function that can do that? I read about wordpress featured images but I dont see the option to set one on the wordpress admin page.

I also tried using the_post_thumbnail() but it didnt work.

this is what my div looks like at the moment:

          <img src="<?php the_post_thumbnail(); ?>" class="card-img-top" alt="...">

<?php the_title() ?>

Random Card content

Body:
I also found another way to do it while using the img tag

<img class="card-img-top" src="<?php the_post_thumbnail_url() ?>" alt="Card image cap">


问:
How to setup seemly circular but not actually circular dependencies in Azure Data Factory V2
Below is the scenario :

Pipeline A triggered by Tumbling Window Trigger A - Runs Every Hour.

Pipeline B triggered by Tumbling Windows Trigger B - Runs Every Week.

I want A to run only after :

a. last run of A is successful. (self dependency - doable).

b. last run of B is successful.  ( This is also doable but can get into circular dependency because of point b in below lines)

I want B to run only after :

a. last run of B is successful. ( self dependency - doable)

b. last run of A is successful. ( This gets into circular dependency issue when we publish and later when it generates ARM templates)

Here A is having frequency of 1 hour and B is having frequency of 1 week.

consider B is to next execute on 9th Feb 12:00 AM for window of 2nd Feb - 9th Feb.

Also, A is about to execute on 9th Feb 12:00 Am for window of 8th Feb 11:00 PM - 12:00 PM.

In this case both runs will collide at 9th Feb 12:00 AM. Can we setup dependency so that it does not collide.

答:
I provide below ideas for your reference:

1.Firstly,put the pipelines into Execute Pipeline Activity because you may have to do some steps before and after execution of A and B pipelines.

2.Secondly,since the pipelines have to be executed with some conditions,i think you could persist the results of A and B pipelines execution anyway.For example,after executing pipeline,use an Azure Function Activity or Web Activity to send the result of pipeline into some residences. The aim is logging the latest execute result of A and B.

3.Finally,before the execution of A and B pipelines,you could use an Until Activity to evaluate whether the pipeline could be executed.


问:
Process HTML file using Thymeleaf in Web based Scopes of Spring and store the processed template as String
I am trying to render an HTML file using thymeleaf and keep the resultant HTML content in a String variable in web-based scopes of Spring so that i can use it later for sending email or converting the content to pdf. I have gone through the implementation given in this website but its giving me error which i couldn't figure out. I am using spring boot 1.5.12.RELEASE with thymeleaf 3.0.9 n thymeleaf dialect 2.2.2. Below is my implementation. Please help.

```<code>import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;
import org.thymeleaf.templatemode.TemplateMode;
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;

@Controller
public class jataController {

    @GetMapping(value = "/manual-thym")
    @ResponseBody
    public void justSample() {
        Context context = new Context();
        String filename = "templates/view/failure";
        String html = renderHtml(filename, context);
        System.out.println("template\n" + html);
    }

    private String renderHtml(String filename, Context context) {

        ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();

        templateResolver.setSuffix(".html");
        templateResolver.setTemplateMode(TemplateMode.HTML);
        templateResolver.setCacheable(false);
        templateResolver.setOrder(1);
        templateResolver.setCharacterEncoding("UTF-8");

        TemplateEngine templateEngine = new TemplateEngine();
        templateEngine.setTemplateResolver(templateResolver);

        String html = templateEngine.process(filename, context);

        return html;
    }
}
</code>```

And the StackTrace:

```<code>2018-04-19 12:26:43.742 ERROR 6375 --- [nio-9000-exec-9] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: ognl/PropertyAccessor] with root cause

java.lang.ClassNotFoundException: ognl.PropertyAccessor
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_162]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_162]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~[na:1.8.0_162]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_162]
    at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_162]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0_162]
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_162]
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[na:1.8.0_162]
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_162]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[na:1.8.0_162]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[na:1.8.0_162]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_162]
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[na:1.8.0_162]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_162]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~[na:1.8.0_162]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_162]
    at org.thymeleaf.standard.expression.OGNLVariableExpressionEvaluator.<init>(OGNLVariableExpressionEvaluator.java:83) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.standard.StandardDialect.getVariableExpressionEvaluator(StandardDialect.java:179) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.standard.StandardDialect.getExecutionAttributes(StandardDialect.java:393) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.DialectSetConfiguration.build(DialectSetConfiguration.java:263) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.EngineConfiguration.<init>(EngineConfiguration.java:123) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.TemplateEngine.initialize(TemplateEngine.java:336) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1079) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1059) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1048) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at com.siqes.flight.controller.jataController.renderHtml(jataController.java:37) ~[classes/:na]
    at com.siqes.flight.controller.jataController.justSample(jataController.java:19) ~[classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_162]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_162]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_162]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) ~[spring-webmvc-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) ~[spring-webmvc-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) ~[spring-webmvc-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967) ~[spring-webmvc-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901) ~[spring-webmvc-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) ~[spring-webmvc-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) ~[spring-webmvc-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55) ~[spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:111) ~[spring-boot-actuator-1.5.12.RELEASE.jar:1.5.12.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:106) ~[spring-boot-actuator-1.5.12.RELEASE.jar:1.5.12.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:613) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_162]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_162]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_162]
</code>```

答:
Using Maven, add ognl dependency to your pom.xml file, e.g. (find the latest dependency/version in MVNRepository):</p>

```<code><dependency>
    <groupId>ognl</groupId>
    <artifactId>ognl</artifactId>
    <version>3.1.12</version>
</dependency>
</code>```

Body:
I am trying to render an HTML file using thymeleaf and keep the resultant HTML content in a String variable in web-based scopes of Spring so that i can use it later for sending email or converting the content to pdf. I have gone through the implementation given in this website but its giving me error which i couldn't figure out. I am using spring boot 1.5.12.RELEASE with thymeleaf 3.0.9 n thymeleaf dialect 2.2.2. Below is my implementation. Please help.

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;
import org.thymeleaf.templatemode.TemplateMode;
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;

@Controller
public class jataController {

    @GetMapping(value = "/manual-thym")
    @ResponseBody
    public void justSample() {
        Context context = new Context();
        String filename = "templates/view/failure";
        String html = renderHtml(filename, context);
        System.out.println("template\n" + html);
    }

    private String renderHtml(String filename, Context context) {

        ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();

        templateResolver.setSuffix(".html");
        templateResolver.setTemplateMode(TemplateMode.HTML);
        templateResolver.setCacheable(false);
        templateResolver.setOrder(1);
        templateResolver.setCharacterEncoding("UTF-8");

        TemplateEngine templateEngine = new TemplateEngine();
        templateEngine.setTemplateResolver(templateResolver);

        String html = templateEngine.process(filename, context);

        return html;
    }
}

And the StackTrace:

2018-04-19 12:26:43.742 ERROR 6375 --- [nio-9000-exec-9] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: ognl/PropertyAccessor] with root cause

java.lang.ClassNotFoundException: ognl.PropertyAccessor
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_162]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_162]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~[na:1.8.0_162]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_162]
    at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_162]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0_162]
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_162]
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[na:1.8.0_162]
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_162]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[na:1.8.0_162]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[na:1.8.0_162]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_162]
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[na:1.8.0_162]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_162]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~[na:1.8.0_162]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_162]
    at org.thymeleaf.standard.expression.OGNLVariableExpressionEvaluator.<init>(OGNLVariableExpressionEvaluator.java:83) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.standard.StandardDialect.getVariableExpressionEvaluator(StandardDialect.java:179) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.standard.StandardDialect.getExecutionAttributes(StandardDialect.java:393) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.DialectSetConfiguration.build(DialectSetConfiguration.java:263) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.EngineConfiguration.<init>(EngineConfiguration.java:123) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.TemplateEngine.initialize(TemplateEngine.java:336) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1079) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1059) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1048) ~[thymeleaf-3.0.9.RELEASE.jar:3.0.9.RELEASE]
    at com.siqes.flight.controller.jataController.renderHtml(jataController.java:37) ~[classes/:na]
    at com.siqes.flight.controller.jataController.justSample(jataController.java:19) ~[classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_162]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_162]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_162]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) ~[spring-webmvc-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) ~[spring-webmvc-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) ~[spring-webmvc-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967) ~[spring-webmvc-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901) ~[spring-webmvc-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) ~[spring-webmvc-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) ~[spring-webmvc-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55) ~[spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:111) ~[spring-boot-actuator-1.5.12.RELEASE.jar:1.5.12.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:106) ~[spring-boot-actuator-1.5.12.RELEASE.jar:1.5.12.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.16.RELEASE.jar:4.3.16.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:613) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_162]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_162]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.29.jar:8.5.29]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_162]

Body:
Using Maven, add ognl dependency to your pom.xml file, e.g. (find the latest dependency/version in MVNRepository):

<dependency>
    <groupId>ognl</groupId>
    <artifactId>ognl</artifactId>
    <version>3.1.12</version>
</dependency>


问:
Adjusting current code to be able to add items from new table to the basket
My website is currently adapted to deal with things like adding to the cart, removing from the cart and creating an order, only on one Item table. I wanted to add different products to the site, so I need to create a new table, that will handle other items. The thing is, that I am not really sure how to properly implement that to my website, so things like adding to the cart and creating order would work with that new table as well.

So thats the model of the first Item table:

```<code>class Item(models.Model):
  title = models.CharField(max_length=100)
  price = models.FloatField()
  discount_price = models.FloatField(blank=True, null=True)
  category = models.ManyToManyField(Category)
  label = models.CharField(choices=LABEL_CHOICES, max_length=1)
  slug = models.SlugField()
  description = models.TextField()
  image = models.ImageField()

  def __str__(self):
      return self.title

  def get_absolute_url(self):
      return reverse("core:product", kwargs={
          'slug': self.slug
      })

  def get_add_to_cart_url(self):
      return reverse("core:add-to-cart", kwargs={
          'slug': self.slug
      })

  def get_remove_from_cart_url(self):
      return reverse("core:remove-from-cart", kwargs={
          'slug': self.slug
      })
</code>```

When you add item to the cart it goes to this table:

```<code>class OrderItem(models.Model):
  user = models.ForeignKey(settings.AUTH_USER_MODEL,
                         on_delete=models.CASCADE)
  ordered = models.BooleanField(default=False)
  item = models.ForeignKey(Item, on_delete=models.CASCADE)
  quantity = models.IntegerField(default=1)
</code>```

Can I just add a new foreign key to this table and everything would work as it should? How to deal with things like adding product from just one table? The field for the other would be blank then?

order model:

```<code>class Order(models.Model):
  user = models.ForeignKey(settings.AUTH_USER_MODEL,
                         on_delete=models.CASCADE)
  ref_code = models.CharField(max_length=20, blank=True, null=True)
  items = models.ManyToManyField(OrderItem)
  start_date = models.DateTimeField(auto_now_add=True)
  ordered_date = models.DateTimeField()
  ordered = models.BooleanField(default=False)
  shipping_address = models.ForeignKey(
      'Address', related_name='shipping_address', on_delete=models.SET_NULL, blank=True, null=True)
</code>```

and finally the new table, that will store other items:

```<code>class Accessory(models.Model):
  title = models.CharField(max_length=100)
  price = models.FloatField()
  discount_price = models.FloatField(blank=True, null=True)
  category = models.ManyToManyField(Category)
  label = models.CharField(choices=LABEL_CHOICES, max_length=1)
  slug = models.SlugField()
  description = models.TextField()
  image = models.ImageField()
</code>```

Anyone can help me get this to work with that new table called Accessory?

答:
Looking at your Item and Accessory model definitions, those two look very similar. My recommendation would be to create a OneToOne relationship between Accessory and Item tables, so you would not need to deal with this redundancy.

If you do it like this, all the functionalities related to Item table would be inherited by the Accessory table as well. I think it will reduce costs and overheads of changing your logic.

```<code>class Accessory(models.Model):
    item = models.OneToOneField(Item, on_delete=models.CASCADE)
    ...
    # other fields that will differ between Accessory and Item
</code>```

You can even use the connected Item record as your Accessory model's primary_key.

Body:
My website is currently adapted to deal with things like adding to the cart, removing from the cart and creating an order, only on one Item table. I wanted to add different products to the site, so I need to create a new table, that will handle other items. The thing is, that I am not really sure how to properly implement that to my website, so things like adding to the cart and creating order would work with that new table as well.

So thats the model of the first Item table:

class Item(models.Model):
  title = models.CharField(max_length=100)
  price = models.FloatField()
  discount_price = models.FloatField(blank=True, null=True)
  category = models.ManyToManyField(Category)
  label = models.CharField(choices=LABEL_CHOICES, max_length=1)
  slug = models.SlugField()
  description = models.TextField()
  image = models.ImageField()

  def __str__(self):
      return self.title

  def get_absolute_url(self):
      return reverse("core:product", kwargs={
          'slug': self.slug
      })

  def get_add_to_cart_url(self):
      return reverse("core:add-to-cart", kwargs={
          'slug': self.slug
      })

  def get_remove_from_cart_url(self):
      return reverse("core:remove-from-cart", kwargs={
          'slug': self.slug
      })

When you add item to the cart it goes to this table:

class OrderItem(models.Model):
  user = models.ForeignKey(settings.AUTH_USER_MODEL,
                         on_delete=models.CASCADE)
  ordered = models.BooleanField(default=False)
  item = models.ForeignKey(Item, on_delete=models.CASCADE)
  quantity = models.IntegerField(default=1)

Can I just add a new foreign key to this table and everything would work as it should? How to deal with things like adding product from just one table? The field for the other would be blank then?

order model:

class Order(models.Model):
  user = models.ForeignKey(settings.AUTH_USER_MODEL,
                         on_delete=models.CASCADE)
  ref_code = models.CharField(max_length=20, blank=True, null=True)
  items = models.ManyToManyField(OrderItem)
  start_date = models.DateTimeField(auto_now_add=True)
  ordered_date = models.DateTimeField()
  ordered = models.BooleanField(default=False)
  shipping_address = models.ForeignKey(
      'Address', related_name='shipping_address', on_delete=models.SET_NULL, blank=True, null=True)

and finally the new table, that will store other items:

class Accessory(models.Model):
  title = models.CharField(max_length=100)
  price = models.FloatField()
  discount_price = models.FloatField(blank=True, null=True)
  category = models.ManyToManyField(Category)
  label = models.CharField(choices=LABEL_CHOICES, max_length=1)
  slug = models.SlugField()
  description = models.TextField()
  image = models.ImageField()

Anyone can help me get this to work with that new table called Accessory?

Body:
Looking at your Item and Accessory model definitions, those two look very similar. My recommendation would be to create a OneToOne relationship between Accessory and Item tables, so you would not need to deal with this redundancy.

If you do it like this, all the functionalities related to Item table would be inherited by the Accessory table as well. I think it will reduce costs and overheads of changing your logic.

class Accessory(models.Model):
    item = models.OneToOneField(Item, on_delete=models.CASCADE)
    ...
    # other fields that will differ between Accessory and Item

You can even use the connected Item record as your Accessory model's primary_key.


问:
Why does it get same value?? and how to attach currency sign after result?
Why does it get same value?? and how to attach currency sign after result?
also, How to make it more briefly? I want to amend the repeating code.

function changeSign() {
  var currencySelect = document.getElementById("CurrencyID").value;
}

function changeCurrency() {

  var inputVal = parseFloat(document.getElementById("inputMoney").value);
  var currencyVal = parseFloat(document.getElementById("inputMoney"));

  if (document.getElementById("Euro")) {

    if (document.getElementById("Us1")) {

      currencyVal = (inputVal * 1.08);

    } else if (document.getElementById("Uk1")) {

      currencyVal = (inputVal * 0.83);

    } else if (document.getElementById("Ja1")) {

      currencyVal = (inputVal * 118.88);

    } else if (document.getElementById("Ca1")) {

      currencyVal = (inputVal * 1.43);
    }
  }

  document.getElementById("demo").textContent = currencyVal;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><b>Choose Convert : </b><br><br>
<select name="CurrencyConverter" id="CurrencyID" class="text ui-widget-content ui-corner-all" style="width: 200px; height:30px;" onchange="changeSign()">
  <option id="Euro" value="€">Euro (EUR)</option>
  <option id="Us" value="$">US Dollar (USD)</option>
  <option id="Uk" value="£">UK Pound Sterling (GBP)</option>
  <option id="Ja" value="¥">Japanese Yen (JPY)</option>
  <option id="Ca" value="$">Canadian Dollor (CAD)</option>
</select>
<br>

<b>Choose Convert : </b><br><br>
<select name="CurrencyConverter" id="CurrencyID" class="text ui-widget-content ui-corner-all" style="width: 200px; height:30px;">
  <option id="Euro1" value="€">Euro (EUR)</option>
  <option id="Us1" value="$">US Dollar (USD)</option>
  <option id="Uk1" value="£">UK Pound Sterling (GBP)</option>
  <option id="Ja1" value="¥">Japanese Yen (JPY)</option>
  <option id="Ca1" value="$">Canadian Dollor (CAD)</option>
</select>
<br>

<label>
                <br>
                <input name="inputMoney" id="inputMoney" type="text" class="text ui-widget-content ui-corner-all"
                    style="width: 196px; height:22px;" oninput="changeCurrency()"
                    >
            </label><br><br>

</div>
</div>

<p>value: <span id="demo"></span></p></code>```

答:
html

Choose Convert :

            Euro (EUR)
            US Dollar (USD)
            UK Pound Sterling (GBP)
            Japanese Yen (JPY)
            Canadian Dollor (CAD)

```<code>    <b>Choose Convert : </b><br><br>
    <select name="CurrencyConverter" id="convartToCurrencyID" class="text ui-widget-content ui-corner-all" style="width: 200px; height:30px;">
        <option id="Euro1" value="Euro1">Euro (EUR)</option>
        <option id="Us1" value="Us1">US Dollar (USD)</option>
        <option id="Uk1" value="Uk1">UK Pound Sterling (GBP)</option>
        <option id="Ja1" value="Ja1">Japanese Yen (JPY)</option>
        <option id="Ca1" value="Ca1">Canadian Dollor (CAD)</option>
    </select>
    <br>

            <label>
                <br>
                <input name="inputMoney" id="inputMoney" type="text" class="text ui-widget-content ui-corner-all" style="width: 196px; height:22px;" oninput="changeCurrency()" >
            </label><br><br>

</div>
</div>

<p>value: <span id="demo"></span></p>
</code>```

js code

```<code>function changeCurrency() {

    var currencySelect = document.getElementById("CurrencyID").value;
    var convartToCurrencyID = document.getElementById("convartToCurrencyID").value;

  var inputVal = parseFloat(document.getElementById("inputMoney").value);
  var currencyVal = parseFloat(document.getElementById("inputMoney"));

        if (currencySelect == "Us1" && convartToCurrencyID == "Us1") {

        currencyVal = (inputVal * 1);

        } else if (currencySelect == "Us1" && convartToCurrencyID == "Uk1") {

        currencyVal = (inputVal * 0.83);

        } else if (currencySelect == "Us1" && convartToCurrencyID == "Ja1") {

        currencyVal = (inputVal * 118.88);

        } else if (currencySelect == "Us1" && convartToCurrencyID == "Ca1") {

        currencyVal = (inputVal * 1.43);
        }

  document.getElementById("demo").textContent = currencyVal;
}
</code>```

This way you will have to adjust the condition for all of them

Now lets see that all will be convart from USD

Body:
Why does it get same value?? and how to attach currency sign after result?
also, How to make it more briefly? I want to amend the repeating code.

function changeSign() {
  var currencySelect = document.getElementById("CurrencyID").value;
}

function changeCurrency() {

  var inputVal = parseFloat(document.getElementById("inputMoney").value);
  var currencyVal = parseFloat(document.getElementById("inputMoney"));

  if (document.getElementById("Euro")) {

    if (document.getElementById("Us1")) {

      currencyVal = (inputVal * 1.08);

    } else if (document.getElementById("Uk1")) {

      currencyVal = (inputVal * 0.83);

    } else if (document.getElementById("Ja1")) {

      currencyVal = (inputVal * 118.88);

    } else if (document.getElementById("Ca1")) {

      currencyVal = (inputVal * 1.43);
    }
  }

  document.getElementById("demo").textContent = currencyVal;
}

Choose Convert :

<select name="CurrencyConverter" id="CurrencyID" class="text ui-widget-content ui-corner-all" style="width: 200px; height:30px;" onchange="changeSign()">
  <option id="Euro" value="€">Euro (EUR)</option>
  <option id="Us" value="$">US Dollar (USD)</option>
  <option id="Uk" value="£">UK Pound Sterling (GBP)</option>
  <option id="Ja" value="¥">Japanese Yen (JPY)</option>
  <option id="Ca" value="$">Canadian Dollor (CAD)</option>
</select>

Choose Convert :

<select name="CurrencyConverter" id="CurrencyID" class="text ui-widget-content ui-corner-all" style="width: 200px; height:30px;">
  <option id="Euro1" value="€">Euro (EUR)</option>
  <option id="Us1" value="$">US Dollar (USD)</option>
  <option id="Uk1" value="£">UK Pound Sterling (GBP)</option>
  <option id="Ja1" value="¥">Japanese Yen (JPY)</option>
  <option id="Ca1" value="$">Canadian Dollor (CAD)</option>
</select>

                <input name="inputMoney" id="inputMoney" type="text" class="text ui-widget-content ui-corner-all"
                    style="width: 196px; height:22px;" oninput="changeCurrency()"
                    >

value:

Body:
html

Choose Convert :

            Euro (EUR)
            US Dollar (USD)
            UK Pound Sterling (GBP)
            Japanese Yen (JPY)
            Canadian Dollor (CAD)

    <b>Choose Convert : </b><br><br>
    <select name="CurrencyConverter" id="convartToCurrencyID" class="text ui-widget-content ui-corner-all" style="width: 200px; height:30px;">
        <option id="Euro1" value="Euro1">Euro (EUR)</option>
        <option id="Us1" value="Us1">US Dollar (USD)</option>
        <option id="Uk1" value="Uk1">UK Pound Sterling (GBP)</option>
        <option id="Ja1" value="Ja1">Japanese Yen (JPY)</option>
        <option id="Ca1" value="Ca1">Canadian Dollor (CAD)</option>
    </select>
    <br>

            <label>
                <br>
                <input name="inputMoney" id="inputMoney" type="text" class="text ui-widget-content ui-corner-all" style="width: 196px; height:22px;" oninput="changeCurrency()" >
            </label><br><br>

</div>
</div>

<p>value: <span id="demo"></span></p>

js code

function changeCurrency() {

    var currencySelect = document.getElementById("CurrencyID").value;
    var convartToCurrencyID = document.getElementById("convartToCurrencyID").value;

  var inputVal = parseFloat(document.getElementById("inputMoney").value);
  var currencyVal = parseFloat(document.getElementById("inputMoney"));

        if (currencySelect == "Us1" && convartToCurrencyID == "Us1") {

        currencyVal = (inputVal * 1);

        } else if (currencySelect == "Us1" && convartToCurrencyID == "Uk1") {

        currencyVal = (inputVal * 0.83);

        } else if (currencySelect == "Us1" && convartToCurrencyID == "Ja1") {

        currencyVal = (inputVal * 118.88);

        } else if (currencySelect == "Us1" && convartToCurrencyID == "Ca1") {

        currencyVal = (inputVal * 1.43);
        }

  document.getElementById("demo").textContent = currencyVal;
}

This way you will have to adjust the condition for all of them

Now lets see that all will be convart from USD


问:
Transpose data in SQL with new column
I have a data like:

```<code>id maths phy chem
1   50   60   21
2   60   80   22
3   80   90   23
</code>```

Now I want it to look like:

```<code>sub   1   2   3
math 50  60  80
phy  60  80  90
chem 21  22  23
</code>```

my code:

```<code>select *
  from mrks
    pivot
(
  max(maths)
  for id in ([1], [2], [3])
) piv
</code>```

however I'm facing 2 issues

I am not able to transpose chem and phy values

Not able to group maths, phy and chem under subj

答:
You can't do PIVOT on multiple columns, you can achieve the desired output by using UNION as following.

```<code>SELECT 'Math' AS Sub,*
FROM (SELECT id ,maths FROM mrks) t
PIVOT(MAX(maths) FOR id IN ([1], [2], [3])) piv

UNION ALL

SELECT 'Phy' AS Sub,*
FROM (SELECT id,phy FROM mrks) t
PIVOT(MAX(phy) FOR id IN ([1], [2], [3])) piv

UNION ALL

SELECT 'Chem' AS Sub,*
FROM (SELECT id,chem FROM mrks) t
PIVOT(MAX(chem) FOR id IN ([1], [2], [3])) piv
</code>```

Title: Transpose data in SQL with new column

Body:
I have a data like:

id maths phy chem
1   50   60   21
2   60   80   22
3   80   90   23

Now I want it to look like:

sub   1   2   3
math 50  60  80
phy  60  80  90
chem 21  22  23

my code:

select *
  from mrks
    pivot
(
  max(maths)
  for id in ([1], [2], [3])
) piv

however I'm facing 2 issues

I am not able to transpose chem and phy values

Not able to group maths, phy and chem under subj

Body:
You can't do PIVOT on multiple columns, you can achieve the desired output by using UNION as following.

SELECT 'Math' AS Sub,*
FROM (SELECT id ,maths FROM mrks) t
PIVOT(MAX(maths) FOR id IN ([1], [2], [3])) piv

UNION ALL

SELECT 'Phy' AS Sub,*
FROM (SELECT id,phy FROM mrks) t
PIVOT(MAX(phy) FOR id IN ([1], [2], [3])) piv

UNION ALL

SELECT 'Chem' AS Sub,*
FROM (SELECT id,chem FROM mrks) t
PIVOT(MAX(chem) FOR id IN ([1], [2], [3])) piv


问:
How to resolve "The located assembly's manifest definition does not match the assembly reference." error?
I downloaded source code for pdfiumviewer from git hub. I made changes to one of the projects in that solution.Then I added that project to my application and added reference of that project to one my application's project.I had to uncheck the Signing option for the PDfiumViewer project, as some of the dll in that project are unsigned.I am able to build the application successfully.But at run time when I create an object of one of the class of PDfiumviewer project.It gives me the following error:

Could not load file or assembly 'PdfiumViewer, Version=2.11.0.0,
  Culture=neutral, PublicKeyToken=null' or one of its dependencies. The
  located assembly's manifest definition does not match the assembly
  reference. (Exception from HRESULT: 0x80131040)

The version number of the assembly is correct.So, why am I getting this error?

答: Ive also encountered this issue, my scenario was thou that I had to add a reference from another solution into my project removing the reference was not an option - what worked for me was reinstall SQLclient from nuget package managerer on both solution. Hopes it helo someone else</p>

ContentLicense: CC BY-SA 3.0


问:
Using position to count nodes - sometimes enumeration starts at 0 instead of 1
Hey folks,
 I've got this rather clumbsy piece of xslt which I use to transform SOAPUI test cases into a more readable format. Currently it enumerates the test cases using the following

<xsl:value-of select="position()-3"/>

My question Sometimes the test case enumeration starts at 0 and sometimes it starts at 1. I don't understand why this is happening? Is it something to do with how the position selector is implemented? Is there a neater way to count instances of a node?

Many thanks,

Richard

Here is the code in its entirety - sans styling.

`

```<code>  <!-- Edited by XMLSpy® -->
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:con="http://eviware.com/soapui/config">
    <xsl:output method="html" encoding ="utf-8"/>
    <xsl:template match="/">
      <html>
        <head>
          <script type="text/javascript">
            function toggleDiv(divid){
                var ele = document.getElementById(divid);

                if(ele.style.display == 'none')
                    {
                        ele.style.display = 'block';
                    }
                else
                    {
                        ele.style.display = 'none';
                    }
                }
          </script>

            <style type="text/css"></style>

        </head>

        <body>

          <xsl:apply-templates/>

          <div class="help">This report is generated automatically by a scheduled job running on Richard Fortune's machine. The SOAPUI project files it references are located in sourcecontrol SVN (https://svn.xxx.xxxxxx.com/svn/network/TEST). These reports are generated daily as the projects they reference are subject to change.</div>

        </body>
      </html>

    </xsl:template>

    <xsl:template match="con:soapui-project">
     <div><h1>Project Name : <xsl:value-of select="@name"/></h1></div>
      <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="con:testSuite">

    <xsl:if test="con:description=''">
                <p class="warn"> (RICHARD - PLEASE PROVIDE A DESCRIPTION!!)</p>
    </xsl:if>
      <div id="content" onmousedown="toggleDiv('{position()}');"><h2 class="ex">TestSuite:  <xsl:value-of select="@name"/></h2></div>
      <br>
        <p class="descSuite"><b>Suite Description: </b><xsl:value-of select="con:description"/></p>
      </br>

      <div style="display:none" id="{position()}"><xsl:apply-templates />
      </div>
    </xsl:template>

    <xsl:template match="con:testCase">

        <ul>
          <li class="tc"><b>
            (#<xsl:value-of select="position()-3"/>) Testcase: </b><xsl:value-of select="@name"/>
          </li>

          <xsl:if test="con:description=''">
            <p class="warn">(Gentle reminder Richard - PLEASE PROVIDE A DESCRIPTION!!)</p>
          </xsl:if>

          <p class="descTc">
            <strong><i>Description:</i></strong> <xsl:value-of select="con:description"/>
          </p>
          <ol class="step">
          <xsl:for-each select="con:testStep"><li>TestStep: <xsl:value-of select="@name"/> </li></xsl:for-each>
          </ol>

        </ul>
        <xsl:apply-templates />

    </xsl:template>

    <xsl:template match="*"></xsl:template>

  </xsl:stylesheet>
</code>```

`

答:
I suggest you to use count():

```<code><xsl:value-of select="count(preceding-sibling::*)+1"/>
</code>```

This returns the current position of the node respect to all its sibling elements (1-based).

position() might be not the proper way depending on the context.

Body:
Hey folks,
 I've got this rather clumbsy piece of xslt which I use to transform SOAPUI test cases into a more readable format. Currently it enumerates the test cases using the following

<xsl:value-of select="position()-3"/>

My question Sometimes the test case enumeration starts at 0 and sometimes it starts at 1. I don't understand why this is happening? Is it something to do with how the position selector is implemented? Is there a neater way to count instances of a node?

Many thanks,

Richard

Here is the code in its entirety - sans styling.

`

  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:con="http://eviware.com/soapui/config">
    <xsl:output method="html" encoding ="utf-8"/>
    <xsl:template match="/">

          <xsl:apply-templates/>

This report is generated automatically by a scheduled job running on Richard Fortune's machine. The SOAPUI project files it references are located in sourcecontrol SVN (https://svn.xxx.xxxxxx.com/svn/network/TEST). These reports are generated daily as the projects they reference are subject to change.

    </xsl:template>

    <xsl:template match="con:soapui-project">

Project Name : <xsl:value-of select="@name"/>

      <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="con:testSuite">

    <xsl:if test="con:description=''">

 (RICHARD - PLEASE PROVIDE A DESCRIPTION!!)

    </xsl:if>

TestSuite:  <xsl:value-of select="@name"/>

Suite Description: <xsl:value-of select="con:description"/>

<xsl:apply-templates />

    </xsl:template>

    <xsl:template match="con:testCase">

            (#<xsl:value-of select="position()-3"/>) Testcase: <xsl:value-of select="@name"/>

          <xsl:if test="con:description=''">

(Gentle reminder Richard - PLEASE PROVIDE A DESCRIPTION!!)

          </xsl:if>

            Description: <xsl:value-of select="con:description"/>

          <xsl:for-each select="con:testStep">
TestStep: <xsl:value-of select="@name"/>
</xsl:for-each>

        <xsl:apply-templates />

    </xsl:template>

    <xsl:template match="*"></xsl:template>

  </xsl:stylesheet>

`

Body:
I suggest you to use count():

<xsl:value-of select="count(preceding-sibling::*)+1"/>

This returns the current position of the node respect to all its sibling elements (1-based).

position() might be not the proper way depending on the context.


问:
Akka pre-mature termination
I'm experiencing early termination of the AkkaSystem after first record being read ,entering into the Dead letter without executing the task for all the records

I have 10records in my file , 2 of the records has the matching filename to be pushed to s3.

what could be going wrong here. Please suggest

```<code>Sample file record:
xxxxx,ABC,2019-05-10 00:11:00
yyyyyy,XYZ,2019-05-10 00:41:00
</code>```

```<code>import akka.actor.{Actor, ActorSystem, Props}

import scala.io.Source
import scala.sys.process._

class HelloActor extends Actor {

  def receive: Receive = {
    case line: String => {
      //        print("Ahshan"+line)
      val row = line.split ( "," )
      val stdout = new StringBuilder
      val stderr = new StringBuilder
      val status = Seq ( "/bin/sh", "-c", "ls /Users/ahshan.md/Downloads/".concat ( row ( 2 ).substring ( 0, 10 ) ).concat ( "/*" ).concat ( row ( 0 ) ).concat ( "*" ) ) ! ProcessLogger ( stdout append _, stderr append _ )
      //        println(status)
      //        println("stdout: " + stdout)
      //        println("stderr: " + stderr)
      if (status == 0) {
        println ( "/bin/sh", "-c", "aws s3 cp ".concat ( stdout.mkString ).concat ( "  " ).concat ( "s3://ahshan/".concat ( row ( 1 ) ).concat ( "/" ).concat ( row ( 0 ) ).concat ( ".email" ) ) )
      }
      else {
        //      println ( "File Not Found:   " + row ( 0 ), row ( 1 ), row ( 2 ).substring ( 0, 10 ) )
        println ( "stderr: " + stderr )
      }
    }

    case "finished" => println ( "Hello Ahshan" )
    case _ => println ( "Exiting" )

  }

}

object AkkaHelloWorld extends App {

  // an actor needs an ActorSystem
  val system = ActorSystem ( "HelloSystem" )
  // create and start the actor
  val helloActor = system.actorOf ( Props [HelloActor], name = "helloActor" )

  try {
    val filename = "/Users/ahshan.md/Downloads/test.txt"
    for (line <- Source.fromFile ( filename ).getLines) {
      helloActor ! line
    }
  }
  finally {

system.terminate ()
  }
}
</code>```

答:
The ActorSystem and the actors run concurrently with your main thread, sending a message to an actor is async and the sending thread immediately continues, it does not wait for the actor to process the message.

This means that in your code the main thread fires off each line to the actor as fast as it can and then terminates the actor system. In this example it could make sense to move the termination logic into the actor and let the actor terminate the system when it has completed.

That will only work as long as your application is a single actor though, as soon as you add another actor you will have to revisit how you terminate the system.

As an additional note using the process API in Scala like that will block until the process has completed, calling blocking code can have bad consequences, read this section of the docs for more details: https://doc.akka.io/docs/akka/current/typed/dispatchers.html#blocking-needs-careful-management

Title: Akka pre-mature termination

Body:
I'm experiencing early termination of the AkkaSystem after first record being read ,entering into the Dead letter without executing the task for all the records

I have 10records in my file , 2 of the records has the matching filename to be pushed to s3.

what could be going wrong here. Please suggest

Sample file record:
xxxxx,ABC,2019-05-10 00:11:00
yyyyyy,XYZ,2019-05-10 00:41:00

import akka.actor.{Actor, ActorSystem, Props}

import scala.io.Source
import scala.sys.process._

class HelloActor extends Actor {

  def receive: Receive = {
    case line: String => {
      //        print("Ahshan"+line)
      val row = line.split ( "," )
      val stdout = new StringBuilder
      val stderr = new StringBuilder
      val status = Seq ( "/bin/sh", "-c", "ls /Users/ahshan.md/Downloads/".concat ( row ( 2 ).substring ( 0, 10 ) ).concat ( "/*" ).concat ( row ( 0 ) ).concat ( "*" ) ) ! ProcessLogger ( stdout append _, stderr append _ )
      //        println(status)
      //        println("stdout: " + stdout)
      //        println("stderr: " + stderr)
      if (status == 0) {
        println ( "/bin/sh", "-c", "aws s3 cp ".concat ( stdout.mkString ).concat ( "  " ).concat ( "s3://ahshan/".concat ( row ( 1 ) ).concat ( "/" ).concat ( row ( 0 ) ).concat ( ".email" ) ) )
      }
      else {
        //      println ( "File Not Found:   " + row ( 0 ), row ( 1 ), row ( 2 ).substring ( 0, 10 ) )
        println ( "stderr: " + stderr )
      }
    }

    case "finished" => println ( "Hello Ahshan" )
    case _ => println ( "Exiting" )

  }

}

object AkkaHelloWorld extends App {

  // an actor needs an ActorSystem
  val system = ActorSystem ( "HelloSystem" )
  // create and start the actor
  val helloActor = system.actorOf ( Props [HelloActor], name = "helloActor" )

  try {
    val filename = "/Users/ahshan.md/Downloads/test.txt"
    for (line <- Source.fromFile ( filename ).getLines) {
      helloActor ! line
    }
  }
  finally {

system.terminate ()
  }
}


问:
RMarkdown knitting error papaja apa6 - rmdfiltr add wordcount filter
I get the following error when knitting papaja::apa6_pdf docs. I'm running R version 3.6.2 with macOS Mojave (10.14.6) on my MacBook Pro. Any ideas?</p>

```<code>Error in rmdfiltr::add_wordcount_filter(args, report = "warn") :
  unused argument (report = "warn")
Calls: <Anonymous> -> <Anonymous> -> pdf_pre_processor
Execution halted
</code>```

答: This error is caused by incompatible versions of papaja and rmdfiltr. Updating papaja (e.g. devtools::install_github("crsh/papaja@devel")) should fix this issue.

Body:
I get the following error when knitting papaja::apa6_pdf docs. I'm running R version 3.6.2 with macOS Mojave (10.14.6) on my MacBook Pro. Any ideas?

Error in rmdfiltr::add_wordcount_filter(args, report = "warn") :
  unused argument (report = "warn")
Calls: <Anonymous> -> <Anonymous> -> pdf_pre_processor
Execution halted


问:
Site with both Window and Anonymous authentication on IIS
I want to host an application on IIS with both windows and anonymous modes. I know it is not possible to run website with both modes on as when I enable anonymous mode, window authentication do not work. What are other alternates by which I can run application in both modes with preference to windows.

P.S I can run two websites but their physical path should be same. Also the original website has binding to server default address, any virtual directory converted to default application by default ask for window authentication. e.g.

172.16.128.190;www.xYZ.com binds to path E:/applications/XYZ

172.16.128.190/MS in default application is mapped to E:applications/MS

Now if I disable window authentication on later application it by default picks authentication from first application (inheritance)

In other scenario I can make another site but same physical path

172.16.128.190;www.xYZ.com binds to path E:/applications/XYZ (Window)

www.xYZipad.com binds to path E:/applications/XYZ (Anonymous)

Please provide possible solutions.

答:
it is not possible to enable both authentications for the same site. if you still host the same folder as an application then it is also not possible because that folder uses the same web.config file.

Your best option is to create a folder where all your secured stuff goes and enable windows authentication on that folder. Keep your public bits in other folders and the root.

You could refer below link:

IIS Mixed Anonymous and Windows Authentication


问:
WGCNA : Choosing a soft-threshold power
powers = c(c(1:10), seq(from = 12, to=20, by=2));

While going through WGCNA i came across this code which i am not able to understand, can anybody explain me the meaning of that piece of code

答:
The code will create a vector of numbers stored in powers.

Specifically: 1:10 creates the numbers 1 2 3 4 5 6 7 8 9 10 (can read as 1 through 10) and seq(from = 12, to = 20, by = 2) creates a sequence of every other number from 12 to 20, i.e. 12 14 16 18 20.

Powers will contain the following 15 numbers: 1  2  3  4  5  6  7  8  9 10 12 14 16 18 20

I am not familiar with the WGCNApackage or if powers is an argument to a function, but this is what powers contains.

Title: WGCNA : Choosing a soft-threshold power


问:
Is the rule of ReactJS re-rendering just: if the state of component changes, then the whole sub-tree is re-rendered?
First of all, by "re-render", here it means either

the render() method of any class component is called, OR

the function of the function component is called.

Let's called the element in the actual DOM changing a "refresh", to distinguish it from "re-render".

Is the rule of "re-render" as simple as:

When any state of a component is changed, then the component and all the subtree down from this component is re-rendered

and that's it?  For example:

function A() {
  console.log("Component A re-render");

  return
Component A says Hello World
;
}

function App() {
  const [counter, setCounter] = React.useState(0);

  console.log("Component App re-render");

  function increaseCount() {
    setCounter(c => c + 1);
  }

  return (

      {counter}
      <button onClick={increaseCount} >Increment</button>

  )
}

ReactDOM.render(<App />, document.querySelector("#root"));```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://unpkg.com/react@16.12.0/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@16.12.0/umd/react-dom.development.js" crossorigin></script>

<div id="root"></div></code>```

Component A is so simple: it doesn't even take any props and is just outputting static text, yet it is still called every time (by looking at the console.log() output).

But even though it is "re-rendered", the actual DOM element is not "refreshed", as seen in Google Chrome's Inspect Element that the DOM element is not flashing for Component A, but is only flashing for the counter number.

So is this how it works?

Whenever any state of a component is changed, that component and the whole subtree will be "re-rendered".

But ReactJS will "reconcile" the content of the "Virtual DOM" that it built using those JSX with the content of the actual DOM, and if the content is different, "refresh the actual DOM".

But having said that, it seems ReactJS doesn't actually reconcile with the actual DOM, but reconcile with probably the "previous virtual DOM". Why?  Because if I use a setTimeout() to change the actual DOM of Component A to some other content after 3 seconds, and click the button, ReactJS doesn't change the content of Component A back to "Hello World". Example:

function A() {
  console.log("Component A re-render");

  return
Component A says Hello World
;
}

function App() {
  const [counter, setCounter] = React.useState(0);

  console.log("Component App re-render");

  function increaseCount() {
    setCounter(c => c + 1);
  }

  return (

      {counter}
      <button onClick={increaseCount} >Increment</button>

  )
}

ReactDOM.render(<App />, document.querySelector("#root"));

setTimeout(function() {
  document.querySelector("#foo").innerText = "hi"
}, 3000);```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://unpkg.com/react@16.12.0/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@16.12.0/umd/react-dom.development.js" crossorigin></script>

<div id="root"></div></code>```

答: After rendering react gets a json of how the view should look like, calculates the changes and then changes the actual dom. So even though A is rerendered the output json will be same as virtual dom's and hence react does not touch the dom</p>

Body:
First of all, by "re-render", here it means either

the render() method of any class component is called, OR

the function of the function component is called.

Let's called the element in the actual DOM changing a "refresh", to distinguish it from "re-render".

Is the rule of "re-render" as simple as:

When any state of a component is changed, then the component and all the subtree down from this component is re-rendered

and that's it?  For example:

function A() {
  console.log("Component A re-render");

  return
Component A says Hello World
;
}

function App() {
  const [counter, setCounter] = React.useState(0);

  console.log("Component App re-render");

  function increaseCount() {
    setCounter(c => c + 1);
  }

  return (

      {counter}
      <button onClick={increaseCount} >Increment</button>

  )
}

ReactDOM.render(<App />, document.querySelector("#root"));

Component A is so simple: it doesn't even take any props and is just outputting static text, yet it is still called every time (by looking at the console.log() output).

But even though it is "re-rendered", the actual DOM element is not "refreshed", as seen in Google Chrome's Inspect Element that the DOM element is not flashing for Component A, but is only flashing for the counter number.

So is this how it works?

Whenever any state of a component is changed, that component and the whole subtree will be "re-rendered".

But ReactJS will "reconcile" the content of the "Virtual DOM" that it built using those JSX with the content of the actual DOM, and if the content is different, "refresh the actual DOM".

But having said that, it seems ReactJS doesn't actually reconcile with the actual DOM, but reconcile with probably the "previous virtual DOM". Why?  Because if I use a setTimeout() to change the actual DOM of Component A to some other content after 3 seconds, and click the button, ReactJS doesn't change the content of Component A back to "Hello World". Example:

function A() {
  console.log("Component A re-render");

  return
Component A says Hello World
;
}

function App() {
  const [counter, setCounter] = React.useState(0);

  console.log("Component App re-render");

  function increaseCount() {
    setCounter(c => c + 1);
  }

  return (

      {counter}
      <button onClick={increaseCount} >Increment</button>

  )
}

ReactDOM.render(<App />, document.querySelector("#root"));

setTimeout(function() {
  document.querySelector("#foo").innerText = "hi"
}, 3000);


问:
How to add commas every 3 digits character for string in Microsoft Server SQL?
Is there a built-in function for this task? If not, how can it be done? It is varchar(20), and it only contains integers. For example, 309000 -> 309,000.

Any idea?

Thanks,

ContentLicense: CC BY-SA 2.5

Body:
You may use

SELECT FORMAT(2123456789, '#,#')


问:
Check Whether a DIV Reaches it End on Window Scroll in Javascript
I have a div of dynamic content so it height depends on dynamic data. when i scroll the browser window to bottom, if the that div reaches its end (bottom) on the view, i want to trigger a function (for now just console it ('reached bottom of div')). Also if browser reached the end of the page, the same function wants to trigger.  how to achieve this im new to JS and innerHeight, clientHeight so on.. are confusing.

body {
  min-height: 500px;
  background-color: yellow;
}

.dynamicDiv {
  min-height: 200px;
  background-color: red;
  color: #fff;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="dynamicDiv">
  some Dynamic data
</div></code>```

答:
window.innerHeight property returns the height of a window's content area.
window.scrollY returns the number of pixels that the document is currently scrolled vertically.
document.body.offsetHeight returns body's height including padding and border

https://jsfiddle.net/smilingpigs/n1vcx3po/4/

```<code>window.onscroll = function(ev) {
    if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
        alert("you are at the bottom of the page");
    }
};
</code>```

Body:
I have a div of dynamic content so it height depends on dynamic data. when i scroll the browser window to bottom, if the that div reaches its end (bottom) on the view, i want to trigger a function (for now just console it ('reached bottom of div')). Also if browser reached the end of the page, the same function wants to trigger.  how to achieve this im new to JS and innerHeight, clientHeight so on.. are confusing.

body {
  min-height: 500px;
  background-color: yellow;
}

.dynamicDiv {
  min-height: 200px;
  background-color: red;
  color: #fff;
}

  some Dynamic data

Body:
window.innerHeight property returns the height of a window's content area.
window.scrollY returns the number of pixels that the document is currently scrolled vertically.
document.body.offsetHeight returns body's height including padding and border

https://jsfiddle.net/smilingpigs/n1vcx3po/4/

window.onscroll = function(ev) {
    if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
        alert("you are at the bottom of the page");
    }
};


问:
Is there any solution to the error while loading SIVP module to scilab
SIVP - Scilab Image and Video Processing Toolbox
    Load macros
atomsLoad: An error occurred while loading 'SIVP-0.5.3.2':
    lib: Old binary lib detected. Please recompile it for Scilab 6.

help me get out of this problem

答: sivp has not been ported to scilab 6. If you want to do some image processing you should rather use IPCV atoms module. </p>


问:
Perl : creating array of known size

I have to store data from request runned with Parallel::ForkManager.

But it comes not in order, I mean, I poll all ports of a switch, but some of them answer faster than others. So, I don't know how to save it, to display it later.

Can I do like that ?

```<code>my @array = ();
$array[10] = "i am a string corresponding to port 10"
$array[2] = "the one for the port 2"
...
print @array;
</code>```

Or should I use a %hash with number of port as keys, but it seems not the best.

Thank you.

答:
In Perl you don't have to worry about the sizes of arrays.  They grow as needed:

```<code>my @array; # defines an empty array

$array[0] = 4; # array has one element
$array[9] = 20; # array has 10 elements now

print join "-", @array;

# prints: 4--------20 because the empty places are undef
</code>```

If you have many ports and are worried about having too many empty entries, use a hash.  I can't see any reason not to do it.

Title: Perl : creating array of known size

Body:
I have to store data from request runned with Parallel::ForkManager.

But it comes not in order, I mean, I poll all ports of a switch, but some of them answer faster than others. So, I don't know how to save it, to display it later.

Can I do like that ?

my @array = ();
$array[10] = "i am a string corresponding to port 10"
$array[2] = "the one for the port 2"
...
print @array;

Or should I use a %hash with number of port as keys, but it seems not the best.

Thank you.

Body:
In Perl you don't have to worry about the sizes of arrays.  They grow as needed:

my @array; # defines an empty array

$array[0] = 4; # array has one element
$array[9] = 20; # array has 10 elements now

print join "-", @array;

# prints: 4--------20 because the empty places are undef

If you have many ports and are worried about having too many empty entries, use a hash.  I can't see any reason not to do it.


问:
Pandas remove the row index from the pandas dataframe
i have a dataframe with the data as follows

```<code>  id  Name   Age
0  1  XXX    30
</code>```

and i have to remove the 0(the row index value) from the dataframe.

I have tried the folowing

```<code>df.reset_index(inplace=True) # Resets the index, makes factor a column
df.drop("Factor",axis=1,inplace=True)
</code>```

but it is not removing the 0.

i want output like:

```<code>id  Name   Age
 1  XXX    30
</code>```

答:
In Pandas index is not a separate column that you can remove. It's an indicator like the indicator in array and dictionary.

For example if you have:

```<code>letters = ["a", "b", "c", "d", "e"]
letters[2]
</code>```

2 is an indicator that cannot be removed from array.

But depending your use of dataframe you can tell pandas not to show index in the export.

Body:
i have a dataframe with the data as follows

  id  Name   Age
0  1  XXX    30

and i have to remove the 0(the row index value) from the dataframe.

I have tried the folowing

df.reset_index(inplace=True) # Resets the index, makes factor a column
df.drop("Factor",axis=1,inplace=True)

but it is not removing the 0.

i want output like:

id  Name   Age
 1  XXX    30

Body:
In Pandas index is not a separate column that you can remove. It's an indicator like the indicator in array and dictionary.

For example if you have:

letters = ["a", "b", "c", "d", "e"]
letters[2]

2 is an indicator that cannot be removed from array.

But depending your use of dataframe you can tell pandas not to show index in the export.


问:
Can't find entry point
I wanted to create an new c++ project and start coding. I am working in an existing solution with 30+ projects in it. So instead of main() GwMain(..) is used. This works for all other files but not when I create a new c++ project. I get a linker error:

```<code>LNK2019 unresolved external symbol _main referenced in function "int__cdel invoke_main(void)" (?invoke_main@@YAHXZ)

File: MSVCRTD.lib(exe_main.obj)
</code>```

I already compared the property configs with the other projects and
it is nearly the same. The solution is migrated from visual studio
2012 to 2019 I guess this is one of the reasons why it is not working
how it should.

I checked already this: Linker->System->SubSystem -> Windows.

And when I change it from console to windows it shows this:

LNK2019 unresolved external symbol _WinMain referenced in function
"int__cdel invoke_main(void)" (?invoke_main@@YAHXZ)

And I do not use cmake

When I use int main(){return 0;} I get no errors, but I have to use
GwMain()

When I change Under Advanced the EntryPoint I actually get more
errors. I tried to insert GwMain.

The code is just like this:

```<code>#include <gwcore.hpp>
#include <gw.hpp>

int GwMain(int, char**)
{

    return 0;
}
</code>```

Grit is used here a very old framework.

答:
Please check Project > Properties > General > Project Defaults > Configuration Type.

If this is ".exe" then a main is needed for this project. Else if this is ".dll" or ".lib" your code should compile.

Title: Can't find entry point

Body:
I wanted to create an new c++ project and start coding. I am working in an existing solution with 30+ projects in it. So instead of main() GwMain(..) is used. This works for all other files but not when I create a new c++ project. I get a linker error:

LNK2019 unresolved external symbol _main referenced in function "int__cdel invoke_main(void)" (?invoke_main@@YAHXZ)

File: MSVCRTD.lib(exe_main.obj)

I already compared the property configs with the other projects and
it is nearly the same. The solution is migrated from visual studio
2012 to 2019 I guess this is one of the reasons why it is not working
how it should.

I checked already this: Linker->System->SubSystem -> Windows.

And when I change it from console to windows it shows this:

LNK2019 unresolved external symbol _WinMain referenced in function
"int__cdel invoke_main(void)" (?invoke_main@@YAHXZ)

And I do not use cmake

When I use int main(){return 0;} I get no errors, but I have to use
GwMain()

When I change Under Advanced the EntryPoint I actually get more
errors. I tried to insert GwMain.

The code is just like this:

#include <gwcore.hpp>
#include <gw.hpp>

int GwMain(int, char**)
{

    return 0;
}

Grit is used here a very old framework.


问:
Dynamicallly retrieve Spring Boot CORS Configuration from database for specific method in a Controller
I am trying to set the CORS configuration at Controller level using

```<code>@CrossOrigin on Controller and Handler Method

public class AccountController {

@CrossOrigin("retreive data from DB")
@RequestMapping("/{id}")
public Account retrieve(@PathVariable Long id) {
    // ...
}
</code>```

}

I have tried using below  but its set only when the spring boot starts and takes changes only when the service is restarted next time ...

```<code>@Bean
public CorsFilter corsFilter() {
    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
   // CorsConfiguration config = jHipsterProperties.getCors();

       CorsConfiguration config=CorsService.fetchCorsConfigFromDb;
    if (config.getAllowedOrigins() != null && !config.getAllowedOrigins().isEmpty()) {
        log.debug("Registering CORS filter");
        source.registerCorsConfiguration("/api/**", config);
        source.registerCorsConfiguration("/management/**", config);
        source.registerCorsConfiguration("/v2/api-docs", config);
    }
    return new CorsFilter(source);
}
</code>```

fetchCorsConfigFromDb will fetch data from DB. Any changes from DB will be reflected only when Spring Boot App is restarted...

答:
To implement this functionality you can use a basic filter in which you can write your custom database logic to add CORS header to your request based on some database attribute value.

You can refer to below example to implement this functionality using spring-data-jpa.

Add DB connection attributes to application.properties file

application.properties

```<code>spring.jpa.database=POSTGRESQL
spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=update

spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/testdb
spring.datasource.username=postgres
spring.datasource.password=root
</code>```

Create a entity with below attribute to save URL in DB

Cors.java

```<code>@Entity
@Getter
@Setter
public class Cors {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;
    private String url;
    private boolean isAllowed;
}
</code>```

And in the repository added a findByUrl method to get value from DB based on URL

CorsRepository.java

```<code>public interface CorsRepository extends JpaRepository<Cors,Long> {
    Optional<Cors> findByUrl(String url);
}
</code>```

Below is my filter to intercept request and make DB call and if isAllowed is true then i add cors headers to make a successful request

CorsFilter.java

```<code>@Component
public class CorsFilter implements Filter {
    @Autowired
    CorsRepository corsRepository;

    @Override
    public void init(FilterConfig filterConfig) throws ServletException { }

    @Override
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) req;
        String url = request.getRequestURI().toString();
        System.out.println(url);

        Optional<Cors> cors = corsRepository.findByUrl(url);
        if(cors.isPresent() && cors.get().isAllowed()){
            HttpServletResponse response = (HttpServletResponse) res;

            response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
            response.setHeader("Access-Control-Allow-Credentials", "true");
            response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
            response.setHeader("Access-Control-Max-Age", "3600");
            response.setHeader("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With, remember-me");
        }
        chain.doFilter(req, res);
    }

    @Override
    public void destroy() { }
}
</code>```

You can create a sample controller like this:

CorsTesterController.java

```<code>@RestController
public class CorsTesterController {

    @GetMapping("/api/v1/test")
    String getResponse(){
        return "test response";
    }
}
</code>```

and insert values to DB to allow/disallow a url to test this example code.

```<code>testdb=# select * from cors;
 id | is_allowed |       url
----+------------+-----------------
  1 | f          | /api/v1/block
  2 | t          | /api/v1/allowed
</code>```

Body:
I am trying to set the CORS configuration at Controller level using

@CrossOrigin on Controller and Handler Method

public class AccountController {

@CrossOrigin("retreive data from DB")
@RequestMapping("/{id}")
public Account retrieve(@PathVariable Long id) {
    // ...
}

}

I have tried using below  but its set only when the spring boot starts and takes changes only when the service is restarted next time ...

@Bean
public CorsFilter corsFilter() {
    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
   // CorsConfiguration config = jHipsterProperties.getCors();

       CorsConfiguration config=CorsService.fetchCorsConfigFromDb;
    if (config.getAllowedOrigins() != null && !config.getAllowedOrigins().isEmpty()) {
        log.debug("Registering CORS filter");
        source.registerCorsConfiguration("/api/**", config);
        source.registerCorsConfiguration("/management/**", config);
        source.registerCorsConfiguration("/v2/api-docs", config);
    }
    return new CorsFilter(source);
}

fetchCorsConfigFromDb will fetch data from DB. Any changes from DB will be reflected only when Spring Boot App is restarted...

Body:
To implement this functionality you can use a basic filter in which you can write your custom database logic to add CORS header to your request based on some database attribute value.

You can refer to below example to implement this functionality using spring-data-jpa.

Add DB connection attributes to application.properties file

application.properties

spring.jpa.database=POSTGRESQL
spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=update

spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/testdb
spring.datasource.username=postgres
spring.datasource.password=root

Create a entity with below attribute to save URL in DB

Cors.java

@Entity
@Getter
@Setter
public class Cors {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;
    private String url;
    private boolean isAllowed;
}

And in the repository added a findByUrl method to get value from DB based on URL

CorsRepository.java

public interface CorsRepository extends JpaRepository<Cors,Long> {
    Optional<Cors> findByUrl(String url);
}

Below is my filter to intercept request and make DB call and if isAllowed is true then i add cors headers to make a successful request

CorsFilter.java

@Component
public class CorsFilter implements Filter {
    @Autowired
    CorsRepository corsRepository;

    @Override
    public void init(FilterConfig filterConfig) throws ServletException { }

    @Override
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) req;
        String url = request.getRequestURI().toString();
        System.out.println(url);

        Optional<Cors> cors = corsRepository.findByUrl(url);
        if(cors.isPresent() && cors.get().isAllowed()){
            HttpServletResponse response = (HttpServletResponse) res;

            response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
            response.setHeader("Access-Control-Allow-Credentials", "true");
            response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
            response.setHeader("Access-Control-Max-Age", "3600");
            response.setHeader("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With, remember-me");
        }
        chain.doFilter(req, res);
    }

    @Override
    public void destroy() { }
}

You can create a sample controller like this:

CorsTesterController.java

@RestController
public class CorsTesterController {

    @GetMapping("/api/v1/test")
    String getResponse(){
        return "test response";
    }
}

and insert values to DB to allow/disallow a url to test this example code.

testdb=# select * from cors;
 id | is_allowed |       url
----+------------+-----------------
  1 | f          | /api/v1/block
  2 | t          | /api/v1/allowed


问:
All the wordpress links points to localhost/dashboard
I have a wordpress install at localhost. I was working on my website when i suddenly notice that all the links on my website starts pointing at localhost/dashboard. Each time I visit my website and click on any link it sends me to localhost/dashboard. But the link which appears at the bottom left corner in google chrome appears to be right.
Is there any way to fix this</p>

答:
in reality , you will not want your WordPress permalinks configured as localhost because when other client request web site files from your WordPress Apache web server , WordPress will direct their traffic to load their own loacalhost which mean they will failed load css or js file from your web server and get broken image\style\web site .

configure this option inside your wordpress web site will make sure all received web request proper direct to a right wordpress server , use a valid public IP or DNS name or private static IP rather then localhost