scope

Scopes of ActionMapper, ActionProxy, ActionInvocation, ActionContext objects in Struts2?

血红的双手。 提交于 2019-12-20 07:26:45
问题 Can any one please describe me when the objects of ActionMapper , ActionProxy , ActionInvocation , ActionContext are created in a Struts2 application. As I am new to Struts2 framework, I am very much confused about the scopes of these objects. 回答1: The ActionMapper is created on startup, it has a singleton scope. The ActionContext is created by the Dispatcher in preparing an action to execute, it's ThreadLocal, and it doesn't have any scope. When action is executing the ActionInvocation and

Instance variable not retaining value in iOS application

吃可爱长大的小学妹 提交于 2019-12-20 05:28:09
问题 I have declared this ivar in my ViewController.h #import <UIKit/UIKit.h> @interface FirstViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> { NSArray *sortedCountries; } @property (nonatomic, retain) NSArray *sortedCountries; @end In ViewController.m, sortedCountries does it's job in -(void)ViewDidLoad{} by storing the result of a sorted .plist. When -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {} is called

(java) variable scope inside try { } when accessing from finally { }?

ⅰ亾dé卋堺 提交于 2019-12-20 05:23:22
问题 I noticed that when the following variables when in try { }, I couldn't use methods on them from finally for example: import java.io.*; public class Main { public static void main()throws FileNotFoundException { Try{ File src = new File("src.txt"); File des = new File("des.txt"); /*code*/ } finally{ try{ /*closing code*/ System.out.print("After closing files:Size of src.txt:"+src.length()+" Bytes\t"); System.out.println("Size of des.txt:"+des.length()+" Bytes"); } catch (IOException io){

(java) variable scope inside try { } when accessing from finally { }?

久未见 提交于 2019-12-20 05:21:26
问题 I noticed that when the following variables when in try { }, I couldn't use methods on them from finally for example: import java.io.*; public class Main { public static void main()throws FileNotFoundException { Try{ File src = new File("src.txt"); File des = new File("des.txt"); /*code*/ } finally{ try{ /*closing code*/ System.out.print("After closing files:Size of src.txt:"+src.length()+" Bytes\t"); System.out.println("Size of des.txt:"+des.length()+" Bytes"); } catch (IOException io){

JavaScript How to get value of variable assigned inside Promise onSuccess outside promise

北慕城南 提交于 2019-12-20 04:35:08
问题 I'm whiting firefox extension. I got function that's reading contents of file: var HelloWorld = {... getData: function () { var env = Components.classes["@mozilla.org/processenvironment;1"].getService(Components.interfaces.nsIEnvironment); var path = env.get("TEMP"); path = path + "\\lastcall.txt" alert(path); Components.utils.import("resource://gre/modules/osfile.jsm"); let decoder = new TextDecoder(); let promise = OS.File.read(path); var line = null; promise = promise.then( function

Returning Array from function in C

爷,独闯天下 提交于 2019-12-20 04:29:17
问题 For some reason, my function is only returning the first element in my array and I cannot figure out why the rest of the array goes out of scope. The function takes two integer arrays, adds their respective elements, and puts the sum into a third array which is returned. Here is my code: #include <stdio.h> /* count digits, white space, others */ int *sumarrays(int arr1[], size_t arr1len, int arr2[], size_t arr2len); void main() { int arr1[10]; size_t arr1len = 10; int arr2[10] = { 2, 2, 2, 2,

Why does my recursive function return “None”?

一个人想着一个人 提交于 2019-12-20 03:07:40
问题 All, I have a dictionary of lists of dictionaries in Python. This represents a parent-child relationship. Given a child, I would like to return the parent. Here is my collection: tree = { u'one' : [ { u'two' : [ { u'three' : [] }, { u'four' : [] } ] }, { u'five' : [ { u'six' : [] } ] } ] } As you can see, "one" has children "two" and "five", "two" has children "three" and "four", "three" has no children, and so on. The following code correctly works out the parent of a given child: def find

What is C local function declaration mechanism?

社会主义新天地 提交于 2019-12-20 02:29:23
问题 Local function declaration seems to be permitted in gcc, and I found a discussion on this: Is there any use for local function declarations? However, my question is: is it allowed by ISO C standard? If it is, how to explain the following phenomenon which makes it puzzling: int main(void) { int f(void); f(); } void g(void) { /* g has no idea about f. It seems that the decl is limited within its * scope */ f(); } int f(void) {} while int main(void) { int f(void); f(); } void f(void); /* error

JavaScript loop/scope issue with Image.onload()

旧街凉风 提交于 2019-12-20 02:16:56
问题 I'm trying to loop through an object with JavaScript and add all the subobjects from that object to a HTML5 canvas. The canvas-bit is working, no problem with that, but for some reason all my images end up being the same size - the size of the last subobject 'background'. I'm assuming that it has to do with the scope of my loop and 'this', but I can't really see what to change; var stage; var items = { head: {image: null, path: "images/avatar-elements/head01.png", w:200, h:200}, hair: {image:

Performance of accessing class variables in Python

瘦欲@ 提交于 2019-12-20 01:38:17
问题 I wonder if there is any difference in performance when accessing a class variable (a dict) inside a method of the same class using: self.class_variable_dict.add(some_key, some_value) and ClassName.class_variable_dict.add(some_key, some_value) obviously, both will work as long as there is no instance variable with the same name, but is there any reason/use case for which we should prefer one over the other? 回答1: Accessing it via ClassName rather than via self will be slightly faster, since if