Search Results

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

Page 133/538 | < Previous Page | 129 130 131 132 133 134 135 136 137 138 139 140  | Next Page >

  • Asp.net razor textbox array for list items

    - by yycdev
    I can't find or figure out how to take a list of items (cupcakes) and display them in razor with a quantity field. What is happening is I am not able to get the values for each cupcake quantity in the list. Can you do textbox arrays in Razor? VIEW <div class="form-group"> <label>Cupcakes</label> @foreach (var cupcake in Model.CupcakeList) { @Html.TextBox("CupcakeQuantities", cupcake.Id) @cupcake.Name <br/> } </div> MODEL public List<Cupcake> CupcakeList { get; set; } public List<int> CupcakeQuantities { get; set; } CONTROLLER public ActionResult Create() { var model = new PartyBookingModel() { CupcakeList = db.Cupcakes.ToList(), CupcakeQuantities = new List<int>() }; return View(model); }

    Read the article

  • Can this django query be improved?

    - by Hobhouse
    Given a model structure like this: class Book(models.Model): user = models.ForeignKey(User) class Readingdate(models.Model): book = models.ForeignKey(Book) date = models.DateField() One book may have several readingdates. How do I list books having at least one readingdate within a specific year? I can do this: from_date = datetime.date(2010,1,1) to_date = datetime.date(2010,12,31) book_ids = Readingdate.objects\ .filter(date__range=(from_date,to_date))\ .values_list('book_id', flat=True) books_read_2010 = Book.objects.filter(id__in=book_ids) Is it possible to do this with one queryset, or is this the best way?

    Read the article

  • ASP.NET MVC. Hot to guess autogenerated id value ?

    - by Andrew Florko
    My web form contains list of dynamic fields that are generated like this: <% for (int i = 0; i < Model.Options.Count; i++) { %> ... <%= Html.Hidden("Options[" + i + "].Id", Model.Options[i].Id)%> <%= Html.CheckBox("Options[" + i + "].Selected", Model.Options[i].Selected)%> ... This maps perfectly on array of controller method parameters as described in Model Binding To A List article. I want to add label for checkboxes to title them, but I have to guess their ids in hmtl layout. Options[" + i + "].Selected turns into Options_0__Selected How can I avoid hardcoding Id generation in-built asp.net mvc rules? Thank you advance.

    Read the article

  • Rails, destroy if blank

    - by Joseph Silvashy
    This might sound odd, but is there a 'Rails way' to have a model destroyed if a certain attribute is blank? Say I have a model like tags with just a name attribute or something, if the user edits the tag and deletes all the text out of the name field in the form I'd like the model to just be deleted. I'm aware of the reject_if method, but that doesn't seem to work.

    Read the article

  • How to find full module path of a class to import in other file

    - by Pooya
    I have method that returns module path of given class name def findModulePath(path, className): attributes = [] for root, dirs, files in os.walk(path): for source in (s for s in files if s.endswith(".py")): name = os.path.splitext(os.path.basename(source))[0] full_name = os.path.splitext(source)[0].replace(os.path.sep, '.') m = imp.load_module(full_name, *imp.find_module(name, [root])) try: attr = getattr(m, className) attributes.append(attr) except: pass if len(attributes) <= 0: raise Exception, "Class %s not found" % className for element in attributes: print "%s.%s" % (element.__module__, className) but it does not return the full path of the module, For example I have a python file named "objectmodel" in objects package,and it contains a Model class, So I call findModulePath(MyProjectPath,"Model"). it prints objectmodel.Model but I need objects.objectmodel.Model

    Read the article

  • Creating a Group of Groups in Django

    - by Greg
    I'm creating my own Group model; I'm not referring to the builtin Group model. I want each hroup to be a member of another group (it's parent), but there is the one "top" group that doesn't have a parent group. The admin interface won't let me create a group without entering a parent. I get the error personnel_group.parent_id may not be NULL. My Group model looks like this: class Group(models.Model): name = models.CharField(max_length=50) parent = models.ForeignKey('self', blank=True, null=True) order = models.IntegerField() icon = models.ImageField(upload_to='groups', blank=True, null=True) description = models.TextField(blank=True, null=True) How can I accomplish this? Thanks.

    Read the article

  • How do I restrict foreign keys choices to related objects only in django

    - by Jeff Mc
    I have a two way foreign relation similar to the following class Parent(models.Model): name = models.CharField(max_length=255) favoritechild = models.ForeignKey("Child", blank=True, null=True) class Child(models.Model): name = models.CharField(max_length=255) myparent = models.ForeignKey(Parent) How do I restrict the choices for Parent.favoritechild to only children whose parent is itself? I tried class Parent(models.Model): name = models.CharField(max_length=255) favoritechild = models.ForeignKey("Child", blank=True, null=True, limit_choices_to = {"myparent": "self"}) but that causes the admin interface to not list any children.

    Read the article

  • Returning a local object from a function

    - by pocoa
    Is this the right way to return an object from a function? Car getCar(string model, int year) { Car c(model, year); return c; } void displayCar(Car &car) { cout << car.getModel() << ", " << car.getYear() << endl; } displayCar(getCar("Honda", 1999)); I'm getting an error, "taking address of temporary". Should I use this way: Car &getCar(string model, int year) { Car c(model, year); return c; }

    Read the article

  • Is there a way to undo Mocha stubbing of any_instance?

    - by Steve Weet
    Within my controller specs I am stubbing out valid? for some routing tests, (based on Ryan Bates nifty_scaffold) as follows :- it "create action should render new template when model is invalid" do Company.any_instance.stubs(:valid?).returns(false) post :create response.should render_template(:new) end This is fine when I test the controllers in isolation. I also have the following in my model spec it "is valid with valid attributes" do @company.should be_valid end Again this works fine when tested in isolation. The problem comes if I run spec for both models and controllers. The model test always fails as the valid? method has been stubbed out. Is there a way for me to remove the stubbing of any_instance when the controller test is torn down. I have got around the problem by running the tests in reverse alphabetic sequence to ensure the model tests run before the controllers but I really don't like my tests being sequence dependant.

    Read the article

  • Can I assigin value dynamically like this?

    - by kumar
    <input type="text" id="Date-<%=Model.ID%>" value= " + <%=Html.DisplayFor(model=>model.Date)%> + " /> is this right? i am trying to display value in input box dynamically? can anyone advice me is this corect approach? but still I am getting here only + + in input box? thanks

    Read the article

  • Why does JPA require a no-arg constructor for domain objects ?

    - by Jacques René Mesrine
    Why does JPA require a no-arg constructor for domain objects ? I am using eclipselink and just got this exception during deployment. Exception [EclipseLink-63] (Eclipse Persistence Services-1.1.0.r3639-SNAPSHOT): org.eclipse.persistence.exceptions.DescriptorException Exception Description: The instance creation method [com.me.model.UserVO.<Default Constructor>], with no parameters, does not exist, or is not accessible. Internal Exception: java.lang.NoSuchMethodException: com.me.model.UserVO.<init>() Descriptor: RelationalDescriptor(com.me.model.UserVO --> [DatabaseTable(user)])

    Read the article

  • Validating an Autocomplete field in Django

    - by anonymous coward
    I have models similar to the following: class Band(models.Model): name = models.CharField(unique=True) class Event(models.Model): name = models.CharField(max_length=50, unique=True) bands = models.ManyToManyField(Band) and essentially I want to use the validation capability offered by a ModelForm that already exists for Event, but I do not want to show the default Multi-Select list (for 'bands') on the page, because the potential length of the related models is extremely long. I have the following form defined: class AddEventForm(ModelForm): class Meta: model = Event fields = ('name', ) Which does what is expected for the Model, but of course, validation could care less about the 'bands' field. I've got it working enough to add bands correctly, but there's no correct validation, and it will simply drop bad band IDs. What should I do so that I can ensure that at least one (correct) band ID has been sent along with my form? For how I'm sending the band-IDs with auto-complete, see this related question: http://stackoverflow.com/questions/1528059/

    Read the article

  • dynamic searchable fields, best practice?

    - by boblu
    I have a Lexicon model, and I want user to be able to create dynamic feature to every lexicon. And I have a complicate search interface that let user search on every single feature (including the dynamic ones) belonged to Lexicon model. I could have used a serialized text field to save all the dynamic information if they are not for searching. In case I want to let user search on all fields, I have created a DynamicField Model to hold all dynamically created features. But imagine I have 1,000,000,000 lexicon, and if one create a dynamic feature for every lexicon, this will result creating 1,000,000,000 rows in DynamicField model. So the sql search function will become quite inefficient while a lot of dynamic features created. Is there a better solution for this situation? Which way should I take? searching for a better db design for dynamic fields try to tuning mysql(add cache fields, add index ...) with current db design

    Read the article

  • How do you set the default source for the Output window in Visual Studio?

    - by Grank
    We added a SharePoint BDC model project to a solution in Visual Studio 2010. Ever since, whenever the solution is built, instead of showing the Build output in the Output window, it insists on having "SharePoint Tools" selected in the "Show Output from:" drop-down, just to say "Model validation started ... Model validation completed with no errors." Short of shutting off any SharePoint projects in the build configuration, can this behavior be overridden?

    Read the article

  • Best Practice for Summary Footer (and the like) in MVC

    - by benpage
    Simple question on best practice. Say I have: public class Product { public string Name { get; set; } public string Price { get; set; } public int CategoryID { get; set; } public bool IsAvailable { get; set; } } and i have a view using IEnumerable< Product as the model, and i iterate through the Products on the page and want to show the total of the prices at the end of the list, should I use: <%= Model.Sum(x=> x.Price) %> or should I use some other method? This may extend to include more involved things like: <%= Model.Where(x=> x.CategoryID == 5 && x.IsAvailable).Sum(x=> x.Price) %> and even <% foreach (Product p in Model.Where(x=> x.IsAvailable) {%> -- insert html -- <% } %> <% foreach (Product p in Model.Where(x=> !x.IsAvailable) {%> -- insert html -- <% } %> I guess this comes down to should I have that sort of code within my view, or should i be passing it to my view in ViewData? Or perhaps some other way?

    Read the article

  • What does the MVC Controller.UpdateModel<T>(T) actually try to do?

    - by unanswered
    When I submit my MVC Page I get an IvalidOperationException from System.Web.Mvc Controller object in the UpdateModel method. the MSDN documentation states that this method does the following: Updates the specified model instance using values from the controller's current value provider. Is the value provider referencing the current Request object? Or where exactly does it get the values that it is using to update the model? And what specifically does the UpdateModel method check and what does it 'mean' when it says that The model of type 'abcXYZ' was not successfully updated Thanks

    Read the article

  • I am confused about how to use @SessionAttributes

    - by yusaku
    I am trying to understand architecture of Spring MVC. However, I am completely confused by behavior of @SessionAttributes. Please look at SampleController below , it is handling post method by SuperForm class. In fact, just field of SuperForm class is only binding as I expected. However, After I put @SessionAttributes in Controller, handling method is binding as SubAForm. Can anybody explain me what happened in this binding. ------------------------------------------------------- @Controller @SessionAttributes("form") @RequestMapping(value = "/sample") public class SampleController { @RequestMapping(method = RequestMethod.GET) public String getCreateForm(Model model) { model.addAttribute("form", new SubAForm()); return "sample/input"; } @RequestMapping(method = RequestMethod.POST) public String register(@ModelAttribute("form") SuperForm form, Model model) { return "sample/input"; } } ------------------------------------------------------- public class SuperForm { private Long superId; public Long getSuperId() { return superId; } public void setSuperId(Long superId) { this.superId = superId; } } ------------------------------------------------------- public class SubAForm extends SuperForm { private Long subAId; public Long getSubAId() { return subAId; } public void setSubAId(Long subAId) { this.subAId = subAId; } } ------------------------------------------------------- <form:form modelAttribute="form" method="post"> <fieldset> <legend>SUPER FIELD</legend> <p> SUPER ID:<form:input path="superId" /> </p> </fieldset> <fieldset> <legend>SUB A FIELD</legend> <p> SUB A ID:<form:input path="subAId" /> </p> </fieldset> <p> <input type="submit" value="register" /> </p> </form:form>

    Read the article

  • Embedded Record is not getting loaded in Ember.js

    - by Venky
    Following is the JSON data I am trying to load using ember-data: { "product" : [ { "id" : 1, "name" : "product1", "master" : { "id" : 1, "name" : "product1", "images" : [ { "id" : 1, "productUrl" : "/images/product1_1.jpg" }, { "id" : 2, "productUrl" : "/images/product1_2.jpg" } ] } }, { "id" : 2, "name" : "product2", "master" : { "id" : 2, "name" : "product2", "images" : [ { "id" : 3, "productUrl" : "/images/product2_1.jpg" }, { "id" : 4, "productUrl" : "/images/product2_2.jpg" } ] } } ] } The models are as follows: App.Product = DS.Model.extend name: DS.attr('string') description: DS.attr('string') master: DS.belongsTo('master') App.Master = DS.Model.extend images: DS.hasMany('image') App.Image = DS.Model.extend productUrl: DS.attr('string') The Application Serializer code is as follows: App.ApplicationSerializer = DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, attrs: { images: { embedded : 'always' } master: { embedded : 'always' } } ) The problem is that the "master" model records are being returned empty. I am not sure, where I am going wrong. I am using the following platform configuration: ember-source (1.4.0) ember-data-source (1.0.0.beta.7) ember-rails (0.15.0) Rails (4.1.0) Thanks

    Read the article

  • my jComboBox does not react to my keyListener and actionPerform perfroms weired stuff

    - by aladdin
    hi I am trying to search for UserName and return values onto jComboBox, here is the code public void actionPerformed(java.awt.event.ActionEvent e) { sr = new Search(((String) jComboBoxReceiver.getSelectedItem())); usrList = sr.searchUser(); String[] userList = new String[usrList.size()] ; for(int i=0;i<usrList.size();i++){ userList[i]= usrList.get(i).getUserName(); } model = new DefaultComboBoxModel(userList); jComboBoxReceiver.setModel(model); } However, if i do that, it does perform correctly, however, it will go search for the first item again, which is very confusing... then i tried using key Pressed if(e.getKeyCode()==13){ sr = new Search(((String) jComboBoxReceiver.getSelectedItem())); usrList = sr.searchUser(); String[] userList = new String[usrList.size()] ; for(int i=0;i<usrList.size();i++){ userList[i]= usrList.get(i).getUserName(); } model = new DefaultComboBoxModel(userList); jComboBoxReceiver.setModel(model); } And this one does not react at all ...

    Read the article

  • ExceptionHandling with Spring 3

    - by mjf
    I have this controller: @RequestMapping(value = "*.xls", method = RequestMethod.GET) public String excel(Model model) { return "excel"; The excel wiew opens actually a ExcelViewer, which is build in method protected void buildExcelDocument(Map<String, Object> map, WritableWorkbook ww, HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception { Class.writecontent Class.writeMoreContent Called methods write content to the Excel sheet and they can throw e.g biffException. How can I show a certain error page when Exception is occured? I tried this @Controller public class ExcelController { @ExceptionHandler(BiffException.class) public String handleException(BiffException ex) { return "fail"; } @RequestMapping(value = "*.xls", method = RequestMethod.GET) public String excel(Model model) { return "excel"; } } But I'm getting the server's error message about Exceptions. Maybe a bean definition missing?

    Read the article

  • Groovy & Grails Concurrency ( quartz, executor )

    - by Pietro
    What I'm trying to do is to run multiple threads at some starting time. Those threads must stay alive for 90minutes after start. During the 90minutes they execute something after a random sleep time (ex: 5minutes to 15minutes). Here is a pseudo code on how I would implement it. The problem is that doing it in this way the threads run in an unexpected way. How can I implement correctly something like this? Class MyJob { static triggers = { cron name: 'first', cronExpression: "0 30 21 * * FRI" cron name: 'second', cronExpression: "0 30 19 * * FRI" cron name: 'third', cronExpression: "0 30 17 * * FRI" def myService def execute() { switch( between trigger name ) case 'first': model = Model.findByAttribute(...) ... myService.run( model, start_time ) break; ... } } class MyService { def run( model, start_time ) { def end_time = end_time.plusMinutes(90) model.fields.each( field -> Thread.start { executeSomeTasks( field, start_time, end_time ) } ) } def executeSomeTasks( field, start_time, end_time ) { while( start_time < end_time ) { ...do something ... sleep( Random.nextInt( 1000 ) ); } } }

    Read the article

  • how to get SOURCE

    - by laknath27
    i do some development with jena ontology API.my ontology file in my local machine..when i'm going to read the model.. there is an error.. and i made ontology with protege and tried to read that file. String SOURCE = "http://www.owl-ontologies.com/Ontology1275995702";(it's XML:base value) //String NS = SOURCE + "#"; //InputStream in = FileManager.get().open("tourism.owl"); OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); model.read(SOURCE,"RDF/XML"); OntClass paper = model.getOntClass( SOURCE + "srilanka" ); how can i fix this?

    Read the article

  • Accessing ArrayList in Javascript - ASP.Net MVC2

    - by Shrikant
    Hi I have ArrayList in my Model and want to iterate through it in my javascript. I am using following code but its giving me error : CS0103: The name 'i' does not exist in the current context for(var i=0; i <= <%=Model.KeyList.Count%>; i++) { alert('<%=Model.KeyList[i]%>'); } How to get rid of this. its urgent...Please.

    Read the article

  • Converting DTOs to View Models

    - by illvm
    Does anyone know of a good (read: quick to code) method for converting DTOs to View Models or mapping DTO members to View Model members? Lately I've been finding myself writing many conversion and helper methods but this is a very arduous and tedious task. Moreover, it will often needs to be done twice (DTO - View Model, View Model - DTO). Is there a methodology, technique, or technology which would allow me to do this more quickly and efficiently?

    Read the article

< Previous Page | 129 130 131 132 133 134 135 136 137 138 139 140  | Next Page >