问:
How to make div loop around in section
I'm working on a Roulette site, but i don't have any idea how to make the divs loop around.
I need the divs to loop around when they get out of the section border.

$("#right").click(function() {
  $("#one").css("left", "300px");
  $("#two").css("left", "300px");
  $("#three").css("left", "300px");
  $("#four").css("left", "300px");
  $("#five").css("left", "300px");
  $("#six").css("left", "300px");

});

$("#left").click(function() {
  $("#one").css("left", "0px");
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>section {
  width: 80%;
  height: 50px;
  border: 5px solid gray;
  margin: auto;
  padding: 7px;
  z-index: 1;
  transition: left 2s ease;
  overflow: hidden;
}

div#one {
  width: 15%;
  height: 50px;
  background: black;
  float: left;
  z-index: -1;
  left: 0px;
  position: relative;
  transition: left 2s ease;
  loop: true;
}

div#six {
  width: 15%;
  height: 50px;
  margin-left: 5px;
  background: red;
  float: left;
  z-index: -1;
  left: 0px;
  position: relative;
  transition: left 2s ease;
  loop: true;
}

div#five {
  width: 15%;
  height: 50px;
  background: black;
  float: left;
  margin-left: 5px;
  z-index: -1;
  left: 0px;
  position: relative;
  transition: left 2s ease;
}

div#two {
  width: 15%;
  height: 50px;
  margin-left: 5px;
  background: red;
  float: left;
  z-index: -1;
  left: 0px;
  position: relative;
  transition: left 2s ease;
}

div#three {
  width: 15%;
  height: 50px;
  margin-left: 5px;
  background: black;
  float: left;
  z-index: -1;
  left: 0px;
  position: relative;
  transition: left 2s ease;
}

div#four {
  width: 15%;
  height: 50px;
  margin-left: 5px;
  background: red;
  float: left;
  z-index: -1;
  left: 0px;
  position: relative;
  transition: left 2s ease;
}</code>```

<button id="right">
left: 100px;
</button>```

so when i click on the button, it should move and then once they go out of the section border, the divs should loop around to the left and show again on the left.

Thanks in advance!

答:
You don't have to animate all the elements, you can only animate the first one that will push the other, then you need to use overflow in order to be able to put the last element at the start.

So you may try something like this (that can be improved of course) :

$("#right").click(function() {
  $('section').prepend($('section div').last().css('margin-left','-30%'));
  $('section >div').eq(1).css('margin-left', '0%');

});

$("#left").click(function() {
  $("#one").css("left", "0px");
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>section {
  width: 80%;
  height: 50px;
  border: 5px solid gray;
  margin: auto;
  padding: 7px;
  z-index: 1;
  transition: left 2s ease;
  overflow: hidden;
  display: flex;
}

section>div {
  flex: 0 0 25%;
  margin: 0 5px;
  position: relative;
  color: #fff;
  text-align: center;
  transition: 1s ease;
}

#one,
#three,
#five {
  background: red;
}

#two,
#four,
#six {
  background: black;
}

section>div:first-child {
  margin-left: -30%;
}</code>```

1

2

3

4

5

6

<button id="right">
left: 100px;
</button>```

Title: How to make div loop around in section

Body:
I'm working on a Roulette site, but i don't have any idea how to make the divs loop around.
I need the divs to loop around when they get out of the section border.

$("#right").click(function() {
  $("#one").css("left", "300px");
  $("#two").css("left", "300px");
  $("#three").css("left", "300px");
  $("#four").css("left", "300px");
  $("#five").css("left", "300px");
  $("#six").css("left", "300px");

});

$("#left").click(function() {
  $("#one").css("left", "0px");
});

section {
  width: 80%;
  height: 50px;
  border: 5px solid gray;
  margin: auto;
  padding: 7px;
  z-index: 1;
  transition: left 2s ease;
  overflow: hidden;
}

div#one {
  width: 15%;
  height: 50px;
  background: black;
  float: left;
  z-index: -1;
  left: 0px;
  position: relative;
  transition: left 2s ease;
  loop: true;
}

div#six {
  width: 15%;
  height: 50px;
  margin-left: 5px;
  background: red;
  float: left;
  z-index: -1;
  left: 0px;
  position: relative;
  transition: left 2s ease;
  loop: true;
}

div#five {
  width: 15%;
  height: 50px;
  background: black;
  float: left;
  margin-left: 5px;
  z-index: -1;
  left: 0px;
  position: relative;
  transition: left 2s ease;
}

div#two {
  width: 15%;
  height: 50px;
  margin-left: 5px;
  background: red;
  float: left;
  z-index: -1;
  left: 0px;
  position: relative;
  transition: left 2s ease;
}

div#three {
  width: 15%;
  height: 50px;
  margin-left: 5px;
  background: black;
  float: left;
  z-index: -1;
  left: 0px;
  position: relative;
  transition: left 2s ease;
}

div#four {
  width: 15%;
  height: 50px;
  margin-left: 5px;
  background: red;
  float: left;
  z-index: -1;
  left: 0px;
  position: relative;
  transition: left 2s ease;
}

<button id="right">
left: 100px;
</button>

so when i click on the button, it should move and then once they go out of the section border, the divs should loop around to the left and show again on the left.

Thanks in advance!

Body:
You don't have to animate all the elements, you can only animate the first one that will push the other, then you need to use overflow in order to be able to put the last element at the start.

So you may try something like this (that can be improved of course) :

$("#right").click(function() {
  $('section').prepend($('section div').last().css('margin-left','-30%'));
  $('section >div').eq(1).css('margin-left', '0%');

});

$("#left").click(function() {
  $("#one").css("left", "0px");
});

section {
  width: 80%;
  height: 50px;
  border: 5px solid gray;
  margin: auto;
  padding: 7px;
  z-index: 1;
  transition: left 2s ease;
  overflow: hidden;
  display: flex;
}

section>div {
  flex: 0 0 25%;
  margin: 0 5px;
  position: relative;
  color: #fff;
  text-align: center;
  transition: 1s ease;
}

#one,
#three,
#five {
  background: red;
}

#two,
#four,
#six {
  background: black;
}

section>div:first-child {
  margin-left: -30%;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section>
  <div id="one">1</div>
  <div id="two">2</div>
  <div id="three">3</div>
  <div id="four">4</div>
  <div id="five">5</div>
  <div id="six">6</div>
</section>

<button id="right">
left: 100px;
</button>


来源: stackexchange

问:
Centering inline element inside div without flexbox
I am trying to acomplish something that should be easy: centering an a tag inside a div. I know this is a classic, that there are similar questions out there, and also that can be done with flexbox, but I am trying to avoid the latter.

.wrapper {
  background-color: gold;
  height: 200px;
  width: 100%;
  position: relative;
  text-align: center;
  vertical-align: middle;
}
a {
  border: 4px dashed white;
  height: 95%;
  width: 95%;
  display: block;
  box-sizing: border-box;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="wrapper">
<a>
  Link
</a>
</div></code>```

Any help will be welcome!

EDIT: I would like the a tag to be flexible and fill the wrapper, without knowing the height of the wrapper.

答:
Add line-height in wrapper div

.wrapper {
  background-color: gold;
  height: 200px;
  width: 100%;
  line-height:200px;
  position: relative;
  text-align: center;
  vertical-align: middle;
}
a {
  border: 4px dashed white;
  height: 95%;
  width: 95%;
  display: block;
  box-sizing: border-box;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="wrapper">
<a>
  Link
</a>
</div></code>```

ContentLicense: CC BY-SA 3.0

Body:
I am trying to acomplish something that should be easy: centering an a tag inside a div. I know this is a classic, that there are similar questions out there, and also that can be done with flexbox, but I am trying to avoid the latter.

.wrapper {
  background-color: gold;
  height: 200px;
  width: 100%;
  position: relative;
  text-align: center;
  vertical-align: middle;
}
a {
  border: 4px dashed white;
  height: 95%;
  width: 95%;
  display: block;
  box-sizing: border-box;
}

  Link

Any help will be welcome!

EDIT: I would like the a tag to be flexible and fill the wrapper, without knowing the height of the wrapper.

Body:
Add line-height in wrapper div

.wrapper {
  background-color: gold;
  height: 200px;
  width: 100%;
  line-height:200px;
  position: relative;
  text-align: center;
  vertical-align: middle;
}
a {
  border: 4px dashed white;
  height: 95%;
  width: 95%;
  display: block;
  box-sizing: border-box;
}

<div class="wrapper">
<a>
  Link
</a>
</div>


问:
SWT Text Unhandled Event Loop Exception: NullPointerException
I have written code for a plugin in which I have a Text field on which I have to do validations using ModifyListener().

Whenever I run the application, I am getting the following error

```<code>!ENTRY org.eclipse.ui 4 0 2017-12-05 12:06:29.140
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
    at com.aspire.plugin.angularator.views.MainWizardPage$1.modifyText(MainWizardPage.java:78)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:180)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4418)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1103)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1084)
    at org.eclipse.swt.widgets.Text.wmCommandChild(Text.java:3122)
    at org.eclipse.swt.widgets.Control.WM_COMMAND(Control.java:4947)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4802)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5123)
    at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
    at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2446)
    at org.eclipse.swt.widgets.Text.callWindowProc(Text.java:262)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4897)
    at org.eclipse.swt.widgets.Text.windowProc(Text.java:2704)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5110)
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2552)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3822)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:818)
    at org.eclipse.jface.window.Window.open(Window.java:794)
    at org.eclipse.ui.internal.handlers.WizardHandler$New.executeHandler(WizardHandler.java:269)
    at org.eclipse.ui.internal.handlers.WizardHandler.execute(WizardHandler.java:290)
    at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:295)
    at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:282)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:264)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
    at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)
    at org.eclipse.core.commands.Command.executeWithChecks(Command.java:494)
    at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:488)
    at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:286)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:507)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:558)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:378)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.access$0(KeyBindingDispatcher.java:324)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:86)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1270)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1078)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1103)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1088)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1130)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1126)
    at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1547)
    at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4918)
    at org.eclipse.swt.widgets.Tree.WM_CHAR(Tree.java:6079)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4799)
    at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:6074)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5110)
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2552)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3822)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:693)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:610)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
</code>```

The code snippet it is referring to is the following:

```<code>projectName = new Text(container, SWT.SINGLE | SWT.BORDER);
    projectName.setLayoutData(gridDataMain);
    projectName.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            String projectNameString = projectName.getText();
            System.out.println(projectNameString);
            if(projectNameString.length() != 0) {
                updateStatus(beanMapper.projectNameChanged(projectNameString));
            }
            else {
                updateStatus(ValidationConstants.PROJECT_NAME_EMPTY_MESSAGE);
            }
        }
    });
</code>```

The projectNameString is able to get the value and the value is getting stored in the Text field also. I don't know how NullPointerException is coming.

Please help me with this.

答:
I solved my error.

I had not Initialized the BeanMapper class and hence the object of BeanMapper, i.e., beanMapper was pointing to null.

Once I initialized the BeanMapper, everything was working fine.

Body:
I have written code for a plugin in which I have a Text field on which I have to do validations using ModifyListener().

Whenever I run the application, I am getting the following error

!ENTRY org.eclipse.ui 4 0 2017-12-05 12:06:29.140
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
    at com.aspire.plugin.angularator.views.MainWizardPage$1.modifyText(MainWizardPage.java:78)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:180)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4418)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1103)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1084)
    at org.eclipse.swt.widgets.Text.wmCommandChild(Text.java:3122)
    at org.eclipse.swt.widgets.Control.WM_COMMAND(Control.java:4947)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4802)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5123)
    at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
    at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2446)
    at org.eclipse.swt.widgets.Text.callWindowProc(Text.java:262)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4897)
    at org.eclipse.swt.widgets.Text.windowProc(Text.java:2704)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5110)
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2552)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3822)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:818)
    at org.eclipse.jface.window.Window.open(Window.java:794)
    at org.eclipse.ui.internal.handlers.WizardHandler$New.executeHandler(WizardHandler.java:269)
    at org.eclipse.ui.internal.handlers.WizardHandler.execute(WizardHandler.java:290)
    at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:295)
    at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:282)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:264)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
    at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)
    at org.eclipse.core.commands.Command.executeWithChecks(Command.java:494)
    at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:488)
    at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:286)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:507)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:558)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:378)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.access$0(KeyBindingDispatcher.java:324)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:86)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1270)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1078)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1103)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1088)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1130)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1126)
    at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1547)
    at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4918)
    at org.eclipse.swt.widgets.Tree.WM_CHAR(Tree.java:6079)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4799)
    at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:6074)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5110)
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2552)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3822)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:693)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:610)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1492)

The code snippet it is referring to is the following:

projectName = new Text(container, SWT.SINGLE | SWT.BORDER);
    projectName.setLayoutData(gridDataMain);
    projectName.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            String projectNameString = projectName.getText();
            System.out.println(projectNameString);
            if(projectNameString.length() != 0) {
                updateStatus(beanMapper.projectNameChanged(projectNameString));
            }
            else {
                updateStatus(ValidationConstants.PROJECT_NAME_EMPTY_MESSAGE);
            }
        }
    });

The projectNameString is able to get the value and the value is getting stored in the Text field also. I don't know how NullPointerException is coming.

Please help me with this.


问:
mediasoup - miss match between PayloadTypes
I'm trying to use mediasoup to forward RTP streams with room.createRtpStreamer

my problem is that the payload type (for OPUS) I get from producer.rtpParameters.codecs[i].payloadType is 111,

while the one I get on the actual RTP packets is 100 (seen on Wireshark)

I tried to set preferredPayloadType in my server's config, but it seems to make no difference.

Note:
if I hardcode 100 as the Payload Type for the OPUS stream I can view/hear the stream using FFPlay

I'm using Chrome 55 (latest) and mediasoup 2.0.5 (latest)

any help will be appreciated.

答:
You should have a look at the SDP of the call setup message and check whether you get 111 or 100 for the OPUS payload.
From there you can decide which part has the bug (Chrome or mediasoup).
In the call setup message (initiating the call) check the payload of the OPUS code.
The called party should respond with the same payload number if it accepts OPUS and then both parties should use the same payload number in the RTP packets.</p>


问:
dbunit disable Oracle constraint
I'm using DbUnit 2.4.8 with Oracle 10g and JUnit 4.5.  I'd like to disable the foreign key constraints in Oracle while running the DbUnit tests I have so I can test single tables independent of all other tables.   This is what I have so far:

I have created a class (DBUnitHelper) which extends DatabaseTestCase.  I've

```<code>@Override
protected IDatabaseConnection getConnection() throws Exception {

    if (usingInternalCtx_)
    {
        if (!esa.util.SysConfig.isRunning())
            esa.util.SysConfig.startupSystem();

        ctx_ = OraPool.getCtx();
    }

    //disable foreign keys
    Connection con = ctx_.getConnection();
    con.prepareStatement("SET CONSTRAINTS ALL DEFERRED").execute();

    return new OracleConnection(con, "my_schema");  // DatabaseConnection(con_);
}
</code>```

The JUnit test method is:

```<code>@Test
public void useDatabaseTesterToRemoveExistingDataThenRunTest()
{
    IDataSet dataset = null;

    try
    {
        IDatabaseTester databaseTester = dbunit_.getDatabaseTester();
        databaseTester.setDataSet(dbunit_.getDataSet());
        databaseTester.onSetup();   // clean out existing entries in the table specified by the dataset and populate it with entries from the database

        IDataSet databaseDataSet = databaseTester.getDataSet();
        // IDataSet databaseDataSet = con.createDataSet();  // uncomment to retrieve actual rows from the database
        ITable actualTable = databaseDataSet.getTable(TABLE_NAME);

        // Load expected data from an XML dataset
        IDataSet expectedDataSet = dbunit_.getDataSet();
        ITable expectedTable = expectedDataSet.getTable(TABLE_NAME);

        // Assert new testing database table match expected (xml) table
        assertEquals(3,expectedTable.getRowCount());
        assertEquals(expectedTable.getRowCount(), actualTable.getRowCount());
        assertEquals(expectedTable.getValue(1, "oid"), actualTable.getValue(1, "oid"));
        Assertion.assertEquals(expectedTable, actualTable);

        databaseTester.onTearDown();  // by default does nothing
    } catch (Exception e)
    {
        e.printStackTrace();
        fail("test_names has problems");
    }
}
</code>```

I get an ORA-02291:  integrity constraint violated - parent key not found error on the Junit line:  databaseTester.onSetup();.  When I step through this with the debugger, I see that the DBUnitHelper.getConnection() is never being called.

Any ideas on what I need to fix to disable the constraints in Oracle?

答:
The first thing to ask is: "Were the constraints on the tables you are working on created as DEFERRABLE?"

You can check this by issuing this query:

```<code>SELECT constraint_name, table_name, DEFERRABLE
  FROM all_constraints
 WHERE owner = 'myschema'
   AND table_name = 'THE_TABLE';
</code>```

If the constraints are not created as DEFERRABLE, the command SET ALL CONSTRAINTS DEFERRED essentially has no effect.

If the constraints are not deferrable, you must drop and re-create them as deferrable. You can't modify them to be deferrable.

ContentLicense: CC BY-SA 2.5

Title: dbunit disable Oracle constraint

Body:
I'm using DbUnit 2.4.8 with Oracle 10g and JUnit 4.5.  I'd like to disable the foreign key constraints in Oracle while running the DbUnit tests I have so I can test single tables independent of all other tables.   This is what I have so far:

I have created a class (DBUnitHelper) which extends DatabaseTestCase.  I've

@Override
protected IDatabaseConnection getConnection() throws Exception {

    if (usingInternalCtx_)
    {
        if (!esa.util.SysConfig.isRunning())
            esa.util.SysConfig.startupSystem();

        ctx_ = OraPool.getCtx();
    }

    //disable foreign keys
    Connection con = ctx_.getConnection();
    con.prepareStatement("SET CONSTRAINTS ALL DEFERRED").execute();

    return new OracleConnection(con, "my_schema");  // DatabaseConnection(con_);
}

The JUnit test method is:

@Test
public void useDatabaseTesterToRemoveExistingDataThenRunTest()
{
    IDataSet dataset = null;

    try
    {
        IDatabaseTester databaseTester = dbunit_.getDatabaseTester();
        databaseTester.setDataSet(dbunit_.getDataSet());
        databaseTester.onSetup();   // clean out existing entries in the table specified by the dataset and populate it with entries from the database

        IDataSet databaseDataSet = databaseTester.getDataSet();
        // IDataSet databaseDataSet = con.createDataSet();  // uncomment to retrieve actual rows from the database
        ITable actualTable = databaseDataSet.getTable(TABLE_NAME);

        // Load expected data from an XML dataset
        IDataSet expectedDataSet = dbunit_.getDataSet();
        ITable expectedTable = expectedDataSet.getTable(TABLE_NAME);

        // Assert new testing database table match expected (xml) table
        assertEquals(3,expectedTable.getRowCount());
        assertEquals(expectedTable.getRowCount(), actualTable.getRowCount());
        assertEquals(expectedTable.getValue(1, "oid"), actualTable.getValue(1, "oid"));
        Assertion.assertEquals(expectedTable, actualTable);

        databaseTester.onTearDown();  // by default does nothing
    } catch (Exception e)
    {
        e.printStackTrace();
        fail("test_names has problems");
    }
}

I get an ORA-02291:  integrity constraint violated - parent key not found error on the Junit line:  databaseTester.onSetup();.  When I step through this with the debugger, I see that the DBUnitHelper.getConnection() is never being called.

Any ideas on what I need to fix to disable the constraints in Oracle?

Body:
The first thing to ask is: "Were the constraints on the tables you are working on created as DEFERRABLE?"

You can check this by issuing this query:

SELECT constraint_name, table_name, DEFERRABLE
  FROM all_constraints
 WHERE owner = 'myschema'
   AND table_name = 'THE_TABLE';

If the constraints are not created as DEFERRABLE, the command SET ALL CONSTRAINTS DEFERRED essentially has no effect.

If the constraints are not deferrable, you must drop and re-create them as deferrable. You can't modify them to be deferrable.


问:
How disable debuger on chrome webdriver in Python 3.x?
anybody know how to disable a debugger/logging in chrome webdriver in Python 3.6 ?

I'm trying following code and it isn't working.

```<code>chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--disable-infobars")
chrome_options.add_argument("--disable-logging")
chrome_options.add_argument("--disable-login-animations")
chrome_options.add_argument("--disable-notifications")
chrome_options.add_argument("--disable-default-apps")

driver = webdriver.Chrome(chrome_options=chrome_options, service_log_path='NUL', service_args=["--verbose", r"--log-path=D:\qc1.log"])
</code>```

Python ver.: 3.6.1

Chrome Browser ver.: 62.0.3202.94 (64bit)

Webdriver ver.: 2.33

OS: Win10 (64bit)

答: add this chrome_options.add_argument("--log-level=3") to shut the logging.

ContentLicense: CC BY-SA 4.0

Body:
anybody know how to disable a debugger/logging in chrome webdriver in Python 3.6 ?

I'm trying following code and it isn't working.

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--disable-infobars")
chrome_options.add_argument("--disable-logging")
chrome_options.add_argument("--disable-login-animations")
chrome_options.add_argument("--disable-notifications")
chrome_options.add_argument("--disable-default-apps")

driver = webdriver.Chrome(chrome_options=chrome_options, service_log_path='NUL', service_args=["--verbose", r"--log-path=D:\qc1.log"])

Python ver.: 3.6.1

Chrome Browser ver.: 62.0.3202.94 (64bit)

Webdriver ver.: 2.33

OS: Win10 (64bit)


问:
java.lang.NumberFormatException: For input string ComboBox

I am trying to get the values of my ComboBox and store it to the database. But I get this error:

```<code>Executing F:\eLibraryServer\dist\run2044401483\eLibraryServer.jar using platform C:\Program Files\Java\jdk1.8.0_151\jre/bin/java
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1774)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Node.fireEvent(Node.java:8413)
at javafx.scene.control.Button.fire(Button.java:185)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:417)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._enterNestedEventLoopImpl(Native Method)
at com.sun.glass.ui.win.WinApplication._enterNestedEventLoop(WinApplication.java:204)
at com.sun.glass.ui.Application.enterNestedEventLoop(Application.java:511)
at com.sun.glass.ui.EventLoop.enter(EventLoop.java:107)
at com.sun.javafx.tk.quantum.QuantumToolkit.enterNestedEventLoop(QuantumToolkit.java:583)
at javafx.stage.Stage.showAndWait(Stage.java:474)
at elibraryserver.NewStudentController.initRegister(NewStudentController.java:152)
at elibraryserver.serverController.addStudentButtonAction(serverController.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1769)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.control.MenuItem.fire(MenuItem.java:462)
at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.doSelect(ContextMenuContent.java:1405)
at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.lambda$createChildren$343(ContextMenuContent.java:1358)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:417)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1769)
... 106 more
Caused by: java.lang.NumberFormatException: For input string: "cmbCourse"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.valueOf(Integer.java:766)
at elibraryserver.NewStudentController.registerButtonAction(NewStudentController.java:180)
</code>```

When using this code:

```<code>String query = ("INSERT INTO tblusers (first_name, middle_initial, last_name, username, password,"
                    + " privilege) VALUES (?,?,?,?,?,?)");
            stmt = conn.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
            stmt.setString(1, txtFn.getText());
            stmt.setString(2, txtMi.getText());
            stmt.setString(3, txtLn.getText());
            stmt.setString(4, txtUser.getText());
            stmt.setString(5, txtPass.getText());
            stmt.setString(6, "student");
            stmt.executeUpdate();
            ResultSet rs = stmt.getGeneratedKeys();
            Integer key =- 1;
            if (rs.next()) {
                key = rs.getInt(1);
            }
            String query2 = ("INSERT INTO tblcourseinfo (user_id, course_id, school_id) VALUES (?,?,?)");
            stmt = conn.prepareStatement(query2);
            stmt.setInt(1, key);
            stmt.setInt(2, Integer.valueOf(cmbCourse.getId()));
            stmt.setInt(3, Integer.valueOf(cmbSchool.getId()));
            stmt.executeUpdate();
</code>```

What does NumberFormatException mean? And am I correct to add another insert statement here for the ComboBoxes which inserts the values to another table? The inserted data should be the foreign keys of my ComboBoxes.

EDIT: As it turns out it does print out the variable name rather than the id.

```<code>cmbCourse.getId(): cmbCourse
cmbSchool.getId(): cmbSchool
</code>```

Here is how my ComboBoxes are populated simply a method

```<code>public void populateCourse() {
    QueryCourses qc = new QueryCourses();
    HashMap<String, Integer> map = qc.hashMap();

    cmbCourse.getItems().setAll(map.keySet());
}
</code>```

with a query of QueryCourses.java

```<code>public class QueryCourses {
Statement stmt = null;
Connection conn = null;
ResultSet rs = null;

public HashMap<String, Integer> hashMap(){
    HashMap<String, Integer> map = new HashMap<>();
    conn = DbConnection.ConnectDB();

    try {
        stmt = conn.createStatement();
        String qry = "SELECT `course_id`, `course_title` FROM `tblcourses`";
        rs = stmt.executeQuery(qry);
        Courses crse;

        while (rs.next()) {
            crse = new Courses(rs.getInt(1), rs.getString(2));
            map.put(crse.getCourseTitle(), crse.getCourseId());
        }
    } catch (SQLException ex) {
        Logger.getLogger(NewStudentController.class.getName()).log(Level.SEVERE, null, ex);
    }

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

答:
Your HashMap declaration

```<code>HashMap<String, Integer> map = new HashMap<>();
</code>```

You try to fill the map with the String key.

```<code>map.put(crse.getCourseTitle(), crse.getCourseId());
</code>```

You construct your combo box with String type key set.

```<code>cmbCourse.getItems().setAll(map.keySet());
</code>```

Now, you get the value from combo box then it returns String that is not convertible to a numeric value from String.

Update :

```<code>public class Courses {
    private int id;
    private String title;

    public Courses (int id, String name) {
        this.id = id;
        this.title = name;
    }
    public int getId() {
        return id;
    }

    public String getTitle() {
        return title;
    }
    public String toString() {
        return title;
    }
}
</code>```

```<code>try {
            stmt = conn.createStatement();
            String qry = "SELECT `course_id`, `course_title` FROM `tblcourses`";
            rs = stmt.executeQuery(qry);
            Courses crse;

            while (rs.next()) {
                crse = new Courses(rs.getInt(1), rs.getString(2));
                cmbCourse.addItem(crse); //you directly add  item in combo course.
                // overload the toString of Course class.
            }
        } catch (SQLException ex) {
            Logger.getLogger(NewStudentController.class.getName()).log(Level.SEVERE, null, ex);
        }
</code>```

```<code>String query = ("INSERT INTO tblusers (first_name, middle_initial, last_name, username, password,"
                + " privilege) VALUES (?,?,?,?,?,?)");
        stmt = conn.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
            stmt.setString(1, txtFn.getText());
            stmt.setString(2, txtMi.getText());
            stmt.setString(3, txtLn.getText());
            stmt.setString(4, txtUser.getText());
            stmt.setString(5, txtPass.getText());
            stmt.setString(6, "student");
            stmt.executeUpdate();
        ResultSet rs = stmt.getGeneratedKeys();
        Integer key =- 1;
            if (rs.next()) {
            key = rs.getInt(1);
        }
        String query2 = ("INSERT INTO tblcourseinfo (user_id, course_id, school_id) VALUES (?,?,?)");
        stmt = conn.prepareStatement(query2);
            stmt.setInt(1, key);
            Course cr =(Course)cmbCourse.getSelectedItem();
            stmt.setInt(2, cr.getId());
            School cs =(School)cmbSchool.getSelectedItem();
            stmt.setInt(3, Integer.valueOf(cs.getId());
            stmt.executeUpdate();
</code>```

Update : Using HashMap

```<code>QueryCourses qc = new QueryCourses();
HashMap<String, Integer> map = qc.hashMap();

//get the course title from combo box.
String courseTitle = (String) cmbCourse.getSelectedItem();
String school = (String) cmbSchool.getSelectedItem();

//get value(id) from course HashMap with key <courseTitle>
stmt.setInt(2, map.get(courseTitle));

//do same for school
</code>```

Body:
I am trying to get the values of my ComboBox and store it to the database. But I get this error:

Executing F:\eLibraryServer\dist\run2044401483\eLibraryServer.jar using platform C:\Program Files\Java\jdk1.8.0_151\jre/bin/java
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1774)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Node.fireEvent(Node.java:8413)
at javafx.scene.control.Button.fire(Button.java:185)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:417)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._enterNestedEventLoopImpl(Native Method)
at com.sun.glass.ui.win.WinApplication._enterNestedEventLoop(WinApplication.java:204)
at com.sun.glass.ui.Application.enterNestedEventLoop(Application.java:511)
at com.sun.glass.ui.EventLoop.enter(EventLoop.java:107)
at com.sun.javafx.tk.quantum.QuantumToolkit.enterNestedEventLoop(QuantumToolkit.java:583)
at javafx.stage.Stage.showAndWait(Stage.java:474)
at elibraryserver.NewStudentController.initRegister(NewStudentController.java:152)
at elibraryserver.serverController.addStudentButtonAction(serverController.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1769)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.control.MenuItem.fire(MenuItem.java:462)
at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.doSelect(ContextMenuContent.java:1405)
at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.lambda$createChildren$343(ContextMenuContent.java:1358)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:417)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1769)
... 106 more
Caused by: java.lang.NumberFormatException: For input string: "cmbCourse"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.valueOf(Integer.java:766)
at elibraryserver.NewStudentController.registerButtonAction(NewStudentController.java:180)

When using this code:

String query = ("INSERT INTO tblusers (first_name, middle_initial, last_name, username, password,"
                    + " privilege) VALUES (?,?,?,?,?,?)");
            stmt = conn.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
            stmt.setString(1, txtFn.getText());
            stmt.setString(2, txtMi.getText());
            stmt.setString(3, txtLn.getText());
            stmt.setString(4, txtUser.getText());
            stmt.setString(5, txtPass.getText());
            stmt.setString(6, "student");
            stmt.executeUpdate();
            ResultSet rs = stmt.getGeneratedKeys();
            Integer key =- 1;
            if (rs.next()) {
                key = rs.getInt(1);
            }
            String query2 = ("INSERT INTO tblcourseinfo (user_id, course_id, school_id) VALUES (?,?,?)");
            stmt = conn.prepareStatement(query2);
            stmt.setInt(1, key);
            stmt.setInt(2, Integer.valueOf(cmbCourse.getId()));
            stmt.setInt(3, Integer.valueOf(cmbSchool.getId()));
            stmt.executeUpdate();

What does NumberFormatException mean? And am I correct to add another insert statement here for the ComboBoxes which inserts the values to another table? The inserted data should be the foreign keys of my ComboBoxes.

EDIT: As it turns out it does print out the variable name rather than the id.

cmbCourse.getId(): cmbCourse
cmbSchool.getId(): cmbSchool

Here is how my ComboBoxes are populated simply a method

public void populateCourse() {
    QueryCourses qc = new QueryCourses();
    HashMap<String, Integer> map = qc.hashMap();

    cmbCourse.getItems().setAll(map.keySet());
}

with a query of QueryCourses.java

public class QueryCourses {
Statement stmt = null;
Connection conn = null;
ResultSet rs = null;

public HashMap<String, Integer> hashMap(){
    HashMap<String, Integer> map = new HashMap<>();
    conn = DbConnection.ConnectDB();

    try {
        stmt = conn.createStatement();
        String qry = "SELECT `course_id`, `course_title` FROM `tblcourses`";
        rs = stmt.executeQuery(qry);
        Courses crse;

        while (rs.next()) {
            crse = new Courses(rs.getInt(1), rs.getString(2));
            map.put(crse.getCourseTitle(), crse.getCourseId());
        }
    } catch (SQLException ex) {
        Logger.getLogger(NewStudentController.class.getName()).log(Level.SEVERE, null, ex);
    }

    return map;
}
}

Body:
Your HashMap declaration

HashMap<String, Integer> map = new HashMap<>();

You try to fill the map with the String key.

map.put(crse.getCourseTitle(), crse.getCourseId());

You construct your combo box with String type key set.

cmbCourse.getItems().setAll(map.keySet());

Now, you get the value from combo box then it returns String that is not convertible to a numeric value from String.

Update :

public class Courses {
    private int id;
    private String title;

    public Courses (int id, String name) {
        this.id = id;
        this.title = name;
    }
    public int getId() {
        return id;
    }

    public String getTitle() {
        return title;
    }
    public String toString() {
        return title;
    }
}

try {
            stmt = conn.createStatement();
            String qry = "SELECT `course_id`, `course_title` FROM `tblcourses`";
            rs = stmt.executeQuery(qry);
            Courses crse;

            while (rs.next()) {
                crse = new Courses(rs.getInt(1), rs.getString(2));
                cmbCourse.addItem(crse); //you directly add  item in combo course.
                // overload the toString of Course class.
            }
        } catch (SQLException ex) {
            Logger.getLogger(NewStudentController.class.getName()).log(Level.SEVERE, null, ex);
        }

String query = ("INSERT INTO tblusers (first_name, middle_initial, last_name, username, password,"
                + " privilege) VALUES (?,?,?,?,?,?)");
        stmt = conn.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
            stmt.setString(1, txtFn.getText());
            stmt.setString(2, txtMi.getText());
            stmt.setString(3, txtLn.getText());
            stmt.setString(4, txtUser.getText());
            stmt.setString(5, txtPass.getText());
            stmt.setString(6, "student");
            stmt.executeUpdate();
        ResultSet rs = stmt.getGeneratedKeys();
        Integer key =- 1;
            if (rs.next()) {
            key = rs.getInt(1);
        }
        String query2 = ("INSERT INTO tblcourseinfo (user_id, course_id, school_id) VALUES (?,?,?)");
        stmt = conn.prepareStatement(query2);
            stmt.setInt(1, key);
            Course cr =(Course)cmbCourse.getSelectedItem();
            stmt.setInt(2, cr.getId());
            School cs =(School)cmbSchool.getSelectedItem();
            stmt.setInt(3, Integer.valueOf(cs.getId());
            stmt.executeUpdate();

Update : Using HashMap

QueryCourses qc = new QueryCourses();
HashMap<String, Integer> map = qc.hashMap();

//get the course title from combo box.
String courseTitle = (String) cmbCourse.getSelectedItem();
String school = (String) cmbSchool.getSelectedItem();

//get value(id) from course HashMap with key <courseTitle>
stmt.setInt(2, map.get(courseTitle));

//do same for school


问:
Creating custom grid number (24) for Bootstrap 4
I have a project and I want to integrate some bootstrap into my html files for ui development. I know that the standard grid size is 12 and I wanted to change the number of grid spaces from 12 to 24. I know there is a way to do it from the documentation but I dont know how to where to integrate it.

This is the bootstrap documentation

```<code>$grid-columns:               12 !default;
$grid-gutter-width-base:     30px !default;
$grid-gutter-widths: (
  xs: $grid-gutter-width-base,
  sm: $grid-gutter-width-base,
  md: $grid-gutter-width-base,
  lg: $grid-gutter-width-base,
  xl: $grid-gutter-width-base
) !default;
</code>```

Where do I put it in my code.

```<code>CSS file
HTML file
Js file
....
</code>```

答:
```<code>24 Grid system with Gutter
@gridColumns: 24
@gridColumnWidth: 30px
@gridGutterWidth: 1px
@gridColumnWidth1200: 35px
@gridGutterWidth1200: 15px
@gridColumnWidth768: 21px
@gridGutterWidth768: 10px

24 Grid system without Gutter
@gridColumns: 24
@gridColumnWidth: 40px
@gridGutterWidth: 0px
@gridColumnWidth1200: 50px
@gridGutterWidth1200: 0px
@gridColumnWidth768: 31px
@gridGutterWidth768: 0px
</code>```

Body:
I have a project and I want to integrate some bootstrap into my html files for ui development. I know that the standard grid size is 12 and I wanted to change the number of grid spaces from 12 to 24. I know there is a way to do it from the documentation but I dont know how to where to integrate it.

This is the bootstrap documentation

$grid-columns:               12 !default;
$grid-gutter-width-base:     30px !default;
$grid-gutter-widths: (
  xs: $grid-gutter-width-base,
  sm: $grid-gutter-width-base,
  md: $grid-gutter-width-base,
  lg: $grid-gutter-width-base,
  xl: $grid-gutter-width-base
) !default;

Where do I put it in my code.

CSS file
HTML file
Js file
....


问:
I have created an call back API to receive the JSON data but its not working
I have created a call back API to receive the JSON data after hitting my server. But somehow its not working as expected

This the response which i have to receive in my API

{"ERROR":0,"STATUS":1,"ORDERID":753093,"OPTRANSID":"2107938600"}

I have written the php file for this rcstatus.php

```<code>$url = 'http://softwarecompany.club/pks/recharge/b2b/rcstatus.php?status='.$_GET['status'].'&Orderid='.$_GET['Orderid'].'&Optransid='.$_GET['Optransid'];

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 30000);
$data = curl_exec($ch);
echo $data;
$json = json_decode($url,true);
$json['STATUS'];
</code>```

Please help me to achieve this. I have never worked with JSON data before. So please help me to achieve it. Thanks in advance!!!

答:
You need to replace:

```<code>$json = json_decode($url,true);
</code>```

with

```<code>$json = json_decode($data,true);
</code>```

Body:
I have created a call back API to receive the JSON data after hitting my server. But somehow its not working as expected

This the response which i have to receive in my API

{"ERROR":0,"STATUS":1,"ORDERID":753093,"OPTRANSID":"2107938600"}

I have written the php file for this rcstatus.php

$url = 'http://softwarecompany.club/pks/recharge/b2b/rcstatus.php?status='.$_GET['status'].'&Orderid='.$_GET['Orderid'].'&Optransid='.$_GET['Optransid'];

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 30000);
$data = curl_exec($ch);
echo $data;
$json = json_decode($url,true);
$json['STATUS'];

Please help me to achieve this. I have never worked with JSON data before. So please help me to achieve it. Thanks in advance!!!

Body:
You need to replace:

$json = json_decode($url,true);

with

$json = json_decode($data,true);


问:
how to read Specific row in csv file from multiple row in jmeter?
I am using csv data set config to read data for data driven framework in jmeter. I have lots of data in my csv file. Suppose I want to read only data of specific row then how can i do this? I don't want to read data of all rows available in csv.

Please help

答:
You can do it with Groovy language like:

```<code>def line10 = new File('/path/to/your/file').readLines().get(9)
</code>```

The above code can be called from any of JSR223 Test Elements or from __groovy() function

More information:

Groovy JDK enhancements

Apache Groovy - Why and How You Should Use It

Body:
You can do it with Groovy language like:

def line10 = new File('/path/to/your/file').readLines().get(9)

The above code can be called from any of JSR223 Test Elements or from __groovy() function

More information:

Groovy JDK enhancements

Apache Groovy - Why and How You Should Use It


问:
read matrix issue C language
This code should read and display a matrix. But it doesnt work, I cant find the problem.  Why it doesnt work?

```<code>#include <stdio.h>

#define MAX 100

void read_matrix(int a[MAX][MAX], int n)
{
    int i, j;

    scanf("%d", &n);
    for (i = 0; i < n; i++)
        for (j = 0; j < n; j++)
            scanf("%d", &a[i][j]);
}

int main(void)
{
    int a[MAX][MAX], n = 1, i, j;

    read_matrix(a, n);

    for(i = 0; i < n; i++) {
        for (j = 0; j < n; j++)
            printf("%d ", a[i][j]);
        printf("\n");
    }

    return 0;
}
</code>```

For input:

```<code>2
1 2
3 4
</code>```

The output is:

```<code>1
</code>```

答:
Because n is passed by value, not by reference. Use:

```<code>void read_matrix(int a[MAX][MAX], int *n) {
    int i, j;

    scanf("%d", n);
    for (i = 0; i < *n; i++)
        for (j = 0; j < *n; j++)
            scanf("%d", &a[i][j]);
}
</code>```

and

```<code>read_matrix(a, &n);
</code>```

Now n is passed by reference and it should work as expected.

Title: read matrix issue C language

Body:
This code should read and display a matrix. But it doesnt work, I cant find the problem.  Why it doesnt work?

#include <stdio.h>

#define MAX 100

void read_matrix(int a[MAX][MAX], int n)
{
    int i, j;

    scanf("%d", &n);
    for (i = 0; i < n; i++)
        for (j = 0; j < n; j++)
            scanf("%d", &a[i][j]);
}

int main(void)
{
    int a[MAX][MAX], n = 1, i, j;

    read_matrix(a, n);

    for(i = 0; i < n; i++) {
        for (j = 0; j < n; j++)
            printf("%d ", a[i][j]);
        printf("\n");
    }

    return 0;
}

For input:

2
1 2
3 4

The output is:

1

Body:
Because n is passed by value, not by reference. Use:

void read_matrix(int a[MAX][MAX], int *n) {
    int i, j;

    scanf("%d", n);
    for (i = 0; i < *n; i++)
        for (j = 0; j < *n; j++)
            scanf("%d", &a[i][j]);
}

and

read_matrix(a, &n);

Now n is passed by reference and it should work as expected.


问:
how do I find all docker images in a private registry that got pushed in the last 6 months?
I have a docker private registry and docker images in it. Now I would like to copy all the images which are created in last 6 months, to another private  docker registry. Can anyone help me with command/script to find out the docker images which got pushed into the registry in last 6 months? then I can re-tag it and push to the new registry.

Thanks in Advance.

答:
I got the images. by the following three steps.
1. get the the catalogs from the registry
2. get the Tags for the images from step1
3. get the created date of the image:tag from step 2
4. compare the date </p>


问:
Cannot add Judopay to Xamarin forms project
I am trying to include Judopay in my project, and I was able to add it to Android and iOS, but not to the Xamarin forms project. There is no NuGet to be included and I can't seem to add the component reference. Any idea on how can I add it? I cannot use any of these:

```<code>using JudoDotNetXamarin;
using JudoPayDotNet.Enums;
using JudoPayDotNet.Models;
</code>```

Again, they only work on iOS or Android, but not Xam forms.

答:
That is because they only provide platform implementations. You will need to tell your Forms app which implementation to use at what time.

The correct way to go about this is with some form of IoC, using dependency injection or service location. Luckily Xamarin Forms has this integrated:
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/dependency-service/introduction/

Using the references from the Android or iOS projects in your shared code will likely not work completely or break things. Maybe not immediately but surely later on. (Except when there really is no platform-specific functionality, then you might get away with this.)

Body:
I am trying to include Judopay in my project, and I was able to add it to Android and iOS, but not to the Xamarin forms project. There is no NuGet to be included and I can't seem to add the component reference. Any idea on how can I add it? I cannot use any of these:

using JudoDotNetXamarin;
using JudoPayDotNet.Enums;
using JudoPayDotNet.Models;

Again, they only work on iOS or Android, but not Xam forms.


问:
Beginner's dillema about calling MVC 5 action using TypeScript
I've started to learn TypeScript and I know how to include jQuery inside its classes. In that way I'm able to make ajax call to MVC5 action and use returned data further.

But, is it possible to not use jQuery ajax calls, but use some TypeScript's mechanism for that purpose? What about async/await?

答:
Yes it's better not to use jquery ajax with typescript in this case to make the async calls . You can use async/await and fetch api to call your controller action methods which returns JSON data like below

```<code>async getDataUsingAsync() {
    let response = await fetch('path-to-controller-action');
    let data= await response.json();
    console.log(data);
}
</code>```

async/await is available from Typescript 2.1 version.

check out the below links for more reference

http://www.syntaxsuccess.com/viewarticle/async-and-await-in-typescript
http://blog.ctaggart.com/2016/12/fetch-api-via-typescript-async.html

Body:
Yes it's better not to use jquery ajax with typescript in this case to make the async calls . You can use async/await and fetch api to call your controller action methods which returns JSON data like below

async getDataUsingAsync() {
    let response = await fetch('path-to-controller-action');
    let data= await response.json();
    console.log(data);
}

async/await is available from Typescript 2.1 version.

check out the below links for more reference

http://www.syntaxsuccess.com/viewarticle/async-and-await-in-typescript
http://blog.ctaggart.com/2016/12/fetch-api-via-typescript-async.html


问:
get dictionary from queryset
I have below query where I want to fetch 'specs' which is a dictionary but the type of envi_dict is a Queryset class. How do I fetch the dictionary from this queryset? Any help is much appreciated.

```<code>envi_dict = Environment.objects.values('specs')
</code>```

Result

```<code><QuerySet [({u'CPU Model': u'Dell', u'RAM': 1000, u'CPU': 400},), ({u'CPU Model': u'Dell', u'RAM': 1000, u'CPU': 400},)]>, <class 'django.db.models.query.QuerySet'>, )
</code>```

I tried Environment.objects.filter(title=item.title).values('specs') and also Environment.objects.get('specs') but I am still getting a queryset.

Edit: Below is models.py

```<code>class CommonModel(models.Model):

    author = models.ForeignKey('auth.User',)
    title = models.CharField(max_length=400)
    comments = models.TextField(blank=True)
    requirements = JSONField(default = {})
    specs = JSONField(default= {})
    created_date = models.DateTimeField(default=timezone.now)
    updated_date = models.DateTimeField(blank=True, null=True)

    class Meta:
       abstract = True

    def update(self):
        self.updated_date = timezone.now()
        self.save()

    def __str__(self):
        return self.title

class Estimate(CommonModel):

    gp_code = models.TextField(default='Unknown')
    inputs = models.TextField(blank=True)
    ...
    def __str__(self):
        return self.title

class Environment(CommonModel):

    estimate = models.ForeignKey(Estimate,related_name='environments')
    logic = PythonCodeField(blank=True, null=True)
    ...
</code>```

答:
Build a list of dicts with model instance.title as key and the specs as value by iterating over all Environment model instances.</p>

```<code>[{i.title: i.specs} for i in Environment.objects.all()]
</code>```

Title: get dictionary from queryset

Body:
I have below query where I want to fetch 'specs' which is a dictionary but the type of envi_dict is a Queryset class. How do I fetch the dictionary from this queryset? Any help is much appreciated.

envi_dict = Environment.objects.values('specs')

Result

<QuerySet [({u'CPU Model': u'Dell', u'RAM': 1000, u'CPU': 400},), ({u'CPU Model': u'Dell', u'RAM': 1000, u'CPU': 400},)]>, <class 'django.db.models.query.QuerySet'>, )

I tried Environment.objects.filter(title=item.title).values('specs') and also Environment.objects.get('specs') but I am still getting a queryset.

Edit: Below is models.py

class CommonModel(models.Model):

    author = models.ForeignKey('auth.User',)
    title = models.CharField(max_length=400)
    comments = models.TextField(blank=True)
    requirements = JSONField(default = {})
    specs = JSONField(default= {})
    created_date = models.DateTimeField(default=timezone.now)
    updated_date = models.DateTimeField(blank=True, null=True)

    class Meta:
       abstract = True

    def update(self):
        self.updated_date = timezone.now()
        self.save()

    def __str__(self):
        return self.title

class Estimate(CommonModel):

    gp_code = models.TextField(default='Unknown')
    inputs = models.TextField(blank=True)
    ...
    def __str__(self):
        return self.title

class Environment(CommonModel):

    estimate = models.ForeignKey(Estimate,related_name='environments')
    logic = PythonCodeField(blank=True, null=True)
    ...

Body:
Build a list of dicts with model instance.title as key and the specs as value by iterating over all Environment model instances.

[{i.title: i.specs} for i in Environment.objects.all()]


问:
css file is not loading on the page
www.septembris.lv
Css file is not loading, I can't find out why.

There is a code in html:

```<code><base href="http://www.septembris.lv/">
<link rel="stylesheet" href="assets/css/style.css" />
</code>```

File itself opening from the browser:
http://www.septembris.lv/assets/css/style.css

答:
assets/css/style.css is loaded without any problem

I think the problem is bootstrap.min.css not be loaded, so the website looks like broken.

Title: css file is not loading on the page

Body:
www.septembris.lv
Css file is not loading, I can't find out why.

There is a code in html:

<base href="http://www.septembris.lv/">
<link rel="stylesheet" href="assets/css/style.css" />

File itself opening from the browser:
http://www.septembris.lv/assets/css/style.css


问:
Function that transforms a list in a list of dictionary
I have to make a function whose purpose is taking in parameter a list.

Such as this one :

```<code>['music', ' extension=mp3', 'reports/INFOB131', ' extension=doc,docx,pdf', ' name_contains=INFOB131', ' max_size=100000', 'reports/INFOB132', ' extension=doc,docx,pdf', ' name_contains=INFOB132', ' max_size=100000', 'games', ' name_contains=SC2,Wesnoth', 'pictures/Namur', ' extension=jpeg', ' min_size=5000000', ' name_contains=cercle', 'pictures/autres', ' extension=jpeg', ' min_size=5000000']
</code>```

And return a list similar to this :

```<code>data_config = [{'music' : {'extension':'mp3'}}, {'reports/INFOB131': {'extension': ['doc', 'docx','pdf'], 'name_contains':'INFOB131', 'max_size':100000}}, {'reports/INFOB132': {'extension': ['doc', 'docx','pdf'], 'name_contains':'INFOB132', 'max_size':100000}}]
</code>```

So I made that function :

```<code>def my_function(list_in_question, my_config_list =[], prev_list = []):
    """ """
    enumerated_list = list(enumerate(list_in_question))

    if not '=' in enumerated_list[0][1]:
        main_key = enumerated_list[0][1]# référencé avant assignement
        pre_dict = {main_key : {}}

        for i in enumerated_list[1:]:

            if '=' in i[1] :
                splitted = i[1].split('=')
                prev_list.append({splitted[0] : splitted[1]})

            elif not '=' in i[1] and i[1] != main_key:
                for j in prev_list:
                    pre_dict[main_key].update(j)

                my_config_list.append(pre_dict)

                return my_function(list_in_question[i[0]:])

            elif not '=' in i[1] and i[1] == main_key and main_key!= enumerated_list[0][1]:
                return my_config_list
    else:
        print("The format of the file containig the data in not adequate !")
</code>```

But I don't understand why when I execute it this way :

```<code>new_lines = ['music', ' extension=mp3', '', 'reports/INFOB131', ' extension=doc,docx,pdf', ' name_contains=INFOB131', ' max_size=100000', '', 'reports/INFOB132', ' extension=doc,docx,pdf', ' name_contains=INFOB132', ' max_size=100000', '', 'games', ' name_contains=SC2,Wesnoth', '', 'pictures/Namur', ' extension=jpeg', ' min_size=5000000', ' name_contains=cercle', '', 'pictures/autres', ' extension=jpeg', ' min_size=5000000']

my_function(new_lines)
</code>```

I end up with this output...

```<code>None
</code>```

I would be very grateful if someone could help me,

Thank you !

PS : If anyone have an idea of how I could do without loop and do it in a recursive way, it would be awesome !

Everyone... Thank you !!! You really hepled me, all your answers are awesome, I have some issues to understand some parts so I'll be annoying just a little longer with some questions of you code. Anyway, thank you for the time you took to help me, you were all more than great help !!!

答:
Try the following code;

```<code>def foo(my_list):
    # Create an iterator
    list_iter = iter(my_list)
    # zip the iterator with itself
    key_val_tuple = zip(list_iter, list_iter) # This will group two items in the list at a time
    output_list = []
    for i in key_val_tuple:
        value_dict = {}
        value = i[1].split('=')
        value_dict[value[0]] = value[1].split(",") if len(value[1].split(","))>1 else value[1]
        element_dict = {}
        element_dict[i[0]] = value_dict
        output_list.append(element_dict)
    return output_list

input_list = ['music', ' extension=mp3', 'reports/INFOB131', ' extension=doc,docx,pdf', ' name_contains=INFOB131', ' max_size=100000', 'reports/INFOB132', ' extension=doc,docx,pdf', ' name_contains=INFOB132', ' max_size=100000', 'games', ' name_contains=SC2,Wesnoth', 'pictures/Namur', ' extension=jpeg', ' min_size=5000000', ' name_contains=cercle', 'pictures/autres', ' extension=jpeg', ' min_size=5000000']

# Call the function foo
output = foo(input_list)
print(output) # python3
</code>```

Got the following output

[{'music': {' extension': 'mp3'}}, {'reports/INFOB131': {' extension': ['doc', 'docx', 'pdf']}}, {' name_contains=INFOB131': {' max_size': '100000'}}, {'reports/INFOB132': {' extension': ['doc', 'docx', 'pdf']}}, {' name_contains=INFOB132': {' max_size': '100000'}}, {'games': {' name_contains': ['SC2', 'Wesnoth']}}, {'pictures/Namur': {' extension': 'jpeg'}}, {' min_size=5000000': {' name_contains': 'cercle'}}, {'pictures/autres': {' extension': 'jpeg'}}]

zip(list_iter, list_iter) : This will group two items in the list at a time.

output : [('music', ' extension=mp3'), ('reports/INFOB131', ' extension=doc,docx,pdf'), ...]

Reference:

python zip()

What exactly are Python's iterator, iterable, and iteration protocols?

Convert List to a list of tuples python

Body:
I have to make a function whose purpose is taking in parameter a list.

Such as this one :

['music', ' extension=mp3', 'reports/INFOB131', ' extension=doc,docx,pdf', ' name_contains=INFOB131', ' max_size=100000', 'reports/INFOB132', ' extension=doc,docx,pdf', ' name_contains=INFOB132', ' max_size=100000', 'games', ' name_contains=SC2,Wesnoth', 'pictures/Namur', ' extension=jpeg', ' min_size=5000000', ' name_contains=cercle', 'pictures/autres', ' extension=jpeg', ' min_size=5000000']

And return a list similar to this :

data_config = [{'music' : {'extension':'mp3'}}, {'reports/INFOB131': {'extension': ['doc', 'docx','pdf'], 'name_contains':'INFOB131', 'max_size':100000}}, {'reports/INFOB132': {'extension': ['doc', 'docx','pdf'], 'name_contains':'INFOB132', 'max_size':100000}}]

So I made that function :

def my_function(list_in_question, my_config_list =[], prev_list = []):
    """ """
    enumerated_list = list(enumerate(list_in_question))

    if not '=' in enumerated_list[0][1]:
        main_key = enumerated_list[0][1]# référencé avant assignement
        pre_dict = {main_key : {}}

        for i in enumerated_list[1:]:

            if '=' in i[1] :
                splitted = i[1].split('=')
                prev_list.append({splitted[0] : splitted[1]})

            elif not '=' in i[1] and i[1] != main_key:
                for j in prev_list:
                    pre_dict[main_key].update(j)

                my_config_list.append(pre_dict)

                return my_function(list_in_question[i[0]:])

            elif not '=' in i[1] and i[1] == main_key and main_key!= enumerated_list[0][1]:
                return my_config_list
    else:
        print("The format of the file containig the data in not adequate !")

But I don't understand why when I execute it this way :

new_lines = ['music', ' extension=mp3', '', 'reports/INFOB131', ' extension=doc,docx,pdf', ' name_contains=INFOB131', ' max_size=100000', '', 'reports/INFOB132', ' extension=doc,docx,pdf', ' name_contains=INFOB132', ' max_size=100000', '', 'games', ' name_contains=SC2,Wesnoth', '', 'pictures/Namur', ' extension=jpeg', ' min_size=5000000', ' name_contains=cercle', '', 'pictures/autres', ' extension=jpeg', ' min_size=5000000']

my_function(new_lines)

I end up with this output...

None

I would be very grateful if someone could help me,

Thank you !

PS : If anyone have an idea of how I could do without loop and do it in a recursive way, it would be awesome !

Everyone... Thank you !!! You really hepled me, all your answers are awesome, I have some issues to understand some parts so I'll be annoying just a little longer with some questions of you code. Anyway, thank you for the time you took to help me, you were all more than great help !!!

Body:
Try the following code;

def foo(my_list):
    # Create an iterator
    list_iter = iter(my_list)
    # zip the iterator with itself
    key_val_tuple = zip(list_iter, list_iter) # This will group two items in the list at a time
    output_list = []
    for i in key_val_tuple:
        value_dict = {}
        value = i[1].split('=')
        value_dict[value[0]] = value[1].split(",") if len(value[1].split(","))>1 else value[1]
        element_dict = {}
        element_dict[i[0]] = value_dict
        output_list.append(element_dict)
    return output_list

input_list = ['music', ' extension=mp3', 'reports/INFOB131', ' extension=doc,docx,pdf', ' name_contains=INFOB131', ' max_size=100000', 'reports/INFOB132', ' extension=doc,docx,pdf', ' name_contains=INFOB132', ' max_size=100000', 'games', ' name_contains=SC2,Wesnoth', 'pictures/Namur', ' extension=jpeg', ' min_size=5000000', ' name_contains=cercle', 'pictures/autres', ' extension=jpeg', ' min_size=5000000']

# Call the function foo
output = foo(input_list)
print(output) # python3

Got the following output

[{'music': {' extension': 'mp3'}}, {'reports/INFOB131': {' extension': ['doc', 'docx', 'pdf']}}, {' name_contains=INFOB131': {' max_size': '100000'}}, {'reports/INFOB132': {' extension': ['doc', 'docx', 'pdf']}}, {' name_contains=INFOB132': {' max_size': '100000'}}, {'games': {' name_contains': ['SC2', 'Wesnoth']}}, {'pictures/Namur': {' extension': 'jpeg'}}, {' min_size=5000000': {' name_contains': 'cercle'}}, {'pictures/autres': {' extension': 'jpeg'}}]

zip(list_iter, list_iter) : This will group two items in the list at a time.

output : [('music', ' extension=mp3'), ('reports/INFOB131', ' extension=doc,docx,pdf'), ...]

Reference:

python zip()

What exactly are Python's iterator, iterable, and iteration protocols?

Convert List to a list of tuples python


问:
How to change the position of an element when I do a click action
So I'm designing an application that makes it easy to fetch result from wikipedia. Now What I want to do firstly is that when the search value has been entered into the search bar and I click on the search Icon, I want the search bar to move up and create space for the incoming result. Yes I have some codes but it's not working yet. Also The API call to wikipedia seems not to be working as well, I will also need help with that. Below is the Javascript code: </p>

```<code>$(document).ready(function() {

  let searchValue = document.getElementById("#searchString").value;

  $(".sbutton").on("click", function() {
    // code to push the wrap div element and icon up the container
    $(".wrap").animate({
      marginTop: "5px"
    });

    let baseUrl = " https://en.wikipedia.org/w/api.php? ";
    let tailUrl =
      "action=opensearch&format=jsonfm&search=" + searchValue + "&limit=10";
    let wikiLink = baseUrl + tailUrl;

    $.ajax({
      url: wikiLink,
      type: "GET",
      dataType: "json",
      success: function getWikiData(data) {
        let dDiv = document.createElement("div");
        dDiv = "content";
        dDiv.className = "secondDiv";
document.getElementByClassName("container").append(dDiv);
        for (var i = 0; i < data.opensearch.search.length; i++) {
          $("#content").appendChild(
            "<p>" + data.opensearch.search[2].title + "</p>"
          );
        }
      },

      error: function(error) {
        console.log(error);
      }
    });
  });
});
</code>```

答:
One way to do it is to add some css to the element.

```<code>$(".wrap").css( "marginTop", "5px" );
</code>```

read more about the jQuery css here http://api.jquery.com/css/

Make sure that youcalls the jQuery aswell, easiest way is through cdn, here you go:
https://cdnjs.com/libraries/jquery/

here you have working fiddle
https://jsfiddle.net/6txwmh8L/

Body:
So I'm designing an application that makes it easy to fetch result from wikipedia. Now What I want to do firstly is that when the search value has been entered into the search bar and I click on the search Icon, I want the search bar to move up and create space for the incoming result. Yes I have some codes but it's not working yet. Also The API call to wikipedia seems not to be working as well, I will also need help with that. Below is the Javascript code:

$(document).ready(function() {

  let searchValue = document.getElementById("#searchString").value;

  $(".sbutton").on("click", function() {
    // code to push the wrap div element and icon up the container
    $(".wrap").animate({
      marginTop: "5px"
    });

    let baseUrl = " https://en.wikipedia.org/w/api.php? ";
    let tailUrl =
      "action=opensearch&format=jsonfm&search=" + searchValue + "&limit=10";
    let wikiLink = baseUrl + tailUrl;

    $.ajax({
      url: wikiLink,
      type: "GET",
      dataType: "json",
      success: function getWikiData(data) {
        let dDiv = document.createElement("div");
        dDiv = "content";
        dDiv.className = "secondDiv";
document.getElementByClassName("container").append(dDiv);
        for (var i = 0; i < data.opensearch.search.length; i++) {
          $("#content").appendChild(
            "
" + data.opensearch.search[2].title + "
"
          );
        }
      },

      error: function(error) {
        console.log(error);
      }
    });
  });
});

Body:
One way to do it is to add some css to the element.

$(".wrap").css( "marginTop", "5px" );

read more about the jQuery css here http://api.jquery.com/css/

Make sure that youcalls the jQuery aswell, easiest way is through cdn, here you go:
https://cdnjs.com/libraries/jquery/

here you have working fiddle
https://jsfiddle.net/6txwmh8L/


问:
React Rendering Dynamic Inner Components
This example illustrates what i`m tryng to do.

The goal is to have a dynamic component array and render it o the screen. I`m not being able to do the rendering part.

```<code>import PropTypes from 'prop-types';
import React from 'react';
import MyComponent1 from './MyComponent1.jsx'
import MyComponent2 from './MyComponent2.jsx'

export default class KneatModalContent extends React.Component {

constructor() {
   super();
   this.components = [MyComponent1, MyComponent2];
}

render() {
  return (
  <div className='modal-contents'>
     {this.components.map(function (component, i) {
        return <{ component } key= { i } />
     })}
  </div>
)
}
}
</code>```

I have tryed to create the array as [<MyComponent1/>, <MyComponent2/>] as well, as tryed to render as React.createElement(component, {key:i}) but still couldnt find a solution =(

答:
In order to create dynamic component, you could just do the following </p>

```<code>constructor() {
   super();
   this.components = [MyComponent1, MyComponent2];
}

render() {
      return (
      <div className='modal-contents'>
         {this.components.map(function (Component, i) {
            return <Component key= { i } />
         })}
      </div>
    )
  }
</code>```

Body:
This example illustrates what i`m tryng to do.

The goal is to have a dynamic component array and render it o the screen. I`m not being able to do the rendering part.

import PropTypes from 'prop-types';
import React from 'react';
import MyComponent1 from './MyComponent1.jsx'
import MyComponent2 from './MyComponent2.jsx'

export default class KneatModalContent extends React.Component {

constructor() {
   super();
   this.components = [MyComponent1, MyComponent2];
}

render() {
  return (

     {this.components.map(function (component, i) {
        return <{ component } key= { i } />
     })}

)
}
}

I have tryed to create the array as [<MyComponent1/>, <MyComponent2/>] as well, as tryed to render as React.createElement(component, {key:i}) but still couldnt find a solution =(

Body:
In order to create dynamic component, you could just do the following

constructor() {
   super();
   this.components = [MyComponent1, MyComponent2];
}

render() {
      return (
      <div className='modal-contents'>
         {this.components.map(function (Component, i) {
            return <Component key= { i } />
         })}
      </div>
    )
  }


问:
.NET XSD validation confusion
I am attempting to use an XmlReader and associated XmlReaderSettings object to perform XSD validation on some documents. I am declaring a ValidationEventHandler which I was expecting would get called whenever the reader encounters a validation problem. However I am getting an XSDValidationException when I attempt to create the reader.

Any idea what would cause the exception? The message is:

System.Xml.Schema.XmlSchemaValidationException: The 'http://www.w3.org/XML/1998/namespace:base' attribute is not declared.

Could there be an issue with one of the underlying schemas?

答:
Verify that your actual XML document does not have a root element in no namespace.

This error can appear when your schema validation has a target namespace but the XML document being validated contains any root elements without a namespace.

Unfortunately schema validation in this case will only generate a warning that it does not find a matching schema for the root element and that warning is only displayed when a certain flag to report warnings is set, which is not set when using the Validate method of XmlDocument.

Title: .NET XSD validation confusion


问:
NameNode: Failed to start namenode in windows 7
I am trying to install Hadoop in windows machine, in middle I got the below error.

Logs

```<code> 17/11/28 16:31:48 ERROR namenode.NameNode: Failed to start namenode.
 java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Ljava/lang/String;I)Z
    at org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Native Method)
    at org.apache.hadoop.io.nativeio.NativeIO$Windows.access(NativeIO.java:609)
    at org.apache.hadoop.fs.FileUtil.canWrite(FileUtil.java:996)
    at org.apache.hadoop.hdfs.server.common.Storage$StorageDirectory.analyze
 Storage(Storage.java:490)
    at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverStorageDirs(FSImage.java:369)
    at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:225)
    at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.loadFSImage(FSNamesystem.java:978)
    at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.loadFromDisk(FSNamesystem.java:685)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.loadNamesystem(NameNode.java:585)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:645)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:819)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:803)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1500)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1566)
</code>```

答:
I also have the similar issue.
I am using Hadoop-2.8.1. These steps solved the error for me.

download the winutils of your version from GitHub

Copy paste winutils at <HADOOP_HOME>/bin/

Also. double check JAVA_HOME environment is correctly set and reference in hadoop-env.cmd file

Body:
I am trying to install Hadoop in windows machine, in middle I got the below error.

Logs

 17/11/28 16:31:48 ERROR namenode.NameNode: Failed to start namenode.
 java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Ljava/lang/String;I)Z
    at org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Native Method)
    at org.apache.hadoop.io.nativeio.NativeIO$Windows.access(NativeIO.java:609)
    at org.apache.hadoop.fs.FileUtil.canWrite(FileUtil.java:996)
    at org.apache.hadoop.hdfs.server.common.Storage$StorageDirectory.analyze
 Storage(Storage.java:490)
    at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverStorageDirs(FSImage.java:369)
    at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:225)
    at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.loadFSImage(FSNamesystem.java:978)
    at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.loadFromDisk(FSNamesystem.java:685)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.loadNamesystem(NameNode.java:585)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:645)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:819)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:803)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1500)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1566)