Search Results

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

Page 19/538 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • XNA stopped compiling my model x files

    - by HuseyinUslu
    So I've a 3d game project I'm working on and I'm using 2 model files (SkyBlock.x and AimedBlock.x). So until now everything was all good and my models files were compiled all okay and I was able to use them within my game. With the latest changes (which I don't know what caused it really) - XNA stopped compiling my model files and instead only outputs files; AimedBlockxnb - 1kb SkyDome.xnb - 1kb SkyDomeTexture.xnb - 1389 kb SkyDomeTexture_0.xnb - 419 kb So I created a test XNA game project and moved all my asset's to new solution content project's and tried compiling them and saw that they're all good. AimedBlockxnb - 2kb SkyDome.xnb - 13kb SkyDomeTexture.xnb - 4097 kb SkyDomeTexture_0.xnb - 683 kb So I guess my main project sucks there but I couldn't came with a solution. I even tried overwriting my game's content project with new game's content project (which was all okay) but it didn't work. Anybody had similar issues?

    Read the article

  • Model Based Apps and Frameworks

    Having been involved (mostly as a user or observer) with several recent applications and frameworks, Ive come to the conclusion that building your app/framework on an internal model is generally the best way to go.  In this post Ill explain what I mean by on an internal model and later describe the benefits I have seen, realized, been told about by others and still others that Ive only imagined (but are still possible).  I plan on writing a few blog posts along these lines to explore what...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Model Based Apps and Frameworks

    Having been involved (mostly as a user or observer) with several recent applications and frameworks, Ive come to the conclusion that building your app/framework on an internal model is generally the best way to go.  In this post Ill explain what I mean by on an internal model and later describe the benefits I have seen, realized, been told about by others and still others that Ive only imagined (but are still possible).  I plan on writing a few blog posts along these lines to explore what...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • what is this 'content_type' mean..

    - by zjm1126
    content_type = ContentType.objects.get_for_model(Map) maps = maps.extra(select=SortedDict([ ('member_count', MEMBER_COUNT_SQL), ('topic_count', TOPIC_COUNT_SQL), ]), select_params=(content_type.id,)) and the ContentType is: class ContentType(models.Model): name = models.CharField(max_length=100) app_label = models.CharField(max_length=100) model = models.CharField(_('python model class name'), max_length=100) objects = ContentTypeManager() class Meta: verbose_name = _('content type') verbose_name_plural = _('content types') db_table = 'django_content_type' ordering = ('name',) unique_together = (('app_label', 'model'),) def __unicode__(self): return self.name def model_class(self): "Returns the Python model class for this type of content." from django.db import models return models.get_model(self.app_label, self.model) def get_object_for_this_type(self, **kwargs): """ Returns an object of this type for the keyword arguments given. Basically, this is a proxy around this object_type's get_object() model method. The ObjectNotExist exception, if thrown, will not be caught, so code that calls this method should catch it. """ return self.model_class()._default_manager.using(self._state.db).get(**kwargs) def natural_key(self): return (self.app_label, self.model) i want to know: what is the 'content_type' used for ??

    Read the article

  • In MVC framworks (such as Ruby on Rails), do usually Model spell as singular and controller and view

    - by Jian Lin
    I usually see Ruby on Rails books using script/generate model Story name:string link:string which is a singular Story, while when it is controller script/generate controller Stories index then the Story now is Stories, which is plural. Is this a standard on Ruby on Rails? Is it true in other MVC frameworks too, like CakePHP, Symfony, Django, or TurboGears? I see that in the book Rails Space, the controller is also called User, which is the same as the model name, and it is the only exception I see.

    Read the article

  • Doctrine 1.2: Can a model have two instances of the sluggabl behavior?

    - by prodigitalson
    I dont see any direct mention on using multiple slugs (or any behavior for that matter) for single model. Is there a way to use the sluggable behavior to generate two separate slugs for a model? For example i need to generate two slugs for every record a product_id consisting of a slugified company name and sku and a distributor_id consisting of a different slugified company name. Obviously i could write this myself fairly easily, im just wondering if this can be done quickly with Sluggable.

    Read the article

  • how to get all 'username' from my model 'MyUser' on google-app-engine ..

    - by zjm1126
    my model is : class MyUser(db.Model): user = db.UserProperty() password = db.StringProperty(default=UNUSABLE_PASSWORD) email = db.StringProperty() nickname = db.StringProperty(indexed=False) and my method which want to get all username is : s=[] a=MyUser.all().fetch(10000) for i in a: s.append(i.username) and the error is : AttributeError: 'MyUser' object has no attribute 'username' so how can i get all 'username', which is the simplest way . thanks

    Read the article

  • Why the only hidden field that is being filled from GET action is not being passed in model?

    - by user1807954
    Sorry for the long title, I didn't know how to make it any shorter. My code: My model: public class CarFilter { public String carMake { get; set; } public String carModel { get; set; } public String carEdition { get; set; } . . . public String SortBy { get; set; } } public class CarSearch : CarFilter { public List<Car> Car { get; set; } } My controller: public ActionResult SearchResult(CarSearch search) { var cars = from d in db.Cars select d; if (Request.HttpMethod == "POST") { search.SortBy = "Price"; } search.Car = new List<Car>(); search.Car.AddRange(cars); var temp = new List<CarSearch>(); temp.Add(search); return View(temp); } My Index view (where user filters results): @model IEnumerable<Cars.Models.CarSearch> @using (Html.BeginForm("SearchResult", "Home", FormMethod.Post)){..forms and other stuff..} My SearchResult view (where user sees the results of filtration): @model IEnumerable<Cars.Models.CarSearch> @using (Html.BeginForm("SearchResult", "Home", FormMethod.Get)) { @Html.Hidden("carMake") @Html.Hidden("carModel") @Html.Hidden("carEdition") . . . @Html.Hidden("SortBy", temp.SortBy) <input name="SortBy" class="buttons" type="submit" value="Make"/> My goal What I'm trying to do is when user clicked on sort by Make it will have to GET back all the variables in hidden field back to the SearchResult action in order to sort the result (same filtered results). Result Is: <input id="SortBy" name="SortBy" type="hidden" value=""/>. The value is null and it's not being passed but all the other hidden fields such as carMake and etc have value. But when I use foreach it works perfect. Question Why is this like this? the SortBy is in the same model class as other fields in the view. The only difference is that SortBy is not being filled in the Index view with other fields, instead it's being filled in controller action. What is the explanation for this? Am I missing any C# definition or something such as dynamic objects or something?

    Read the article

  • How do I make an object a property of a model in Ruby on Rails?

    - by iTake
    I have this in my schema: create_table "robots_matches", :force => true do |t| t.integer "robot_id" t.integer "match_id" and I think I want to be able to load a robot and match from within my robots_match model so I can do something like this: robots_match.find(:id).get_robot().Name My attempt in the robots_matches model was this: def get_robot Robot.find(this.id) end I am super new to rails, so feel free to correct my architectural decision here.

    Read the article

  • MVC: model of type Nullable<T>

    - by Fyodor Soikin
    I have a partial view that inherits from ViewUserControl<Guid?> - i.e. it's model is of type Nullable<Guid>. Very simple view, nothing special, but that's not the point. Somewhere else, I do Html.RenderPartial( "MyView", someGuid ), where someGuid is of type Nullable<Guid>. Everything's perfectly legal, should work OK, right? But here's the gotcha: the second argument of Html.RenderPartial is of type object, and therefore, Nullable<Guid> being a value type, it must be boxed. But nullable types are somehow special in the CLR, so that when you box one of those, you actually get either a boxed value of type T (Nullable's argument), or a null if the nullable didn't have a value to begin with. And that last case is actually interesting. Turns out, sometimes, I do have a situation when someGuid.HasValue == false. And in those cases, I effectively get a call Html.RenderPartial( "MyView", null ). And what does the HtmlHelper do when the model is null? Believe it or not, it just goes ahead and takes the parent view's model. Regardless of it's type. So, naturally, in those cases, I get an exception saying: "The model item passed into the dictionary is of type 'Parent.View.Model.Type', but this dictionary requires a model item of type 'System.Guid?'" So the question is: how do I make MVC correctly pass new Nullable<Guid> { HasValue = false } instead of trying to grab the parent's model? Note: I did consider wrapping my Guid? in an object of another type, specifically created for this occasion, but this seems completely ridiculous. Don't want to do that as long as there's another way. Note 2: now that I've wrote all this, I've realized that the question may be reduced to how to pass a null for model without ending up with parent's model?

    Read the article

  • rails Creating a model instance automatically when another is created

    - by bob
    Hello I have a user model and a ratings model. Whenever a new user is created I want to create a new feedback model with it automatically. Each user model has one feedback model and each feedback model has many ratings. My Classes class User < ActiveRecord::Base end class Feedback < ActiveRecord::Base belongs_to :user has_many :ratings end class Rating < ActiveRecord::Base belongs_to :feedback end My database tables -user doesn't have anything special -feedback has user_id. This user_id should be the same as the user that has just been created. For example, user_id of 1 is created, then a feedback model should be created that belongs to user_id of 1. So the user_id column in the feedback database will also be 1. - Rating has a feedback_id and a user_id the user_id in this case is the id of the person who submitted the rating. I am having it assigned through the build command. I believe my process is correct here. The Goal The goal is to have each user have a feedback table that has many ratings from other users. So if someone goes to the feedback page, they will see all the ratings given and by who. Is there a better way to approach this? How do you create a model of feedback with the same id as the user being created right when a new user is created. The idea is that when a user is created a feedback is created associated with that user so people can then go to http://localhost:3000/users/1/feedback/ and submit new ratings. I'm trying to bypass having a user rate another user with just a ratings model because I'm not sure how to do it.

    Read the article

  • Java MVC project - either I can't update the drawing, or I can't see it

    - by user1881164
    I've got a project based around the Model-View-Controller paradigm, and I've been having a lot of trouble with getting it to work properly. The program has 4 panels, which are supposed to allow me to modify an oval drawn on the screen in various ways. These seem to work fine, and after considerable trouble I was able to get them to display in the JFrame which holds the whole shebang. I've managed to get them to display by breaking away from the provided instructions, but when I do that, I can't seem to get the oval to update. However, if I follow the directions to the letter, I only ever see an empty frame. The project had pretty specific directions, which I followed up to a point, but some of the documentation was unclear. I think what I'm missing must be something simple, since nothing is jumping out at me as not making sense. I have to admit though that my Java experience is limited and my experience with GUI design/paradigms is even more so. Anyway, I've been searching the web and this site extensively trying to figure out what's wrong, but this is a somewhat specific example and honestly I just don't know enough about this to generalize any of the answers I've found online and figure out what's missing. I've been poring over this code for far too long now so I'm really hoping someone can help me out. public class Model { private Controller controller; private View view; private MvcFrame mvcFrame; private int radius = 44; private Color color = Color.BLUE; private boolean solid = true; //bunch of mutators and accessors for the above variables public Model() { controller = new Controller(this); view = new View(this); mvcFrame = new MvcFrame(this); } } Here's the model class. This seems to be fairly simple. I think my understanding of what's going on here is solid, and nothing seems to be wrong. Included mostly for context. public class Controller extends JPanel{ private Model model; public Controller(Model model) { this.model = model; setBorder(BorderFactory.createLineBorder(Color.GREEN)); setLayout(new GridLayout(4,1)); add(new RadiusPanel(model)); add(new ColorPanel(model)); add(new SolidPanel(model)); add(new TitlePanel(model)); } } This is the Controller class. As far as I can tell, the setBorder, setLayout, and series of adds do nothing here. I had them commented out, but this is the way that the instructions told me to do things, so either there's a mistake there or something about my setup is wrong. However, when I did it this way, I would get an empty window (JFrame) but none of the panels would show up in it. What I did to fix this is put those add functions in the mvcFrame class: public class MvcFrame extends JFrame { private Model model; public MvcFrame(Model model){ this.model = model; //setLayout(new GridLayout(4,1)); //add(new RadiusPanel(model)); //add(new ColorPanel(model)); //add(new SolidPanel(model)); //add(new TitlePanel(model)); //add(new View(model)); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLocationRelativeTo(null); setSize(800,600); setVisible(true); } } So here's where things kind of started getting weird. The first block of commented out code is the same as what's in the Controller class. The reason I have it commented out is because that was just a lucky guess - it's not supposed to be like that according to the instructions. However, this did work for getting the panels to show up - but at that point I was still tearing my hair out trying to get the oval to display. The other commented line ( add(new View(model)); ) was a different attempt at making things work. In this case, I put those add functions in the View class (see commented out code below). This actually worked to display both the oval and the panels, but that method wouldn't allow me to update the oval. Also, though I just had the oval displaying, I can't seem to figure out what exactly made that happen, and I can't seem to make it come back. public class View extends JPanel{ private Model model; public View(Model model) { this.model = model; //setLayout(new GridLayout(4,1)); //add(new RadiusPanel(model)); //add(new ColorPanel(model)); //add(new SolidPanel(model)); //add(new TitlePanel(model)); repaint(); } @Override protected void paintComponent(Graphics g){ super.paintComponent(g); //center of view panel, in pixels: int xCenter = getWidth()/2; int yCenter = getHeight()/2; int radius = model.getRadius(); int xStart = xCenter - radius; int yStart = yCenter - radius; int xWidth = 2 * radius; int yHeight = 2 * radius; g.setColor(model.getColor()); g.clearRect(0, 0, getWidth(), getHeight()); if (model.isSolid()){ g.fillOval(xStart, yStart, xWidth, yHeight); } else { g.drawOval(xStart, yStart, xWidth, yHeight); } } } Kinda same idea as before - the commented out code is stuff I added to try to get things working, but is not based on the provided directions. In the case where that stuff was uncommented, I had the add(new View(model)); line from the mvcFrame line uncommented as well. The various panel classes (SolidPanel, ColorPanel, etc) simply extend a class called ControlPanel which extends JPanel. These all seem to work as expected, not having much issue with them. There is also a driver which launches the GUI. This also seems to work as expected. The main problem I'm having is that I can't get the oval to show up, and the one time I could make it show up, none of the options for changing it seemed to work. I feel like I'm close but I'm just at a loss for other things to try out at this point. Anyone who can help will have my sincerest gratitude.

    Read the article

  • How would the 'Model' in a Rails-type webapp be implemented in a functional programming langauge?

    - by ceptorial
    In MVC web development frameworks such as Ruby on Rails, Django, and CakePHP, HTTP requests are routed to controllers, which fetch objects which are usually persisted to a backend database store. These objects represent things like users, blog posts, etc., and often contain logic within their methods for permissions, fetching and/or mutating other objects, validation, etc. These frameworks are all very much object oriented. I've been reading up recently on functional programming and it seems to tout tremendous benefits such as testability, conciseness, modularity, etc. However most of the examples I've seen for functional programming implement trivial functionality like quicksort or the fibonnacci sequence, not complex webapps. I've looked at a few 'functional' web frameworks, and they all seem to implement the view and controller just fine, but largely skip over the whole 'model' and 'persistence' part. (I'm talking more about frameworks like Compojure which are supposed to be purely functional, versus something Lift which conveniently seems to use the OO part of Scala for the model -- but correct me if I'm wrong here.) I haven't seen a good explanation of how functional programming can be used to provide the metaphor that OO programming provides, i.e. tables map to objects, and objects can have methods which provide powerful, encapsulated logic such as permissioning and validation. Also the whole concept of using SQL queries to persist data seems to violate the whole 'side effects' concept. Could someone provide an explanation of how the 'model' layer would be implemented in a functionally programmed web framework?

    Read the article

  • What does this model error says in asp.net mvc?

    - by Pandiya Chendur
    My Html action link takes me to a view where i can see the details.. For Ex:http://localhost:1985/Materials/Details/4 But it shows error, The model item passed into the dictionary is of type 'System.Data.Linq.DataQuery`1[CrMVC.Models.ConstructionRepository+Materials]' but this dictionary requires a model item of type 'CrMVC.Models.ConstructionRepository+Materials'. And my model is... public IQueryable<Materials> GetMaterial(int id) { return from m in db.Materials join Mt in db.MeasurementTypes on m.MeasurementTypeId equals Mt.Id where m.Mat_id == id select new Materials() { Id = Convert.ToInt64(m.Mat_id), Mat_Name = m.Mat_Name, Mes_Name = Mt.Name, }; } public class Materials { private Int64 id; public string mat_Name; public string mes_Name; public Int64 Id { get { return id; } set { id = value; } } public string Mat_Name { get { return mat_Name; } set { mat_Name = value; } } public string Mes_Name { get { return mes_Name; } set { mes_Name = value; } } } } and my controller method... public ActionResult Details(int id) { var material = consRepository.GetMaterial(id).AsQueryable(); return View("Details", material); } Any suggestion what am i missing here?

    Read the article

  • Should I put actors in the Domain-Model/Class-Diagram?

    - by devoured elysium
    When designing both the domain-model and class-diagrams I am having some trouble understanding what to put in them. I'll give an example of what I mean: I am doing a vacations scheduler program, that has an Administrator and End-Users. The Administrator does a couple of things like registering End-Users in the program, changing their previleges, etc. The End-User can choose his vacations days, etc. I initially defined an Administrator and End-User as concepts in the domain-model, and later as classes in the class-diagram. In the class-diagram, both classes ended up having a couple of methods like Administrator.RegisterNewUser(); Administrator.UnregisterUser(int id); etc. Only after some time I realised that actually both Administrator and End-User are actors, and maybe I got this design totally wrong. Instead of filling Administrator and End-User classes with methods to do what my Use-Cases request, I could define other classes from the domain to do them, and have controllers handle the Use-Cases(actually, I decided to do one for each Use-Case). I could have a UserDatabase.RegisterNewUser() and UserDatabase.UnregisterUser(int id);, for example, instead of having those methods on the Administrator class. The idea would be to try to think of the whole vacation-scheduler as a "closed-program" that has a set of features and doesn't bother with things such as authentication, that should be internal/protected, being that the only public things I'd let the outside world see would be its controllers. Is this the right approach? Or am I getting this totally wrong? Is it generally bad idea to put Actors in the domain-model/class-diagrams? What are good rules of thumb for this? My lecturer is following Applying UML and Patterns, which I find awful, so I'd like to know where I could look up more info on this described actor-models situation. I'm still a bit confused about all of this, as this new approach is radically different from anything I've done before.

    Read the article

  • MVC 3, View Model for user registration process. Password validation not working properly

    - by sec_goat
    I am trying to create a user registration page using MVC 3, so that I can better understand the process of how it works, what's going on behind the scenes etc. I am running into some issues when trying to use [Compare] to check to see that the user entered the same password twice. I tried adding the ComparePassword field to my user model first, and found that would not work the way I wanted as I did not have the field in the database, so the obvious answer was to create a View Model using the same information including the ComparePassword field. So I now have created a User model and a RegistrationViewModel, however it appears that the [Compare] on the password is not returning anything, for instance no matter what I put in the two boxes, when I click create it gives no error, which seems to me to mean it was successfully validated. I am not sure what I am doing or not doing to make this work properly. I have tried updating the jQuery.Validate to the newest version as there were some bugs reported in older version, this has not helped my efforts. Below is a wall of code, that is what I am working with. } public class RegistrationViewModel { [Required] [StringLength(15, MinimumLength = 3)] [Display(Name = "User Name")] [RegularExpression(@"(\S)+", ErrorMessage = " White Space is not allowed in User Names")] [ScaffoldColumn(false)] public String Username { get; set; } [Required] [StringLength(15, MinimumLength = 3)] [Display(Name = "First Name")] public String firstName { get; set; } [Required] [StringLength(15, MinimumLength = 3)] [Display(Name = "Last Name")] public String lastName { get; set; } [Required] [Display(Name = "Email")] public String email { get; set; } [Required] [Display(Name = "Password")] [DataType(DataType.Password)] public String password { get; set; } [Required] [DataType(DataType.Password)] [Display(Name = "Re-enter Password")] [Compare("Password", ErrorMessage = "Passwords do not match.")] public String comparePassword { get; set; } }

    Read the article

  • Create bullet physics rigid body along the vertices of a blender model

    - by Krishnabhadra
    I am working on my first 3D game, for iphone, and I am using Blender to create models, Cocos3D game engine and Bullet for physics simulation. I am trying to learn the use of physics engine. What I have done I have created a small model in blender which contains a Cube (default blender cube) at the origin and a UVSphere hovering exactly on top of this cube (without touching the cube) I saved the file to get MyModel.blend. Then I used File -> Export -> PVRGeoPOD (.pod/.h/.cpp) in Blender to export the model to .pod format to use along with Cocos3D. In the coding side, I added necessary bullet files to my Cocos3D template project in XCode. I am also using a bullet objective C wrapper. -(void) initializeScene { _physicsWorld = [[CC3PhysicsWorld alloc] init]; [_physicsWorld setGravity:0 y:-9.8 z:0]; /*Setup camera, lamp etc.*/ .......... ........... /*Add models created in blender to scene*/ [self addContentFromPODFile: @"MyModel.pod"]; /*Create OpenGL ES buffers*/ [self createGLBuffers]; /*get models*/ CC3MeshNode* cubeNode = (CC3MeshNode*)[self getNodeNamed:@"Cube"]; CC3MeshNode* sphereNode = (CC3MeshNode*)[self getNodeNamed:@"Sphere"]; /*Those boring grey colors..*/ [cubeNode setColor:ccc3(255, 255, 0)]; [sphereNode setColor:ccc3(255, 0, 0)]; float *cVertexData = (float*)((CC3VertexArrayMesh*)cubeNode.mesh).vertexLocations.vertices; int cVertexCount = (CC3VertexArrayMesh*)cubeNode.mesh).vertexLocations.vertexCount; btTriangleMesh* cTriangleMesh = new btTriangleMesh(); // for (int i = 0; i < cVertexCount * 3; i+=3) { // printf("\n%f", cVertexData[i]); // printf("\n%f", cVertexData[i+1]); // printf("\n%f", cVertexData[i+2]); // } /*Trying to create a triangle mesh that curresponds the cube in 3D space.*/ int offset = 0; for (int i = 0; i < (cVertexCount / 3); i++){ unsigned int index1 = offset; unsigned int index2 = offset+6; unsigned int index3 = offset+12; cTriangleMesh->addTriangle( btVector3(cVertexData[index1], cVertexData[index1+1], cVertexData[index1+2] ), btVector3(cVertexData[index2], cVertexData[index2+1], cVertexData[index2+2] ), btVector3(cVertexData[index3], cVertexData[index3+1], cVertexData[index3+2] )); offset += 18; } [self releaseRedundantData]; /*Create a collision shape from triangle mesh*/ btBvhTriangleMeshShape* cTriMeshShape = new btBvhTriangleMeshShape(cTriangleMesh,true); btCollisionShape *sphereShape = new btSphereShape(1); /*Create physics objects*/ gTriMeshObject = [_physicsWorld createPhysicsObjectTrimesh:cubeNode shape:cTriMeshShape mass:0 restitution:1.0 position:cubeNode.location]; sphereObject = [_physicsWorld createPhysicsObject:sphereNode shape:sphereShape mass:1 restitution:0.1 position:sphereNode.location]; sphereObject.rigidBody->setDamping(0.1,0.8); } When I run the sphere and cube shows up fine. I expect the sphere object to fall directly on top of the cube, since I have given it a mass of 1 and the physics world gravity is given as -9.8 in y direction. But What is happening the spere rotates around cube three or times and then just jumps out of the scene. Then I know I have some basic misunderstanding about the whole process. So my question is, how can I create a physics collision shape which corresponds to the shape of a particular mesh model. I may need complex shapes than cube and sphere, but before going into them I want to understand the concepts.

    Read the article

  • Models, collections...and then what? Processes?

    - by Dan
    I'm a LAMP-stack dev who's been more on the JavaScript side the last few years and really enjoying the Model + Collection approach to data entities that BackboneJS, etc. uses. It's helped me organize my code in such a way that it is extremely portable, keeping all my properties and methods in the scope (model, collection, etc.) in which they apply. One thing that keeps bugging me though is how to organize the next level up, the 'process layer' as you might call it, that can potentially operate on instances of either models or collections or whatever else. Where should methods like find() (which returns a collection) and create() (which returns a model) reside? I know some people would put a create() in the Collection prototype, but while a collection operates on models I don't think it's exactly right to create them. And while a find() would return a collection I don't think it correct to have that action within the collection prototype itself (it should be a layer up). Can anyone offer some examples of any patterns that employ some kind of OOP-friendly 'process' layer? I'm sorry if this is a fairly well-known discussion but I'm afraid I can't seem to find the terminology to search for.

    Read the article

  • Using separate model methods to manage transactions

    - by DCrystal
    If i’ve got 2(or more) model methods which do (for example, in billing system) enrolling/withdrawing, and one controller’s method that calls 2(or more) of these model methods. Is it a good way(maybe, any suggestions how to do it better) to write/use 2model methods like these: public function start_transaction(){ $this->db->trans_start(); } public function end_transaction(){ $this->db->trans_complete(); } And call in controller’s method: public function smth(){ //something $this->model->start_transaction(); $this->model->enroll(); //something else $this->model->withdraw(); $this->model->end_transaction(); } Will transaction be reversed, if model's withdraw() method fails? Thanks.

    Read the article

  • ASP.Net MVC 2: How to keep values in the model between posts

    - by Andreas
    I have an edit view that is displaying some model properties as plain text and other model properties as input fields. My problem is that the model properties displayed as plain text are null when the model is returned to the view after a validation error. How do I retain the model values when I don't have input fields for all properties? What is best practice? My first thought is to keep the values of these properties in hidden input elements. <%= Html.HiddenFor(model => model.CustomerName) %> Is this considered a correct solution? Thanks Andreas

    Read the article

  • Entity Framework 4 Hiding Underlying Resolver Tables when model is generated from database

    - by grrrrrrrrrrrrr
    When creating an entity framework model from scratch it is possible to specify a Many to Many relationship in the model. e.g Entity1 * ----- * Entity2 When a database is then generated from this, a resolver table is then created automatically between the two entities, this is hidden in the code model, allowing direct access to each of the entities via properties. e.g. Entity1 ----* ResolverEntity *----- Entity2 My question is, when a model is generated from an existing database, which contains resolver tables, is it possible to create the same effect so the resolver tables do not appear in the generated object model? When I have attempted this, the entity framework appears to create entities in the model for the resolver tables with no obvious way of hiding them in the object model. Thanks.

    Read the article

  • Is passing the Model around in this way considered bad practice?

    - by Theomax
    If I have a view called, for example, ViewDetails that displays user information in labels and has a Model called ViewDetailsModel and if I want to allow the user to click a button to edit some of these details, is it considered bad practice is I pass the entire Model in the markup to a controller method which then assigns the values for another model, using the values stored in the Model that was passed in as a parameter to that action method? If so, should there instead be a service method that gets the data required for the edit view? For example: In the ViewDetails view, the user clicks the edit button which calls an action method in the controller (and passes in the Model object). The action method then uses the data in the Model object to populate another model which will be used for the EditDetails view that will be returned.

    Read the article

  • Gui problem after rewriting to MVC

    - by trevor_nise
    I'm practicing MVC style programming. I have a Mastermind game in a single file, working with no problems (maybe apart of the fact that "Check" button is invisible at start). http://paste.pocoo.org/show/226726/ But when I've rewritten it to model, view, controller files - when I click on empty Pin (that should be updated, and repainted with new color) - noting happens. Can anybody see any problems here ? I've tried placing repaint() in different places, but it simply does not work at all :/ Main : public class Main { public static void main(String[] args){ Model model = new Model(); View view = new View("Mastermind", 400, 590, model); Controller controller = new Controller(model, view); view.setVisible(true); } } Model : import java.util.Random; public class Model{ static final int LINE = 5, SCORE = 10, OPTIONS = 20; Pin pins[][] = new Pin[21][LINE]; int combination[] = new int[LINE]; int curPin = 0; int turn = 1; Random generator = new Random(); int repaintPin; boolean pinsRepaint=false; int pinsToRepaint; boolean isUpdate = true, isPlaying = true, isRowFull = false; static final int HIT_X[] = {270,290,310,290,310}, HIT_Y[] = {506,496,496,516,516}; public Model(){ for ( int i=0; i < SCORE; i++ ){ for ( int j = 0; j < LINE; j++ ){ pins[i][j] = new Pin(20,0); pins[i][j].setPosition(j*50+30,510-i*50); pins[i+SCORE][j] = new Pin(8,0); pins[i+SCORE][j].setPosition(HIT_X[j],HIT_Y[j]-i*50); } } for ( int i=0; i < LINE; i++ ){ pins[OPTIONS][i] = new Pin( 20, i+2 ); pins[OPTIONS][i].setPosition( 370,i * 50 + 56); } } void fillHole(int color) { pins[turn-1][curPin].setColor(color+1); pinsRepaint = true; pinsToRepaint = turn; curPin = (curPin+1) % LINE; if (curPin == 0){ isRowFull = true; } pinsRepaint = false; pinsToRepaint = 0; } void check() { int junkPins[] = new int[LINE], junkCode[] = new int[LINE]; int pinCount = 0, pico = 0; for ( int i = 0; i < LINE; i++ ) { junkPins[i] = pins[turn-1][i].getColor(); junkCode[i] = combination[i]; } for ( int i = 0; i < LINE; i++ ){ if (junkPins[i]==junkCode[i]) { pins[turn+SCORE][pinCount].setColor(1); pinCount++; pico++; junkPins[i] = 98; junkCode[i] = 99; } } for ( int i = 0; i < LINE; i++ ){ for ( int j = 0; j < LINE; j++ ) if (junkPins[i]==junkCode[j]) { pins[turn+SCORE][pinCount].setColor(2); pinCount++; junkPins[i] = 98; junkCode[j] = 99; j = LINE; } } pinsRepaint = true; pinsToRepaint = turn + SCORE; pinsRepaint = false; pinsToRepaint=0; if ( pico == LINE ){ isPlaying = false; } else if ( turn >= 10 ){ isPlaying = false; } else{ curPin = 0; isRowFull = false; turn++; } } void combination() { for ( int i = 0; i < LINE; i++ ){ combination[i] = generator.nextInt(6) + 1; } } } class Pin{ private int color, X, Y, radius; public Pin(){ X = 0; Y = 0; radius = 0; color = 0; } public Pin( int r,int c ){ X = 0; Y = 0; radius = r; color = c; } public int getX(){ return X; } public int getY(){ return Y; } public int getRadius(){ return radius; } public void setRadius(int r){ radius = r; } public void setPosition( int x,int y ){ this.X = x ; this.Y = y ; } public void setColor( int c ){ color = c; } public int getColor() { return color; } } View: import java.awt.*; import javax.swing.*; public class View extends Frame{ Model model; JButton checkAnswer; private JPanel button; private static final Color COLORS[] = {Color.black, Color.white, Color.red, Color.yellow, Color.green, Color.blue, new Color(7, 254, 250)}; public View(String name, int w, int h, Model m){ model = m; setTitle( name ); setSize( w,h ); setResizable( false ); this.setLayout(new BorderLayout()); button = new JPanel(); button.setSize( new Dimension(400, 100)); button.setVisible(true); checkAnswer = new JButton("Check"); checkAnswer.setSize( new Dimension(200, 30)); button.add( checkAnswer ); this.add( button, BorderLayout.SOUTH); button.setVisible(true); } @Override public void paint( Graphics g ) { g.setColor( new Color(238, 238, 238)); g.fillRect( 0,0,400,590); for ( int i=0; i < model.pins.length; i++ ) { paintPins(model.pins[i][0],g); paintPins(model.pins[i][1],g); paintPins(model.pins[i][2],g); paintPins(model.pins[i][3],g); paintPins(model.pins[i][4],g); } } @Override public void update( Graphics g ) { if ( model.isUpdate ) { paint(g); } else { model.isUpdate = true; paintPins(model.pins[model.repaintPin-1][0],g); paintPins(model.pins[model.repaintPin-1][1],g); paintPins(model.pins[model.repaintPin-1][2],g); paintPins(model.pins[model.repaintPin-1][3],g); paintPins(model.pins[model.repaintPin-1][4],g); } } void repaintPins( int pin ) { model.repaintPin = pin; model.isUpdate = false; repaint(); } public void paintPins(Pin p, Graphics g ){ int X = p.getX(); int Y = p.getY(); int color = p.getColor(); int radius = p.getRadius(); int x = X-radius; int y = Y-radius; if (color > 0){ g.setColor( COLORS[color]); g.fillOval( x,y,2*radius,2*radius ); } else{ g.setColor( new Color(238, 238, 238) ); g.drawOval( x,y,2*radius-1,2*radius-1 ); } g.setColor( Color.black ); g.drawOval( x,y,2*radius,2*radius ); } } Controller: import java.awt.*; import java.awt.event.*; public class Controller implements MouseListener, ActionListener { private Model model; private View view; public Controller(Model m, View v){ model = m; view = v; view.addWindowListener( new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } }); view.addMouseListener(this); view.checkAnswer.addActionListener(this); model.combination(); } public void actionPerformed( ActionEvent e ) { if(e.getSource() == view.checkAnswer){ if(model.isRowFull){ model.check(); } } } public void mousePressed(MouseEvent e) { Point mouse = new Point(); mouse = e.getPoint(); if (model.isPlaying){ if (mouse.x > 350) { int button = 1 + (int)((mouse.y - 32) / 50); if ((button >= 1) && (button <= 5)){ model.fillHole(button); if(model.pinsRepaint){ view.repaintPins( model.pinsToRepaint ); } } } } } public void mouseClicked(MouseEvent e) {} public void mouseReleased(MouseEvent e){} public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} }

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >