state

What is the best way to add a value to an array in state

白昼怎懂夜的黑 提交于 2019-11-28 04:05:33
I have an array in state, let's say this.state.arr. I want to add something to this state property, and then change some more properties. Option 1 onChange(event){ this.state.arr.push('newvalue'); ... this.setState({some:'val',arr:this.state.arr}) } Option 2 onChange(event){ var newArr = this.state.arr; ... newArr.push('newvalue'); ... this.setState({some:'val',arr:newArr}) } So.. I know this.state is supposed to be treated immutable. But is it ok to use it like in option 1 where I still set the state from it, or do I need to go with something like option 2, and thus always first making a copy

java.lang.IllegalStateException: Cannot create a session after the response has been committed

柔情痞子 提交于 2019-11-28 02:26:15
I've got this really strange request for an invalid URL on: Invalid URL: /cgi-bin/1st.cgi This is causing the following error: SEVERE: Exception initializing page context java.lang.IllegalStateException: Cannot create a session after the response has been committed at org.apache.catalina.connector.Request.doGetSession(Request.java:2381) at org.apache.catalina.connector.Request.getSession(Request.java:2098) at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833) at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216) at org.apache

How can I maintain the state of dialog box with progress all over my Angular 2 application?

╄→尐↘猪︶ㄣ 提交于 2019-11-28 02:13:34
I would like to keep the state of the Md Dialog alive even I close the dialog.So that I can keep the upload status active all over the application. My plan is to store the upload response in the service to maintain the upload progress and an icon will be given in the toolbar.The dialog box reinitializes everytime. How can I maintain the state of dialog box with upload progress all over the application? app.component.ts import { Component, NgZone, Inject, EventEmitter } from '@angular/core'; import { NgUploaderOptions, UploadedFile, UploadRejected } from 'ngx-uploader'; import { MdDialog,

Pressed android button state

試著忘記壹切 提交于 2019-11-28 01:12:20
I've been following a tutorial that explains how to use background for a button with different states but it doesn't seem to work :S Here is my code : <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/boutonn" android:state_window_focused="false"/> <item android:drawable="@drawable/boutonnpousse" android:state_pressed="true"/> <item android:drawable="@drawable/boutonnpousse" android:state_focused="true"/> <item android:drawable="@drawable/boutonn" android:state_focused="false" android:state_pressed=

How can I remove an attribute from a Reactjs component's state object

痞子三分冷 提交于 2019-11-27 23:18:39
问题 If I have a react component that had a property set on it's state: onClick() { this.setState({ foo: 'bar' }); } Is it possible to remove "foo" here from Object.keys(this.state) ? The replaceState method looks like the obvious method to try but it's since been depreciated. 回答1: You can set foo to undefined , like so var Hello = React.createClass({ getInitialState: function () { return { foo: 10, bar: 10 } }, handleClick: function () { this.setState({ foo: undefined }); }, render: function() {

UI-Router Multiple Views Single Controller not work

最后都变了- 提交于 2019-11-27 23:16:04
I would like to use one controller defined in views, but the $scope does not define anything. Is there a way to do this? Please share a simple example in order to understand. I have this index.html <body ng-app="ehc"> <h1>{{home}}+{{a}}+{{b}}</h1> <ion-side-menus enable-menu-with-back-views="false" delegate-handle="left"> <!-- Left menu --> <ion-side-menu side="left" is-enabled="true"> <ion-header-bar class="bar-stable">AAA</ion-header-bar> <ion-content> <div class="list"> <div class="item item-divider"> Candy Bars </div> </div> </ion-content> </ion-side-menu> <ion-side-menu-content edge-drag

How to simulate a corrupt state exception in .NET 4?

℡╲_俬逩灬. 提交于 2019-11-27 23:05:27
Well, in .NET 4 Microsoft added the HandleProcessCorruptedStateExceptions attribute: HandleProcessCorruptedStateExceptionsAttribute Class I want to test this feature. How can I bring my application to a "corrupt state"? Screwing up the garbage collected heap is always a good way: using System; using System.Runtime.InteropServices; class Program { unsafe static void Main(string[] args) { var obj = new byte[1]; var pin = GCHandle.Alloc(obj, GCHandleType.Pinned); byte* p = (byte*)pin.AddrOfPinnedObject(); for (int ix = 0; ix < 256; ++ix) *p-- = 0; GC.Collect(); // kaboom } } Just dereference a

How do you pass or share variables between django views?

孤人 提交于 2019-11-27 23:02:05
I'm kind of lost as to how to do this: I have some chained select boxes, with one select box per view. Each choice should be saved so that a query is built up. At the end, the query should be run. But how do you share state in django? I can pass from view to template, but not template to view and not view to view. Or I'm truly not sure how to do this. Please help! There are many ways... in the view to template... put the variables in hidden fields in the forms. So when you "submit" in the subsequent forms... the values are then contained in the following request.POST.get(). Of course you can

is it possible to do 'stateless' programming in matlab / how to avoid checking data integrity?

一个人想着一个人 提交于 2019-11-27 22:37:46
My day to day work flow is something like this: acquire raw data (~50GB) parse raw data timing-information and build raw data structure (struct / object) from timing-information (what event occurred when, in which order, in what file, what other events occurred at the same time, etc ...) load only the necessary parts of raw data into struct / object as selected from previous timing information (basically this is a way to sub-select data) for each raw data chunk, calculate / extract certain metrics like RMS of signal, events where data > threshold, d' / z-score, and save them with struct /

How can I get a list of instantiated beans from Spring?

╄→гoц情女王★ 提交于 2019-11-27 19:48:45
I have several beans in my Spring context that have state, so I'd like to reset that state before/after unit tests. My idea was to add a method to a helper class which just goes through all beans in the Spring context, checks for methods that are annotated with @Before or @After and invoke them. How do I get a list of instantiated beans from the ApplicationContext ? Note: Solutions which simply iterate over all defined beans are useless because I have many lazy beans and some of them must not be instantiated because that would fail for some tests (i.e. I have a beans that need a java.sql