Search Results

Search found 13838 results on 554 pages for 'disconnected model'.

Page 81/554 | < Previous Page | 77 78 79 80 81 82 83 84 85 86 87 88  | Next Page >

  • Problem with date_select when using :discard option. (Rails)

    - by MikeH
    I'm using a date_select with the option :discard_year => true If a user selects a date in the date select, and then he comes back and returns the select to the prompt values of Month and Day, Rails automatically sets the select values to January 1. I know this is the intended functionality if a month is selected and a day is left blank, but that's not the case here. In my example, the user sets both the month and day back to the prompt. By Rails forcing January 1, I'm getting bad results. I've tried every parameter available in the api. :default = nil, :include_blank = true. None of those change the behavior I'm describing. I've isolated the root of the problem, which is this: Because I'm discarding the :year parameter, when the user tries to return the month and day to the prompt values, Rails doesn't see an empty prompt select. It perhaps sees a year selected with empty month and day, which it then sets to January 1. This is the case because the :discard_year parameter does in fact set a date in the database, it just removes it from the view. How can I code around this problem?

    Read the article

  • In Prism (CAL), how can I RegisterPresenterWithRegion instead of RegisterViewWithRegion

    - by Edward Tanguay
    I have a module in a Prism application and in its initialize method I want to register a presenter instead of a view with a region, i.e. I want to do this: PSEUDO-CODE: regionManager.RegisterPresenterWithRegion( "MainRegion", typeof(Presenters.EditCustomerPresenter)); instead of loading a view like this: regionManager.RegisterViewWithRegion( "MainRegion", typeof(Views.EditCustomerView)); The presenter would of course bring along its own view and ultimately register this view in the region, but it would allow me to bind the presenter to the view in the presenter's constructor instead of binding the two together in XAML (which is more of a decoupled MVVM pattern which I want to avoid here). How can I add a Presenter to a Region instead of a view? namespace Client.Modules.CustomerModule { [Module(ModuleName = "CustomerModule")] public class CustomerModule : IModule { private readonly IRegionManager regionManager; public CustomerModule(IRegionManager regionManager) { this.regionManager = regionManager; } public void Initialize() { regionManager.RegisterViewWithRegion("MainRegion", typeof(Views.EditCustomerView)); } } }

    Read the article

  • How set opacity on QGraphicsItem

    - by La Chamelle
    Hello, i have a inherited from QGraphicsScene and QGraphicsItem to create my own classes. I use Qt 4.6. I want to set a specific opacity on each items of my scene. I use setOpacity : setOpacity method, but its not the result i hope. I want to have for example one item opaque and an other transparent (to see the desktop, or the other application). But if i dont set the opacity of the QGraphicsView to 0.5, i have not the transparancy. And if the QGraphicsView is set to 0.5, the item is not real opaque. What should i do ? Thanks you.

    Read the article

  • Rails :dependent => :destroy VS :dependent => :delete_all

    - by Sergey
    In rails guides it's described like this: "Objects will be in addition destroyed if they’re associated with :dependent = :destroy, and deleted if they’re associated with :dependent = :delete_all." Right, cool. But what's the difference between being destroyed and being deleted? I tried both and it seems to do the same thing.

    Read the article

  • Storing n-grams in database in < n number of tables.

    - by kurige
    If I was writing a piece of software that attempted to predict what word a user was going to type next using the two previous words the user had typed, I would create two tables. Like so: == 1-gram table == Token | NextWord | Frequency ------+----------+----------- "I" | "like" | 15 "I" | "hate" | 20 == 2-gram table == Token | NextWord | Frequency ---------+------------+----------- "I like" | "apples" | 8 "I like" | "tomatoes" | 12 "I hate" | "tomatoes" | 20 "I hate" | "apples" | 2 Following this example implimentation the user types "I" and the software, using the above database, predicts that the next word the user is going to type is "hate". If the user does type "hate" then the software will then predict that the next word the user is going to type is "tomatoes". However, this implimentation would require a table for each additional n-gram that I choose to take into account. If I decided that I wanted to take the 5 or 6 preceding words into account when predicting the next word, then I would need 5-6 tables, and an exponentially increase in space per n-gram. What would be the best way to represent this in only one or two tables, that has no upper-limit on the number of n-grams I can support?

    Read the article

  • MVP - asp.net - passing information via views - confused

    - by ekynox
    Hi, I've just started to play around with MVP in asp.net. One thing I quite cant figure out is how do I pass information, i.e. an integer variable from one view(webform) to another. Let's I have a customerlistView which is mapped to a customerlist.aspx page. From it I select a customer and it's record id. Say I want to display the customer's details in another view (i.e customerDetailView, customerdetail.aspx). How do I achieve that ? Does that mean customerlistView would call the presenter of the customerdetail and cause a page redirect ? Any ideas ? thanks

    Read the article

  • Using a "vo" for joined data?

    - by keithjgrant
    I'm building a small financial system. Because of double-entry accounting, transactions always come in batches of two or more, so I've got a batch table and a transaction table. (The transaction table has batch_id, account_id, and amount fields, and shared data like date and description are relegated to the batch table). I've been using basic vo-type models for each table so far. Because of this table structure structure, though, transactions will almost always be selected with a join on the batch table. So should I take the selected records and splice them into two separate vo objects, or should I create a "shared" vo that contains both batch and transaction data? There are a few cases in which batch records and/or transaction records. Are there possible pitfalls down the road if I have "overlapping" vo classes?

    Read the article

  • Display values inside a JList -

    - by sharon Hwk
    I have a method that returns a HashMap, and is defined as follows; public HashMap<Integer, Animal> allAnimal(){ return returnsAHashMap; } Animal will have the following values in its class: public Animal{ int animalID; String animalName; // i have declared getters/setters } I have a GUI screen which has a JList and it's defined as: l = new JList(); l.setModel(new AbstractListModel() { String[] v = new String[] {"animal id 1", "2", "3"}; public int getSize() { return v.length; } public Object getElementAt(int index) { return v[index]; } }); What I want to do is to display the AnimalID's in the JList. I need to find a way to call the allAnimal() method and display all its Animal Id's in the JList. How can i do this ?

    Read the article

  • How do I add a one-to-one relationship in MYSQL?

    - by alex
    +-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | pid | varchar(99) | YES | | NULL | | +-------+-------------+------+-----+---------+-------+ 1 row in set (0.00 sec) +-------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+---------------+------+-----+---------+-------+ | pid | varchar(2000) | YES | | NULL | | | recid | varchar(2000) | YES | | NULL | | +-------+---------------+------+-----+---------+-------+ 2 rows in set (0.00 sec) This is my table. pid is just the id of the user. "recid" is a recommended song for that user. I hope to have a list of pid's, and then recommended songs for each person. Of course, in my 2nd table, (pid, recid) would be unique key. How do I do a one-to-one query for this ?

    Read the article

  • MVC using ODP.NET getting ORA-01840

    - by sse
    I am writing a simple MVC Application using ODP.NET. I am trying to call a Pl/Sql proc that inserts a record. Here is the simple Pl/Sql: procedure spAddCountry(pGisRecid in country.GISRECID%type, pCountryCode in country.COUNTRYCODE%type, pCountryName in country.COUNTRYNAME%type, pCurrencyCode in country.CURRENCYCODE%type, pEUTerritory in country.EUTERRITORY%type, pFatCAStatus in country.FATCASTATUS%type, pFATF in country.FATF%type, pFSCountryCode in country.COUNTRYCODE%type, pInsertedBy in country.INSERTEDBY%type, pInsertedOn in country.INSERTEDON%type, pLanguages in country.LANGUAGES%type, pNCCT in country.NCCT%type) is PRAGMA AUTONOMOUS_TRANSACTION; begin INSERT INTO COUNTRY (GISRECID, COUNTRYCODE, COUNTRYNAME, CURRENCYCODE, EUTERRITORY, FATCASTATUS, FATF, FSCOUNTRYCODE, INSERTEDBY, INSERTEDON, LANGUAGES, NCCT) VALUES(pGISRECID, pCOUNTRYCODE, pCOUNTRYNAME, pCURRENCYCODE, pEUTERRITORY, pFATCASTATUS, pFATF, pFSCOUNTRYCODE, pINSERTEDBY, pINSERTEDON, pLANGUAGES, pNCCT); Commit; end; I am having difficulty passing the date parameter, pInsertedOn, to the Stored Proc. I have verified that the web form retrieves the form data successfully and calls the AddCountry method below, which in turns calls the stored proc, spAddCountry, after populating all of the parms. Here is a snippet of the MVC C# code. I get the following exception: "ORA-01840 input value not long enough for date format". public void AddCountry(Country aCountry) //because the country object field names match the form field names they automatically get bound!! { string oradb = "Data Source=XYZ;User Id=XYZ;Password=xyz;"; OracleConnection conn = new OracleConnection(oradb); OracleCommand cmd = conn.CreateCommand(); cmd.CommandText = "tstpack.spAddCountry"; cmd.CommandType = CommandType.StoredProcedure; ... OracleParameter paramInsertedBy = new OracleParameter(); paramInsertedBy.ParameterName = "pInsertedBy"; paramInsertedBy.Value = aCountry.InsertedBy; cmd.Parameters.Add(paramInsertedBy); // CultureInfo ci = new CultureInfo("en-US"); OracleParameter paramInsertedOn = new OracleParameter(); paramInsertedOn.ParameterName = "pInsertedOn"; // paramInsertedOn.Value = DateTime.Now; //just testing to see if it's WebForm issue // paramInsertedOn.Value = Convert.ToDateTime(DateTime.Now.ToString(), ci); //flail! paramInsertedOn.Value = aCountry.InsertedOn; cmd.Parameters.Add(paramInsertedOn); ... conn.Open(); cmd.ExecuteNonQuery(); //CRASH! ORA-01840 conn.Close(); } Just to verify that the flow of the program is working, I tried removing the date parm "pInsertedOn" from the pl/sql and from the parm list above, and everything worked fine. I know I am going off of the rails with the date. Can someone tell me how to pass a date to Oracle from an MVC WebForm? Is there some sort of type cast needed? I would really appreciate an example too. Thanks so much! ps, I did try changing the parm type to Varchar2 in the Pl/Sql and doing some conversions myself in the Pl/Sql, the automatic MVC binder was getting in my way, forcing the property of paramInsertedOn.OracleType to DateTime. I tried forcing it to Varchar2, but no luck there either...

    Read the article

  • Properly populating tables in an Object Relational database

    - by chaosTechnician
    I've got a homework assignment that requires that I use Oracle 10g Express to implement an Object Relational database to track phone billing data. I have a superclass of Communications with subclasses of Call, Text, and Data. I'm hitting a snag with properly populating these tables so that I can find the appropriate data in the various tables. My Types and Tables are declared as such: create type CommunicationType as object ( -- column names here ) not final; create type CallType under CommunicationType ( -- column names here ); create type TextType under CommunicationType ( -- column names here ); create type DataType under CommunicationType ( -- column names here ); create table Communications of CommunicationType ( -- Primary and Foreign key constraints here ); create table Calls of CallType; create table Texts of TextType; create table Datas of DataType; When I try to insert data into one of the subclasses, its entry doesn't appear in the superclass. Likewise if I insert into the superclass, it doesn't show up in the appropriate subclass. For example, insert into Calls values (CallType( -- Values -- )); doesn't show any data in Communications. Nor does insert into Communications values (CallType( -- Values -- )); show anything in Calls. What am I doing wrong?

    Read the article

  • PHP search multidimensional array for value, then place that element at start of array

    - by BobFlemming
    I need to search this array: cars - [0] -make : Ford -model: Escort -year: 1991 [1] -make: Honda -model: Civic -year: 1996 [2] -make: Vauxhall -model: Astra -year: 1972 And if (for example) the model is "Civic" , place that 'car' at position 0. So the end array would be like: cars - [0] -make: Honda -model: Civic -year: 1996 [1] -make : Ford -model: Escort -year: 1991 [2] -make: Vauxhall -model: Astra -year: 1972 I've tried some usort variations: function typeSort($a, $b) { if ($a['model'] == 'Civic' ) { return 0; } return ($a['model'] < $b['model']) ? -1 : 1; } but this is just returning 1

    Read the article

  • CSS filter for IE6 standard mode and quirk mode?

    - by jackysee
    Is there any CSS filter can be applied to detect IE6's standard mode and quirk mode? The story is that a jQuery script is using $.support.boxModel to handle different rendering mode. But the CSS use the *width hack to define the dimension. But this hack can only filter whether the browser is IE but not the real rendering mode IE is on.

    Read the article

  • Implicit Memory Barriers

    - by foo
    let's say i have variables A, B and C that two threads (T1, T2) share. i have the following code: //T1 //~~ A = 1; B = 1; C = 1; InterlockedExchange(ref Foo, 1); //T2 (executes AFTER T1 calls InterlockedExchange) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ InterlockedExchange(ref Bar, 1); WriteLine(A); WriteLine(B); WriteLine(C); Question: does calling InterlockedExchange (implicit full fence) on T1 and T2, gurentess that T2 will "See" the write done by T1 before the fence? (A, B and C variables), even though those variables are not plance on the same cache-line as Foo and Bar?

    Read the article

  • Writing a custom auth system (like the default django auth system), use it to generate tables in DB

    - by dotty
    Hay all, I've been reading up on middleware and how to use it with a context object. I want to write a simple middleware class which i can use on my own applications, it will essentially be a cut down version of the django one. The problem i seem to have is that if i have INSTALLED_APPS = ('django.contrib.my_auth') in the settings file, all is well. I've also added MIDDLEWARE_CLASSES = ('django.contrib.my_auth.middleware.MyAuthMiddleware') in it and everything is fine. My question is, how would i make my middleware automatically generate tables from a models.py module, much like how the django auth does when i run manage.py syncdb? thanks

    Read the article

  • How to return a property name when comparing two properties at class-level

    - by CodeMonkey
    Hi I have implemented an 'EqualTo' Validation Attribute, that compares two Properties of an object, during ModelBinding in ASP.NET MVC 2. The problem I have is not with it not working, because it does work. The problem is, when I do my request - which is an ajax request - I get back errors to my front-end, where it sets a class on the input fields to indicate invalid input. What it does is iterate through a list of Errors (in a JsonResult), and set a class. This is all dandy. But the ValidationAtrribute I am having trouble with is set at a Class-level, i.e., it's not like other ValidationAttributes where you set something like "[Required]" or something like that. [AttributeUsage(AttributeTargets.Class, AllowMultiple=true, Inherited=false)] public class EqualToAttribute : ValidationAttribute { public String SourceProperty { get; set; } public String MatchProperty { get; set; } public EqualToAttribute(string source, string match) { SourceProperty = source; MatchProperty = match; } public override Boolean IsValid(Object value) { Type objectType = value.GetType(); PropertyInfo[] properties = objectType.GetProperties(); object sourceValue = new object(); object matchValue = new object(); Type sourceType = null; Type matchType = null; int counter = 0; foreach (PropertyInfo propertyInfo in properties) { if (propertyInfo.Name == SourceProperty || propertyInfo.Name == MatchProperty) { if (counter == 0) { sourceValue = propertyInfo.GetValue(value, null); sourceType = propertyInfo.GetValue(value, null).GetType(); } if (counter == 1) { matchValue = propertyInfo.GetValue(value, null); matchType = propertyInfo.GetValue(value, null).GetType(); } counter++; if (counter == 2) { break; } } } if (sourceType != null && matchType != null) { return sourceValue.ToString().Equals(matchValue.ToString()); //return Convert.ChangeType(sourceValue, sourceType) == Convert.ChangeType(matchValue, matchType); } return false; } private object _typeId = new object(); public override object TypeId { get { return this._typeId; } } } Now this code works, except for the fact that the validation process does not return which Property failed. And I simply can't figure out how to make it return one of the two. In reality I don't care which one it returns.. because both are failing.. Do you have an idea how to make it return the/or both Property/Properties that is/are failing.

    Read the article

  • Having trouble understanding some code (Ruby on Rails)

    - by user284194
    I posted a question awhile ago asking how I could limit the rate at which a form could be submitted from a rails application. I was helped by a very patient user and their solution works great. The code was for my comments controller, and now I find myself wanting to add this functionality to another controller, my Messages controller. I immediately tried reusing the working code from the comments controller but I couldn't get it to work. Instead of asking for the working code, could someone please help me understand my working comment controller code? class CommentsController < ApplicationController #... before_filter :post_check def record_post_time cookies[:last_post_at] = Time.now.to_i end def last_post_time Time.at((cookies[:last_post_at].to_i rescue 0)) end MIN_POST_TIME = 2.minutes def post_check return true if (Time.now - last_post_time) > MIN_POST_TIME flash[:warning] = "You are trying to reply too fast." @message = Message.find(params[:message_id]) redirect_to(@message) return false end #... def create @message = Message.find(params[:message_id]) @comment = @message.comments.build(params[:comment]) if @comment.save record_post_time flash[:notice] = "Replied to \"#{@message.title}\"" redirect_to(@message) else render :action => "new" end end def update @message = Message.find(params[:message_id]) @comment = Comment.find(params[:id]) if @comment.update_attributes(params[:comment]) record_post_time redirect_to post_comment_url(@message, @comment) else render :action => "edit" end end #... end My Messages controller is pretty much a standard rails generated controller with a few before filters and associated private methods for DRYing up the code and a redirect for non existent pages. I'll explain how much of the code I understand. When a comment is created, a cookie is created with a last_post_time value. If they try to post another comment, the cookie is checked if the last one was made in the last two minutes. If it was a flash warning is displayed and no comment is recorded. What I don't really understand is how the post_check method works and how I can adapt it for my simpler posts controller. I thought I could reuse all the code in the message controller with the exception of the line: @message = Message.find(params[:message_id]) # (don't need the redirect code) in the post_check method. But it trips up on the "record_post_time" in the create action/method. I really want to understand this. Can someone explain why this doesn't work? I greatly appreciate you reading my lengthy question.

    Read the article

  • Rails 3 find all associated records has_many :through

    - by Sergey
    I would like to list all posts that are connected with some specific category. I have: class Post < ActiveRecord::Base has_many :category_posts has_many :categories, :through => :category_posts end class Category < ActiveRecord::Base has_many :category_posts has_many :posts, :through => :category_posts end class CategoryPost < ActiveRecord::Base belongs_to :category belongs_to :post end And I wanna do something like this Post.where(["category.id = ?", params[:category_id]]) It indeed is very simple task, but I don't know what I should be looking for (keywords). It's the same problem like this, but in rails.

    Read the article

< Previous Page | 77 78 79 80 81 82 83 84 85 86 87 88  | Next Page >