methods

Unable to locate the specified class while calling another controller in codeigniter

冷暖自知 提交于 2020-01-05 08:20:43
问题 I have following code for controller Qprs <?php defined('BASEPATH') OR exit('No direct script access allowed'); class Qprs extends CI_Controller { public function xyz() { //some code } } below code used to call above controller from another controller $this->load->library('../controllers/Qprs'); $this->Qprs->xyz(); but getting error: Unable to locate the specified class Qprs.php How to solve such error? 回答1: Very simple way in codeigniter to call a method of one controller to other controller

HTML Checkbox automatically send POST

回眸只為那壹抹淺笑 提交于 2020-01-05 07:40:15
问题 I'm trying to collect checkbox data without adding button to submit. This is the code I have so far: <!-- Web form --> <form class="switcher-form" method="post"> <p class="setting-switch setting-switch-first"> <label for="setting1">Controle Total</label> <!-- switcher checkbox #1 --> <input type="checkbox" class="switcher" checked name="setting1" value="1" onclick="submit();"/> </p> <p class="setting-switch"> <label for="setting2">Controle Sala</label> <!-- switcher checkbox #2 --> <input

Combination of getter and list modification in Java

对着背影说爱祢 提交于 2020-01-05 07:25:42
问题 today i dealt with a Java problem that really confused me. I have the following code: List<ObjectXY> someList = obj.getListOfObjectsXY(); // getter returns 2 elements someList.add(new ObjectXY()); obj.getListOfObjectsXY(); // getter now returns 3 elements When i add an element to a list, the getter gets some kind of overwritten. Is this because someList acts like a reference on the result of the getter in this case? Or what else causes this effect? I solved the problem with the following code

How to call a method on .mm file from a objective c class

别说谁变了你拦得住时间么 提交于 2020-01-05 07:04:41
问题 I am working on an iphone app. I need to call a method on a .mm file. Here is simplified version of the problem: ViewHelper.h - (void)testMtd; ViewHelper.mm (notice this is .mm) - (void)testMtd{ NSLog(@"Call reached mm"); } SomeViewController.m (import to ViewHelper.h omitted for clarity) - (void)someCallerMtd{ NSLog(@"before"); [viewHelper testMtd]; //call does not work NSLog(@"after"); } I see "before" and "after" in the log, but "Call reached mm" never gets printed. Are there special rules

C# Ui freezes when calling a method

我怕爱的太早我们不能终老 提交于 2020-01-05 03:37:11
问题 I got a function called Connect() this function takes about 2-3seconds because it use some api requests. Now I want to find a way that my Ui dont freeze while ill start this function. private void connectToolStripMenuItem_Click(object sender, EventArgs e) { Connect() // << this tooks a lot of time } I have tried to solve it with a thread private void connectToolStripMenuItem_Click(object sender, EventArgs e) { new Thread(Connect).Start(); } and a backgroudnworker private void

Scala call logging method without “log.xxxx”

人盡茶涼 提交于 2020-01-05 02:47:27
问题 Is there a way to do the following without having to manually define the logging methods e.g. def error : object FooBar { lazy val log = LoggerFactory.getLogger("AndroidProxy") def error(msg: String) = log.error(msg) def my_method(): Unit = { error("This is an error!") } } 回答1: replace def error with import log.error 回答2: If you want to log in many classes and not rewrite the logging method every time, you can create a trait trait Logging { lazy val logger = LoggerFactory.getLogger(getClass()

Why am I getting error Undefined method `name' for nil:NilClass with Ruby on Rails?

倖福魔咒の 提交于 2020-01-04 21:35:54
问题 I thought methods such as name and email were default in rails? In my static pages view, in profile.html.erb I have: <% if logged_in? %> <% provide(:title, @user.name) %> <% else %> <% provide(:title, 'Profile')%> <% end %> I put in my static_page_controller def profile @user = User.find_by_remember_token(:remember_token) end When I go to the console User.find_by_remember_token("actualtoken").name returns me the appropriate users name, but :remember_token does not. How do I make :remember

foreach in method to return value

霸气de小男生 提交于 2020-01-04 15:31:51
问题 def a: Int = { for(i <- Array(1,2,3,4,5)){ if(i == 3) return i } } The above method will not compile, I get the following error: error: type mismatch; found : Unit required: Int for(i <- Array(1,2,3,4,5)){ ^ The expected behaviour is that the method returns 3. What is wrong with my code? 回答1: That is because your lambda in the foreach does guarantee to return a value. If you provide a default return value it should work. def a: Int = { for(i <- Array(1,2,3,4,5)){ if(i == 3) return i } 0 } 回答2

javascript - how to “fluent API” (also calling “chaining”)?

ぃ、小莉子 提交于 2020-01-04 15:16:15
问题 I am trying to understand is how to create call methods after a method call. For example in jquery you have something like this: $("blah").data("data-id"); How would I make : blah("cow").foo("moo"); Where the mothods blah and foo just console.log(value) ? 回答1: What you're referring to is a "fluent API" (also calling "chaining"). Your functions need to return the object that has the next method you want to call on it. For example, var obj = function(){ var self = this; self.blah = function(v){

How do I write a lambda expression that looks like a method?

徘徊边缘 提交于 2020-01-04 14:19:07
问题 I've been going nuts trying to figure this out. Consider the following code (I'm assuming forward references have been defined): // Signature representing a pointer to a method call typedef void (MyClass::*MyMethod)(int); class MyClass { MyClass(); void method1(int i); void method2(int i); void associateMethod(int index, MyMethod m); } Given the above, the constructor can do things like the following: MyClass::MyClass() { associateMethod(1, &MyClass::method1); associateMethod(2, &MyClass: