instantiation

JSF application scope instantiation and injection

落花浮王杯 提交于 2019-12-12 08:26:07
问题 Probably my question is a trivial one, but I never used an application scope bean before. I need the application bean because I have to do time consuming transactions on the database. my search didn't satisfy my curiosity at all. I don't know why but I didn't manage to initialize the bean (it is null) or it the app crashed. So I have an application scope bean @ManagedBean(eager=true) @ApplicationScoped public class ApplicationContainer { ... } eager=true I read that tells JSF to initiate the

How to instantiate object class that contains GameObject?

徘徊边缘 提交于 2019-12-12 04:45:25
问题 I am attempting to instantiate a large number of "particles" using a C# script in Unity. I have created a particle class that contains the creation of a corresponding GameObject. The GameObject within each particle instance is a sphere. When attempting to instantiate a new particle (Particle p = new Particle(...)) I get a Unity warning that the 'new' keyword should not be used. "You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. MonoBehaviours can only be

Using FastActivator in place of Activator.CreateInstance()

≯℡__Kan透↙ 提交于 2019-12-12 00:22:00
问题 Trying to use Class shown here as a sample for Activator.CreateInstance() http://codeblocks.codeplex.com/wikipage?title=FasterActivator%20Sample public static List<T> SortedCollection<T>(SPListItemCollection items, ListSortType sortType, List<Vote> votes) where T : IVotable { var returnlist = new List<T>(); var functionCreator = FastActivator.GenerateFunc<Func<SPListItem, List<Vote>, T>>(); for (int i = 0; i < items.Count; i++) { returnlist.Add(functionCreator(items[i], votes)); } } switch

Deleting the last Instantiated GameObject from a List and Scene

北战南征 提交于 2019-12-12 00:19:23
问题 So I'm missing something that's probably pretty straightforward to some, but I'm having trouble with it. I've created a List (msgSymbols) that gets populated with a new GameObject every time a button gets pressed (it's basically a custom keyboard) which then gets instantiated to a Grid Layout. But how do I then delete only the last GameObject on that list and update the Grid Layout to reflect that change? (like hitting a backspace button on the keyboard)? The delete key code that I currently

C++ How to use vectors with templates? [duplicate]

倖福魔咒の 提交于 2019-12-11 19:19:33
问题 This question already has answers here : Why can templates only be implemented in the header file? (16 answers) Closed 5 years ago . I'm working through an algorithm text, trying to implement everything in C++ for practice. But I can't seem to figure out templating.I have three files: algPlayground.h #include <stdlib.h> #include <vector> using namespace std; template <class T> void insertionSort(vector<T>& toSort); algPlayground.cpp #include <stdlib.h> #include <vector> #include

Instantiation of a module in verilog

感情迁移 提交于 2019-12-11 19:12:44
问题 I am getting an error in instantiating a module in verilog file. I am instantiating like this: module lab3(input clk,set,reset,plus,minus,start,button,output reg [3:0]led,output reg [6:0]y); wire [3:0] indicesgu[3:0]; reg [1:0] going; reg alsogoing,yes; if (going==1 && alsogoing) begin up_counter up_0 ( indicesgu , indices , alsogoing ); end endmodule and my up_counter module starts as: module up_counter(input [3:0] indices_in [3:0],output [3:0]indices[3:0],output alsogoing); reg [3:0]indices

How to safely and dynamically create an instance of an existing PHP class?

不问归期 提交于 2019-12-11 13:39:46
问题 Say I have a file Foo.php: <?php interface ICommand { function doSomething(); } class Foo implements ICommand { public function doSomething() { return "I'm Foo output"; } } ?> If I want to create a class of type Foo I could use: require_once("path/to/Foo.php") ; $bar = new Foo(); But say that I've created a Chain of Command Pattern and I have a configuration file that registers all the possible classes and creates an instance of these classes based on strings that are present in the

InstantiationException when using newInstance on BroadcastReceiver

别说谁变了你拦得住时间么 提交于 2019-12-11 10:06:03
问题 I do have a class with lots of static convenience methods. One of them should start a BroadcastReceiver dynamically - but it always returns an InstantiationException. The BroadcastReceiver has a no-parameter constructor so it should work - but it doesn't. Here's what I did so far: Here's the convenience method in it's class: // Static convenience methods in a tools class public class MyTools { // Start BroadcastReceiver dynamically public static BroadcastReceiver startBroadcastReceiver

Can only return, not assign, Self?

大城市里の小女人 提交于 2019-12-11 09:22:12
问题 Consider this pattern extension UIViewController { class func make(sb: String, id: String) -> Self { return helper(sb:sb, id:id) } private class func helper<T>(sb: String,id: String) -> T { let s = UIStoryboard(name: storyboardName, bundle: nil) let c = s.instantiateViewControllerWithIdentifier(id) as! T return c } } that works fine, so let s = SomeViewControllerClass.make( ... ) does in fact return the subclass "SomeViewControllerClass". (Not just a UIViewController.) That's all fine BUT,

Instantiating Objects & the relation of Child/Parent classes

江枫思渺然 提交于 2019-12-11 07:55:08
问题 So, I'm trying to understand some concepts here. 1) The general "syntax" (if you will) of creating a new object. For example, which of the following is "correct" (I know there's more than one way to instantiate an object): //1) ChildClass obj = new ParentClass(); //2) ParentClass obj = new ChildClass(); I know that the following two are "legal," but I can't understand the difference between instantiating an object when it comes to Child/Parent classes (I already know that these two are okay):