Search Results

Search found 2536 results on 102 pages for 'initialize'.

Page 5/102 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to initialize a web app?

    - by Gatis
    My Web App will be deployed as a WAR package in a Jetty instance. It needs to perform a lot of caching before serving requests. How do I call the caching method before anything else? is the a static void main() in the web app standard?

    Read the article

  • ASP.NET <Body onload="initialize()">

    - by Alyn
    Hi, I am creating an ASP.NET custom control. I want to set the body onload event of the ASPX page where the control resides. Please note I cannot rely on the body tag in the ASPX page having runat="server". any ideas?? Cheers.

    Read the article

  • Initialize static members in PHP

    - by Senthil
    class Person { public static function ShowQualification() { } } class School { public static $Headmaster = new Person(); // NetBeans complains about this line } Why is this not possible? I want to be able to use this like School::Headmaster::ShowQualification(); ..without instantiating any class. How can I do it?

    Read the article

  • Initialize window code Mac OS X

    - by Jarle
    I'm currently reading "the red book" for learning OpenGL properly, and in one of the first examples, the author writes a line that says "InitializeAWindowPlease();" as a place holder for the code that will make a window to draw the OpenGL content in. Since I'm using Xcode for my programing, I know that I "get" a window to work with automatically (and that I have to make my own OpenGL view in interfacebuilder). How can I make this with pure code? I'm trying to learn programming, and I'm not to happy about taking "shortcuts" all the time. How can I make a window to draw my openGL stuff in? With Objective-C and C code I would love to see it. My goal is that I can make it without opening interface builder at all:)

    Read the article

  • In Ruby, how can I initialize instance variables in new objects of core classes created from literal

    - by Ollie Saunders
    class Object attr_reader :foo def initialize @foo = 'bar' end end Object.new.foo # => 'bar' ''.foo # => nil //.foo # => nil [].foo # => nil I want them all to return 'bar' Am aware that you can do this already: class Object def foo 'bar' end end But I specifically want to initialize a state variable. Also note that this doesn't work. class String alias_method :old_init, :initialize def initialize(*args) super old_init(*args) end end class Object attr_reader :foo def initialize @foo = 'bar' super end end ''.foo # => nil Nor does this: class String attr_reader :foo def initialize @foo = 'bar' end end ''.instance_variables # => [] I'm beginning to think that this isn't actually possible.

    Read the article

  • Initialize virtual attributes

    - by Horace Loeb
    I have an IncomingEmail model with an attachments virtual attribute: class IncomingEmail < ActiveRecord::Base attr_accessor :attachments end I want the attachments virtual attribute to be initialized to [] rather than nil so that I can do: >> i = IncomingEmail.new => #<IncomingEmail id: nil,...) >> i.attachments << "whatever" Without first setting i.attachments to [] (put another way, I want this virtual attribute to default to an empty array rather than nil)

    Read the article

  • Compile error with initializer_list when trying to use it to initialize member value of class

    - by ilektron
    I am trying to make a class initializable from an initialization_list in a class constructor's constructor's initialization list. It works for a std::map, but not for my custom class. I don't see any difference other than templates are used in std::map. #include <iostream> #include <initializer_list> #include <string> #include <sstream> #include <map> using std::string; class text_thing { private: string m_text; public: text_thing() { } text_thing(text_thing& other); text_thing(std::initializer_list< std::pair<const string, const string> >& il); text_thing& operator=(std::initializer_list< std::pair<const string, const string> >& il); operator string() { return m_text; } }; class static_base { private: std::map<string, string> m_test_map; text_thing m_thing; static_base(); public: static static_base& getInstance() { static static_base instance; return instance; } string getText() { return (string)m_thing; } }; typedef std::pair<const string, const string> spair; text_thing::text_thing(text_thing& other) { m_text = other.m_text; } text_thing::text_thing(std::initializer_list< std::pair<const string, const string> >& il) { std::stringstream text_gen; for (auto& apair : il) { text_gen << "{" << apair.first << ", " << apair.second << "}" << std::endl; } } text_thing& text_thing::operator=(std::initializer_list< std::pair<const string, const string> >& il) { std::stringstream text_gen; for (auto& apair : il) { text_gen << "{" << apair.first << ", " << apair.second << "}" << std::endl; } return *this; } static_base::static_base() : m_test_map{{"test", "1"}, {"test2", "2"}}, // Compiler fine with this m_thing{{"test", "1"}, {"test2", "2"}} // Compiler doesn't like this { } int main() { std::cout << "Starting the program" << std::endl; std::cout << "The text thing: " << std::endl << static_base::getInstance().getText(); } I get this compiler output g++ -O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -MMD -MP -MF"static_base.d" -MT"static_base.d" -o "static_base.o" "../static_base.cpp" Finished building: ../static_base.cpp Building file: ../test.cpp Invoking: GCC C++ Compiler g++ -O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -MMD -MP -MF"test.d" -MT"test.d" -o "test.o" "../test.cpp" ../test.cpp: In constructor ‘static_base::static_base()’: ../test.cpp:94:40: error: no matching function for call to ‘text_thing::text_thing(<brace-enclosed initializer list>)’ m_thing{{"test", "1"}, {"test2", "2"}} ^ ../test.cpp:94:40: note: candidates are: ../test.cpp:72:1: note: text_thing::text_thing(std::initializer_list<std::pair<const std::basic_string<char>, const std::basic_string<char> > >&) text_thing::text_thing(std::initializer_list< std::pair<const string, const string> >& il) ^ ../test.cpp:72:1: note: candidate expects 1 argument, 2 provided ../test.cpp:67:1: note: text_thing::text_thing(text_thing&) text_thing::text_thing(text_thing& other) ^ ../test.cpp:67:1: note: candidate expects 1 argument, 2 provided ../test.cpp:23:2: note: text_thing::text_thing() text_thing() ^ ../test.cpp:23:2: note: candidate expects 0 arguments, 2 provided make: *** [test.o] Error 1 Output of gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.1-2ubuntu1~13.04' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.8.1 (Ubuntu 4.8.1-2ubuntu1~13.04) It compiles fine with the std::map constructed this way, and if I modify the static_base to return the strings from the maps, all is fine and dandy. Please help me understand what is going on here.

    Read the article

  • Cast/initialize submodels of a Backbone Model

    - by nambrot
    I think I have a pretty simple problem that is just pretty difficult to word and therefore hard to find a solution for. Setup: PathCollection is a Backbone.Collection of Paths Path is a Backbone.Model which contains NodeCollection (which is a Backbone.Collection) and EdgeCollection (which is a Backbone.Collection). When I fetch PathCollection paths = new PathCollection() paths.fetch() obviously, Paths get instantiated. However, I'm missing the spot where I can allow a Path to instantiate its submodels from the attribute hashes. I can't really use parse, right? Basically im looking for the entry point for a model when its instantiated and set with attributes. I feel like there must be some convention for it.

    Read the article

  • How to initialize F# list when size is unknown, using while..do loop

    - by James Black
    I have a function that will parse the results of a DataReader, and I don't know how many items are returned, so I want to use a while..do loop to iterate over the reader, and the outcome should be a list of a certain type. (fun(reader) -> [ while reader.Read() do new CityType(Id=(reader.GetInt32 0), Name=(reader.GetString 1), StateName=(reader.GetString 2)) ]) This is what I tried, but the warning I get is: This expression should have type 'unit', but has type 'CityType'. Use 'ignore' to discard the result of the expression, or 'let' to bind the result to a name. So what is the best way to iterate over a DataReader and create a list?

    Read the article

  • How to initialize an std::string using ""?

    - by Mohsin
    I'm facing problems with initializing a std::string variable using "" (i.e. an empty string). It's causing strange behavior in code that was previously working. Is the following statement wrong? std::string operationalReason = ""; When I use the following code everything works fine: std::string operationalReason; operationalReason.clear(); I believe that string literals are stored in a separate memory location that is compiler-dependent. Could the problem I'm seeing actually be indicating a corruption of that storage? If so, it would get hidden by my usage of the clear() function. Thanks.

    Read the article

  • How do I initialize a fixed byte array?

    - by Jurily
    I have the following struct: [StructLayout(LayoutKind.Sequential, Pack = 1)] struct cAuthLogonChallenge { byte cmd; byte error; fixed byte name[4]; public cAuthLogonChallenge() { cmd = 0x04; error = 0x00; name = ??? } } name is supposed to be a null-terminated ASCII string, and Visual Studio is rejecting all my ideas to interact with it. How do I set it?

    Read the article

  • Initialize child models at model creation

    - by Antoine
    I have a model Entree which belongs to a model Vin, which itself belongs to a model Producteur. On the form for Entree creation/edition, I want to allow the user to define the attributes for parent Vin and Producteur to create them, or retrieve them if they exist (retrieval based on user input). For now I do the following in Entree new and edit actions: @entree = Entree.new @entree.vin = Vin.new @entree.vin.producteur = Producteur.new and use fields_for helper in the form,and that works. But I intend to have much more dependencies with more models, so I want to keep it DRY. I defined a after_initialize callback in Vin model which does the producteur initialization: class Vin < ActiveRecord::Base after_initialize :vin_setup def vin_setup producteur = Producteur.new end end and remove the producteur.new from the controller. However, get an error on new action: undefined method `model_name' for NilClass:Class for the line in the form that says <%= fields_for @entree.vin.producteur do |producteur| %> I guess that means the after_initialize callback doesn't act as I expect it. Is there something I'm missing? Also, I get the same error if I define a after_initialize method in the Vin model instead of definiing a callback.

    Read the article

  • C++ Initialize array in constructor EXC_BAD_ACCESS

    - by user890395
    I'm creating a simple constructor and initializing an array: // Construtor Cinema::Cinema(){ // Initalize reservations for(int i = 0; i < 18; i++){ for(int j = 0; j < 12; j++){ setReservation(i, j, 0); } } // Set default name setMovieName("N/A"); // Set default price setPrice(8); } The setReservation function: void Cinema::setReservation(int row, int column, int reservation){ this->reservations[row][column] = reservation; } The setMovieName function: void Cinema::setMovieName(std::string movieName){ this->movieName = movieName; } For some odd reason when I run the program, the setMovieName function gives the following error: "Program Received Signal: EXC_BAD_ACCESS" If I take out the for-loop that initializes the array of reservations, the problem goes away and the movie name is set without any problems. Any idea what I'm doing wrong? This is the Cinema.h file: #ifndef Cinema_h #define Cinema_h class Cinema{ private: int reservations[17][11]; std::string movieName; float price; public: // Construtor Cinema(); // getters/setters int getReservation(int row, int column); int getNumReservations(); std::string getMovieName(); float getPrice(); void setReservation(int row, int column, int reservation); void setMovieName(std::string movieName); void setPrice(float price); }; #endif

    Read the article

  • Using Remote Web Server to Initialize iPhone App

    - by Chris_K
    My iPhone app relies on a vendor's XML feed to provide data. But that feed is not locked down. The vendor could change the format of the XML at any time, although so far they've promised not to. Since I might want to tell my app to use a different URL for its data source, I'd like to set up a single "Command Central" Web page, on my own server, to direct the app to the correct data source. In other words, each time my app starts, in the background and unseen by the user, it would visit "http://www.myserver.com/iphoneapp_data_sources.xml" to retrieve the URL for retrieving data from my vendor. That way, if my vendor suddenly changes the exact URL or the XML feed that the app needs, I can update that Web page and ensure that all installations of the app are using the correct XML feed. Does anyone have any advice or examples showing this kind of approach? It seems as if this must be a common problem, but so far I haven't found a well-established design pattern that fits it.

    Read the article

  • Initialize generic object from a System.Type

    - by CaptnCraig
    I need to create a generic type, but I do not know the type at compile time. I would like to do this: Type t = typeof(whatever); var list = new List<t> this won't compile, because t is not a valid type. But it does know all about a valid type. Is there a way to dynamically create the generic list from a System.Type like this? I may need reflection, and that's ok, I am just a bit lost here.

    Read the article

  • Using Remote Web Page to Initialize iPhone App

    - by Chris_K
    My iPhone app relies on a vendor's XML feed to provide data. But that feed is not locked down. The vendor could change the format of the XML at any time, although so far they've promised not to. Since I might want to tell my app to use a different URL for its data source, I'd like to set up a single "Command Central" Web page, on my own server, to direct the app to the correct data source. In other words, each time my app starts, in the background and unseen by the user, it would visit "http://www.myserver.com/iphoneapp_data_sources.xml" to retrieve the URL for retrieving data from my vendor. That way, if my vendor suddenly changes the exact URL or the XML feed that the app needs, I can update that Web page and ensure that all installations of the app are using the correct XML feed. Does anyone have any advice or examples showing this kind of approach? It seems as if this must be a common problem, but so far I haven't found a well-established design pattern that fits it.

    Read the article

  • Java: how to initialize String[]?

    - by Heoa
    Error % javac StringTest.java StringTest.java:4: variable errorSoon might not have been initialized errorSoon[0] = "Error, why?"; Code public class StringTest { public static void main(String[] args) { String[] errorSoon; errorSoon[0] = "Error, why?"; } }

    Read the article

  • How should I initialize jQuery?

    - by Reigel
    I have seen this (I'm also using it): $(document).ready(function(){ // do jQuery }) and also this (I have tried lately): (function(){ // do jQuery })(jQuery) both works fine. My question is what is the difference of the two ( except on how it looks ). Which one is more proper to use?. Can you give me some pro's and con's for each? Is there also another way of doing this? (also help me with the title above. SO suggested, "The question you're asking appears subjective and is likely to be closed.") Thanks everyone.

    Read the article

  • More elegant way to initialize list of duplicated items in Python

    - by Claudiu
    If I want a list initialized to 5 zeroes, that's very nice and easy: [0] * 5 However if I change my code to put a more complicated data structure, like a list of zeroes: [[0]] * 5 will not work as intended, since it'll be 10 copies of the same list. I have to do: [[0] for i in xrange(5)] that feels bulky and uses a variable so sometimes I even do: [[0] for _ in " "] But then if i want a list of lists of zeros it gets uglier: [[[0] for _ in " "] for _ in " "] all this instead of what I want to do: [[[0]]*5]*5 Has anyone found an elegant way to deal with this "problem"?

    Read the article

  • Where to initialize a NSMutableArray?

    - by eco_bach
    Hi having an issue using a NSMutableArray; In my implementation file applicationDidFinishLaunching method I have _imgArray = [NSMutableArray array]; and _imgArray is defined in my .h file as NSMutableArray *_imgArray; After populating it, it traces out correctly. The problem is, in another method in my implementation file, I can't seem to acces the _imgArray array. It traces out to _imgArray= ar.lproj What gives?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >