Search Results

Search found 13429 results on 538 pages for 'model reject'.

Page 93/538 | < Previous Page | 89 90 91 92 93 94 95 96 97 98 99 100  | Next Page >

  • Why does the ASP.Net Web Forms model "suck"?

    - by Daniel Magliola
    I've heard Jeff Atwood, Joel Spolsky, and many other legendary people talk about how the ASP.Net Web Forms model sucks. (So this question is kind of directed to them, hopefully Jeff is reading) Now, I highly respect their opinion, given their background and expertise, but truth be told, I absolutely LOVE ASP.Net. I think the model is brilliant, and it sucks if you have no idea what you're doing, but once you understand how to control ViewState, when to use handlers instead of pages, etc, it is generations ahead of all the other models. So every time I hear someone complain about how it sucks, I can't help ask the same question... Why? What is it that's so bad about it? I appreciate all opinions. I'm assuming there's probably a post at Jeff's blog talking about this too...

    Read the article

  • M-V-VM, isn't the Model leaking into the View?

    - by BFree
    The point of M-V-VM as we all know is about speraration of concerns. In patterns like MVVM, MVC or MVP, the main purpose is to decouple the View from the Data thereby building more flexible components. I'll demonstrate first a very common scenario found in many WPF apps, and then I'll make my point: Say we have some StockQuote application that streams a bunch of quotes and displays them on screen. Typically, you'd have this: StockQuote.cs : (Model) public class StockQuote { public string Symbol { get; set; } public double Price { get; set; } } StockQuoteViewModel.cs : (ViewModel) public class StockQuoteViewModel { private ObservableCollection<StockQuote> _quotes = new ObservableCollection<StockQuote>(); public ObservableCollection<StockQuote> Quotes { get { return _quotes; } } } StockQuoteView.xaml (View) <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfApplication1" Title="Window1" Height="300" Width="300"> <Window.DataContext> <local:StockQuoteViewModel/> </Window.DataContext> <Window.Resources> <DataTemplate x:Key="listBoxDateTemplate"> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Symbol}"/> <TextBlock Text="{Binding Price}"/> </StackPanel> </DataTemplate> </Window.Resources> <Grid> <ListBox ItemTemplate="{StaticResource listBoxDateTemplate}" ItemsSource="{Binding Quotes}"/> </Grid> </Window> And then you'd have some kind of service that would feed the ObservableCollection with new StockQuotes. My question is this: In this type of scenario, the StockQuote is considered the Model, and we're exposing that to the View through the ViewModel's ObservableCollection. Which basically means, our View has knowledge of the Model. Doesn't that violate the whole paradigm of M-V-VM? Or am I missing something here....?

    Read the article

  • How do I do this Database Model in Django?

    - by alex
    Django currently does not support the "Point" datatype in MySQL. That's why I created my own. class PointField(models.Field): def db_type(self): return 'Point' class Tag(models.Model): user = models.ForeignKey(User) utm = PointField() As you can see, this works, and syncdb creates the model fine. However, my current code calculates a length between two Points using raw SQL. cursor.execute("SELECT user_id FROM life_tag WHERE\ (GLength(LineStringFromWKB(LineString(asbinary(utm), asbinary(PointFromWKB(point(%s, %s)))))) < 55)... This says: Select where the length between the given point and the table point is less than 55. How can I do this with Django instead of RAW SQL? I don't want to do cursors and SELECT statements anymore. How can I modify the models.py in order to do this?

    Read the article

  • How do I memoize expensive calculations on Django model objects?

    - by David Eyk
    I have several TextField columns on my UserProfile object which contain JSON objects. I've also defined a setter/getter property for each column which encapsulates the logic for serializing and deserializing the JSON into python datastructures. The nature of this data ensures that it will be accessed many times by view and template logic within a single Request. To save on deserialization costs, I would like to memoize the python datastructures on read, invalidating on direct write to the property or save signal from the model object. Where/How do I store the memo? I'm nervous about using instance variables, as I don't understand the magic behind how any particular UserProfile is instantiated by a query. Is __init__ safe to use, or do I need to check the existence of the memo attribute via hasattr() at each read? Here's an example of my current implementation: class UserProfile(Model): text_json = models.TextField(default=text_defaults) @property def text(self): if not hasattr(self, "text_memo"): self.text_memo = None self.text_memo = self.text_memo or simplejson.loads(self.text_json) return self.text_memo @text.setter def text(self, value=None): self.text_memo = None self.text_json = simplejson.dumps(value)

    Read the article

  • ActiveRecord model with datetime stamp with timezone support attribute.

    - by jtarchie
    Rails is great that it will support timezone overall in the application with Time.zone. I need to be able to support the timezone a user selects for a record. The user will be able to select date, time, and timezone for the record and I would like all calculations to be done with respect to the user selected timezone. My question is what is the best practice to handle user selected timezones. The model is using a time_zone_select and datetime_select for two different attributes timezone and scheduled_at. When the model saves, the scheduled_at attribute gets converted to the locally defined Time.zone. When a user goes back to edit the scheduled_at attribute with the datetime_select the datetime is set to the converted Time.zone timezone and not the timezone attribute. Is there a nice way to handle to the conversion to the user selected timezone?

    Read the article

  • Why does mysqldump need to be fully pathed when called from a controller or model?

    - by Kris
    When I call mysqldump from a controller or model I need to fully path the binary, when I call it from Rake I don't need to. If I do not fully path I get a zero byte file... I can confirm both processes are run using the same user. # Works in a controller, model and Rake task system "/usr/local/mysql/bin/mysqldump -u root #{w.database_name} > #{target_file}" # Only works in a Rake task system "mysqldump -u root #{w.database_name} > #{target_file}" If I call the Rake task from the action it also fails (zero byte file). OS: Mac Ruby 1.8.6 EDIT: I use Etc.getpwuid(Process.uid).name to get the User of the current process

    Read the article

  • How can I model the data in a multi-language data editor in WPF with MVVM?

    - by Patrick Szalapski
    Are there any good practices to follow when designing a model/ViewModel to represent data in an app that will view/edit that data in multiple languages? Our top-level class--let's call it Course--contains several collection properties, say Books and TopicsCovered, which each might have a collection property among its data. For example, the data needs to represent course1.Books.First().Title in different languages, and course1.TopicsCovered.First().Name in different languages. We want a app that can edit any of the data for one given course in any of the available languages--as well as edit non-language-specific data, perhaps the Author of a Book (i.e. course1.Books.First().Author). We are having trouble figuring out how best to set up the model to enable binding in the XAML view. For example, do we replace (in the single-language model) each String with a collection of LanguageSpecificString instances? So to get the author in the current language: course1.Books.First().Author.Where(Function(a) a.Language = CurrentLanguage).SingleOrDefault If we do that, we cannot easily bind to any value in one given language, only to the collection of language values such as in an ItemsControl. <TextBox Text={Binding Author.???} /> <!-- no way to bind to the current language author --> Do we replace the top-level Course class with a collection of language-specific Courses? So to get the author in the current language: course1.GetLanguage(CurrentLanguage).Books.First.Author If we do that, we can only easily work with one language at a time; we might want a view to show one language and let the user edit the other. <TextBox Text={Binding Author} /> <!-- good --> <TextBlock Text={Binding ??? } /> <!-- no way to bind to the other language author --> Also, that has the disadvantage of not representing language-neutral data as such; every property (such as Author) would seem to be in multiple languages. Even non-string properties would be in multiple languages. Is there an option in between those two? Is there another way that we aren't thinking of? I realize this is somewhat vague, but it would seem to be a somewhat common problem to design for. Note: This is not a question about providing a multilingual UI, but rather about actually editing multi-language data in a flexible way.

    Read the article

  • Cache inferno - how can Model.A be two different things at the same time?

    - by Martin
    I have this <%=Model.StartDate%> <%=Html.Hidden("StartDate", Model.StartDate)%> it outputs: 2010-05-11 11:00:00 +01:00 <input type="hidden" value="2010-03-17 11:00:00 +01:00" name="StartDate" id="StartDate"> What the... It's a paging mechanism so the hidden value was valid on the first page and I've been able to move forward to the next page. But since the values won't update properly it ends there. What do I need to do. Using firefox.

    Read the article

  • CakePHP: How do I order results based on a 2-level deep association model?

    - by KcYxA
    I'm hoping I won't need to resort to custom queries. A related question would be: how do I retrieve data so that if an associated model is empty, no record is retrieved at all, as opposed to an empty array for an associated model? As an oversimplified example, say I have the following models: City -- Street -- House How do I sort City results by House numbers? How do I retrieve City restuls that have at least one House in it? I don't want a record with a city name and details and an empty House array as it messes up pagination results. CakePHP retrieves House records belonging to the Street in a separate query, so putting somthing like 'House.number DESC' into the 'order' field of the search query returns a 'field does not exist' error. Any ideas?

    Read the article

  • How to preprocess a Django model field value before return?

    - by Satoru.Logic
    Hi, all. I have a Note model class like this: class Note(models.Model): author = models.ForeignKey(User, related_name='notes') content = NoteContentField(max_length=256) NoteContentField is a custom sub-class of CharField that override the to_python method in purpose of doing some twitter-text-conversion processing. class NoteContentField(models.CharField): __metaclass__ = models.SubfieldBase def to_python(self, value): value = super(NoteContentField, self).to_python(value) from ..utils import linkify return mark_safe(linkify(value)) However, this doesn't work. When I save a Note object like this: note = Note(author=request.use, content=form.cleaned_data['content']) The conversed value is saved into the database, which is not what I wanna see. Would you please tell me what's wrong with this? Thanks in advance.

    Read the article

  • How to activate a solution in SharePoint 2010 using client object model?

    - by Boris
    Here's the situation: I have a customized SharePoint2010 site created. I saved that site as a site template, which has created a solution. I want to be able to activate that solution using SharePoint2010 client object model. Is that possible? If yes, could you show me how to do it? If no, then could you show me how it can be done using standard SharePoint object model, or any other method? Thank you for all the help.

    Read the article

  • Is it possible to create a domain model for legacy code without refactoring?

    - by plaureano
    I currently have a client that wants me to 'abstract' out a domain model from the existing code but they specifically said that I shouldn't refactor the existing code itself. My question is 1) whether or not this is advisable and 2) what techniques would you apply in this scenario if you can't refactor the code yet they expect you to come up with a model for it? (EDIT: I can't quite put my finger on it, but somehow, not being able to refactor in this case just feels wrong. Has anyone else run into this type of scenario?)

    Read the article

  • Inline HTML Syntax for Helpers in ASP.NET MVC

    - by kouPhax
    I have a class that extends the HtmlHelper in MVC and allows me to use the builder pattern to construct special output e.g. <%= Html.FieldBuilder<MyModel>(builder => { builder.Field(model => model.PropertyOne); builder.Field(model => model.PropertyTwo); builder.Field(model => model.PropertyThree); }) %> Which outputs some application specific HTML, lets just say, <ul> <li>PropertyOne: 12</li> <li>PropertyTwo: Test</li> <li>PropertyThree: true</li> </ul> What I would like to do, however, is add a new builder methid for defining some inline HTML without having to store is as a string. E.g. I'd like to do this. <% Html.FieldBuilder<MyModel>(builder => { builder.Field(model => model.PropertyOne); builder.Field(model => model.PropertyTwo); builder.ActionField(model => %> Generated: <%=DateTime.Now.ToShortDate()%> (<a href="#">Refresh</a>) <%); }).Render(); %> and generate this <ul> <li>PropertyOne: 12</li> <li>PropertyTwo: Test</li> <li>Generated: 29/12/2008 <a href="#">Refresh</a></li> </ul> Essentially an ActionExpression that accepts a block of HTML. However to do this it seems I need to execute the expression but point the execution of the block to my own StringWriter and I am not sure how to do this. Can anyone advise?

    Read the article

  • Should I use the Model-View-ViewModel (MVVM) pattern in Silverlight projects?

    - by Jon Galloway
    One challenge with Silverlight controls is that when properties are bound to code, they're no longer really editable in Blend. For example, if you've got a ListView that's populated from a data feed, there are no elements visible when you edit the control in Blend. I've heard that the MVVM pattern, originated by the WPF development community, can also help with keeping Silverlight controls "blendable". I'm still wrapping my head around it, but here are some explanations: http://www.nikhilk.net/Silverlight-ViewModel-Pattern.aspx http://mark-dot-net.blogspot.com/2008/11/model-view-view-model-mvvm-in.html http://www.ryankeeter.com/silverlight/silverlight-mvvm-pt-1-hello-world-style/ http://jonas.follesoe.no/YouCardRevisitedImplementingTheViewModelPattern.aspx One potential downside is that the pattern requires additional classes, although not necessarily more code (as shown by the second link above). Thoughts?

    Read the article

  • Any tips of how to handle hierarchical trees in relational model?

    - by George
    Hello all. I have a tree structure that can be n-levels deep, without restriction. That means that each node can have another n nodes. What is the best way to retrieve a tree like that without issuing thousands of queries to the database? I looked at a few other models, like flat table model, Preorder Tree Traversal Algorithm, and so. Do you guys have any tips or suggestions of how to implement a efficient tree model? My objective in the real end is to have one or two queries that would spit the whole tree for me. With enough processing i can display the tree in dot net, but that would be in client machine, so, not much of a big deal. Thanks for the attention

    Read the article

  • CakePHP. How can i make a model test in a table with another primary key?

    - by Marcelo
    I have this table CREATE TABLE myexamples.problems ( id INT, name VARCHAR(45) NULL , pk_id INT AUTO_INCREMENT PRIMARY KEY ); But when I try test a model in cakephp, it fails because the table has two autoincrement attributes. The following query CREATE TABLE `test_suite_problems` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) DEFAULT NULL, `pk_id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`pk_id`) ) DEFAULT CHARSET=latin1, COLLATE=latin1_swedish_ci, ENGINE=InnoDB; raise this error: "1075: Incorrect table definition; there can be only one auto column and it must be defined as a key" I have in the model class <?php class Problem extends AppModel { var $name = 'Problem'; var $displayField = 'name'; var $primaryKey='problems'; } ?> But I don't know how to make the field ID not having an autoincrement attribute, and I can't change the table structure.

    Read the article

  • How to model my database when using entity framework 4?

    - by Junior Ewing
    Trying to wrap my head around the best approach in modelling a database when we are using Entity Framework 4 as the ORM layer. We are going to use asp.net mvc 2 for the application. Is it worth trying to model using the class diagram modeller that comes with Visual Studio 2010 where you graphically configure your models into the EDMX file and then generate out the database structure? I have run into a bunch of non trivial issues and for complex many to many mappings or multi primary key entities the answer is not that obvious even after poking around a while with the tools. I figure its easy at this point to give up and start modelling the DB using real, working DB modelling tools and then try to generate out the EDMX from the database, rather than trying to do the model first approach.

    Read the article

  • Rails link from one model to another based on db field?

    - by Danny McClelland
    Hi Everyone, I have a company model and a person model with the following relationships: class Company < ActiveRecord::Base has_many :kases has_many :people def to_s; companyname; end end class Person < ActiveRecord::Base has_many :kases # foreign key in join table belongs_to :company end In the create action for the person, I have a select box with a list of the companies, which assigns a company_id to that person's record: <%= f.select :company_id, Company.all.collect {|m| [m.companyname, m.id]} %> In the show view for the person I can list the company name as follows: <%=h @person.company.companyname %> What I am trying to work out, is how do I make that a link to the company record? I have tried: <%= link_to @person.company.companyname %> but that just outputs the company name inside a href tag but links to the current page. Thanks, Danny

    Read the article

  • How can I modify input before model binding in asp.net mvc?

    - by David G
    How can I intercept submitted form input and modify it before it is bound to my model? For example, if I wanted to trim the whitespace from all text. I have tried creating a custom model binder like so: public class CustomBinder : DefaultModelBinder { protected override void SetProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor, object value) { string newValue = ((string)value).Trim(); //example code to create new value but could be anything base.SetProperty(controllerContext, bindingContext, propertyDescriptor, newValue); } } but this doesn't seem to be invoked. Is there a better place to modify the input value? Note: I need to modify the value before it is bound and validated.

    Read the article

  • Translate model fields' attributes from a Database with Django?

    - by Luiz C.
    I'm trying to create a Model that has fields that have the following attributes translatable: verbose_name and choices. I can easily do this by tagging the strings and using the i18l middleware. The problem is that I don't want to define the translation in po/mo files. Is there a way to pull this data from a database table? If so, any examples? There are some options out there that offer model content translation. That is not my case. I need to translate the verbose_name, choices and error_messages from database.

    Read the article

  • Ruby on Rails: building a model with an attribute not in the database?

    - by randombits
    I have a model that sets one of its attributes based off of a form parameter that a user submits. The model is a child resource to a parent resource Home. A hypothetical example is the following: A class Person has an age attribute. The user submits a birthdate as an HTTP POST parameter and from that, I need to derive the age of the user. So I'd do something like this: @home.people.build(:name => params[:name], :birthdate => params[:birthdate]) Rails would barf on that for obvious reasons, complaining it doesn't know what the attribute birthdate is. What's the proper way of going about this? Is it possible to use the build constructor with the supplied solution so that my foreign key relations are also setup properly? If not, what's a better way to work around this problem?

    Read the article

  • What is the proper way to access datastore in custom Model Binders?

    - by mare
    How should I properly implement data access in my custom model binders? Like in controllers I use IContentRepository and then have it create an instance of its implementing class in constructor. So I have everything ready for incorporating IoC (DI) at a later stage. Now I need something similar in model binder. I need to make some DB lookups in the binder. I'm thinking of doing it the same way I do it in controllers but I am open to suggestion. This is a snippet from one of my controllers so you can imagine how I'm doing it in them: public class WidgetZoneController : BaseController { // BaseController has IContentRepository ContentRepository field public WidgetZoneController() : this(new XmlWidgetZoneRepository()) { } public WidgetZoneController(IContentRepository repository) { ContentRepository = repository; } ...

    Read the article

  • Can I use Pub/Sub model with Many Publishers and Only One Subscriber?

    - by rauch
    I need to send some files from different machines to only one Server. As I understand, I can use JMS api + (for example) ActiveMQ as broker. There are two models: p2p and pub/sub. I would like to use pub/sub model, but the problem is that I haven`t few subscribers, I have only one Subscriber(Server) and many Publishers. The question is the following: can I use pub/sub model for my situation and How can I send files from different machines to Only One Topic, on that Server sibscribed? May be any other ideas, thanks a lot.

    Read the article

  • What's the best way to share one Entity Framework 4 data model among multiple applications (meant to

    - by Ivan
    A project (a "solution" to say in VS terms) of mine consists of an ASP.Net 4 Dynamic Data Entities web application, some WinForms applications, some WPF applications, some services. All they are intended to work with one SQL Server database, generated from an Entity Framework 4 model as table-per-type, with lots of inheritance and multiple self-referencing relations. Where do I best put my model? In a separate class library, a copy in every project, in one project, etc. What naming should I best use? Is it good idea to name it MySolution.MyClassLibrary.MySolutionEntities, or just MySolutionEntities or just MySolution? Can you share any useful experience on this subject?

    Read the article

< Previous Page | 89 90 91 92 93 94 95 96 97 98 99 100  | Next Page >