Hi Folks,
I have a static object defined in my logging class, along the lines of:
class myLoggingClass {
static java.util.Properties properties;
...
...
}
According to my reference book, this means that the properties object is shared by all instances of my class.
I find this definition insufficient. I'm writin...
I would like to add a couple of instance variables to my controller, since the variables in question are required from within more than one action's view. However, the below example does not work as I would expect.
class ExampleController < ApplicationController
@var1 = "Cheese"
@var2 = "Tomato"
def show_pizza_topping
# What ...
Hi,
Consider the following Javascript code:
var a = [];
var f = function() {
for (var i = 0; i < 3; i++) {
a.push(function(){alert(i)});
}
for (var j = 0; j < 3; j++) {
a[j]();
}
};
The alerts print out '3' all three times. I want a different behaviour - in each iteration of the loop generate a funct...
I just spent some time debugging a problem that boiled down to forgetting to use the var keyword in front of a new variable identifier, so Javascript was automatically creating that variable in the global scope. Is there any way to prevent this, or change the default behavior, without using a validator like JSLint?
Running a validator i...
I'm using an MVC setup and I'm trying to inject javascript into my views (.php), yet allow the javascript access to all the variables that the view has access to. My end goal is to be able to access PHP variables from my javascript (for example so I could alert() a product's name).
Here's my application flow:
start output buffer
call ...
package a{
public class a{
public var a_var:String;
public var x_var:String;
public function a(){
var a_var = 'My name';
var x_var = 'X string'
}
public function show_a():String{
return a_var;
}
}
public class b{
public function b(){
var a_obj:a = new a();
trace('trace' ...
I need to make a grand total of the items I'm counting in a subReport. To do that, I think I need to add the value of that variable to another variable for each iteration, or "increment" it by that value. The subReport gets called for each group, and I get a total for that group. I need to add the variable values, rather than database co...
In some languages, there are things like these:
Lisp:
(let ((x 3))
(do-something-with x))
JavaScript:
let (x = 3) {
doSomethingWith(x);
}
Is there anything like this in C#?
...
Hello,
I have a var to get thumbnails width, and it's set at the beggining of my class code.
var thumbW:Number;
Then I update that var inside a function that updades with stage resize.
function x(){
var thumbW:thumbnails.width;
//tracing thumbW here returns the updated value. Perfect!
}
Then I try to get the thumbW valu...
Assume that we have 3 classes:
Place, Contact, PhoneNumber classes.
Under the Place class, I want to have a Contact class but it is better to keep PhoneNumber class under the Contact class. So in the Place class, it is more logical to reach the PhoneNumber by first getting the Contact object, then the PhoneNumber under the Contact obj...
Does InputStreams and OutputStreams in Java close() on destruction? I fully understand that this may be bad form (esp in C and C++ world), but I'm curious.
Also, suppose I have the following code:
private void foo()
{
final string file = "bar.txt";
Properties p = new Properties();
p.load( new FileInputStream(file) );
//...
I'm asking this question because I finally solved a problem that I have been trying to find a technique for in a number of cases. I think it's pretty neat so I'm doing a Q-and-A on this.
See, if I could use eval, I would just do this:
eval join( "\n"
, map {
my $v = $valcashe{$_};
sprintf( '$Text:...
I'm writing a equals(Object obj) function for a class. I see that it is possible to access the private fields of obj from the caller. So instead of using a getter:
Odp other = (Odp) obj;
if (! other.getCollection().contains(ftw)) {
}
I can just access the field directly:
Odp other = (Odp) obj;
if (! other.collection.contains(ftw)) {...
Hi,
I currently have two classes, one called Dog, one called Poodle. Now how can I use a variable defined in Dog from the Poodle class. My code is as follows:
class dog {
protected static $name = '';
function __construct($name) {
$this->name = $name
}
}
class Poodle extends dog {
functi...
How can I call the Jquery Function From other javaScript Function (Not
from jquery function)
i.e
I have written some Jquery code like below
$(document).ready(function()
{
function func1(){
// Do Something.
}
});
Now I want to call the func1() function from other JavaScript Function
i.e Say an Example
function...
Hi Everyone,
I have three view controllers, one root controller, one login view controller and one customers view controller. I want to pass the entered username and password in login view controller to the customers view controller. My files and code is displayed below, could you please guide me, how can access to variables set in the ...
I'm having a problem with some JavaScript code.
Script
setTimeout(function() {
for (var i = 0; i < 5; i++) {
setTimeout(function() {
console.log(i);
}, i * 200);
}
}, 200);
Outputs
5, 5, 5, 5, 5 instead of 1, 2, 3, 4, 5
I can kind of understand why this doesn't work, but I was wondering if someon...
I've recently seen some code similar to that outlined below.
public void someMethod() {
Lecture lect = createLecture();
...
lect.getLectureSeries().delete();
}
public Lecture createLecture() {
LectureSeries series = new Series();
Lecture lect = new Lecture(series);
...
return lect;
}
The point being that some objec...
What is better for performance wise declaring the variable outside the foreach statment and the each time reassign it in side it (foreach) or create an new variable inside foreach
for example
private List<ListItem> GetItems()
{
var items = new List<ListItem>();
var collection = new List<int> { 0, 1, 2, 3,...
I have a jQuery script:
$.ajax({
url: "/scripts/secure/development/ajax.asp",
type: "POST",
dataType: "text",
data: "cmd=addresses",
success: function(msg){
var arrRows = msg.split("#*#");
for(i=0;i<arrRows.length;i++){
var record_id = arrRows[i].split("|")[0];
var address = arrRows[i].split("|")[1];
...