Search Results

Search found 5872 results on 235 pages for 'authorize attribute'.

Page 15/235 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • Unable to pass attribute from controller to view

    - by MDS
    I'm using Spring MVC 3 for a web app. In the app a URI template is supposed to be handled by a controller method, which then passes an attribute to a view. Currently, the controller does handle the request, and it even forwards to the correct view. However, it does NOT pass the attribute to the view. Below are the URI template, controller method and relevent jsp tags. Anyone see what is wrong? URI: /home/{status} Controller: @RequestMapping("/home") @Controller public class HomeController { ... ... @RequestMapping(value="/{status}") public String homeStatusView(@PathVariable("status") String status, ModelMap model) { model.addAttribute("status", status); return "home"; } } JSP: ... <c:if test="${not empty status}"> <span class="status">Your status is available...</span> </c:if> ...

    Read the article

  • Xml schema, how to make sure one element exists with a specific attribute value

    - by pexxxy
    How do I enforce the existing of an element with a specific attribute value in the XML? For example: <events> <event type="system" desc="this is a system event"/> <event type="bla1" desc="this is bla1 event"/> <event type="bla2" desc="this is bla2 event"/> </events> I need a rule to make sure the event element with type attribute = 'system' exists (once). All other event elements are optional;

    Read the article

  • Flex - Use Variables for Object Attribute Names

    - by Immanuel
    How do you use variables to access Object attributes? Suppose I have an Object declared as follows, var obj:Object = new Object; obj.Name = "MyName"; obj.Age = "10"; How would i do something like this, var fieldName:String = "Name"; var fieldAge:String = "Age"; var Name_Age:String = obj.fieldName + " ," + obj.fieldAge; The code above treats 'fieldName' and 'fieldAge' as attribute name itself. I want to treat the same as a variable, and map the value associated with the variable as the Object attribute name.

    Read the article

  • JSTL request attribute in c:if

    - by JNPW
    I set an request attribute in my action class as follows: request.setAttribute("xFg",Boolean.TRUE); I want to retrive this in my JSP. I want to retrive them using JSTL tags. I tried this : <c:if test="${requestScope.xFg}"> <c:set var="showlist" value="true" /> </c:if> But c:if didnt work, i mean it didnt goto c:set I tried to print the sameusing c:out but nothing got displayed. What is wrong or How should i test request attribute value. I havent used requestScope so far. Is requestScope the option to get the request value? pls help.Thanks in advance.

    Read the article

  • JQuery: showing elements with a particular title

    - by Joe Smalley
    I am trying to show only elements that have the title attribute passed to the function: var selectservice = function(serviceStr) { $j("li.project").hide(); $j("li.project.attr('title').contains(serviceStr)").show(); }; I am not quite sure how to compare the title attribute to the passed string serviceStr? contains doesnt seem to work.

    Read the article

  • How to get HandleUnauthorizedRequest to return correct url?

    - by Jova
    I'm writing a custom AuthorizeAttribute which should redirect unauthorized users to the login page. My HandleUnauthorizedRequest method looks like this, protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext) { RouteValueDictionary returnRoute = new RouteValueDictionary(); returnRoute["controller"] = "Account"; returnRoute["action"] = "Login"; returnRoute["returnUrl"] = filterContext.HttpContext.Request.Url.AbsolutePath; filterContext.Result = new RedirectToRouteResult(returnRoute); } Unfortunately it's not working properly as the returning url looks like this, www.mydomain.com/?controller=Account&action=Login&returnUrl=%2FUser%2FEditProfile%2FUsername What is the reason for this and how do I correct it?

    Read the article

  • JSF command button attribute is transferred incorrectly

    - by Oleg Rybak
    I have following code in jsf page, backed by jsf managed bean <h:dataTable value="#{poolBean.pools}" var="item"> <h:column> <f:facet name="header"> <h:outputLabel value="Id"/> </f:facet> <h:outputText value="#{item.id}"/> </h:column> <h:column> <f:facet name="header"> <h:outputLabel value="Start Range"/> </f:facet> <h:inputText value="#{item.startRange}" required="true"/> </h:column> <h:column> <f:facet name="header"> <h:outputText value="End Range"/> </f:facet> <h:inputText value="#{item.endRange}" required="true"/> </h:column> <h:column> <f:facet name="header"> <h:outputText value="Pool type"/> </f:facet> <h:selectOneMenu value="#{item.poolType}" required="true"> <f:selectItems value="#{poolBean.poolTypesMenu}"/> </h:selectOneMenu> </h:column> <h:column> <f:facet name="header"/> <h:commandButton id="ModifyPool" actionListener="#{poolBean.updatePool}" image="img/update.gif" title="Modify Pool"> <f:attribute name="pool" value="#{item}"/> </h:commandButton> </h:column> </h:dataTable> This code fragment is dedicated to editing come collection of items. Each row of the table contains "edit" button that submits changed values of the row to the server. It has the item itself as an attribute. Submit is performed by calling actionListener method in the backing managed bean. This code runs correctly on Glassfish v 2.1 But when the server was updated to Glassfish v 2.1.1, the attribute stopped to be passed correctly. Instead of passing edited item (when we change the values in table row, we are actually changing the underlying object fields), the source item is submitted to server, i.e. the item that was previously given to the page. All the changes that were made on the page are discarded. I tried to update jsf version from 1.2_02 to 1.2_14 (we are using jsf RI), but it had no effect. Perhaps anyone came across the same problem? Any help and suggestions will be appreciated.

    Read the article

  • ASP.NET MVC 2 "value" in IsValid override in DataAnnotation attribute passed is null, when incorrect

    - by goldenelf2
    Hello to all! This is my first question here on stack overflow. i need help on a problem i encountered during an ASP.NET MVC2 project i am currently working on. I should note that I'm relatively new to MVC design, so pls bear my ignorance. Here goes : I have a regular form on which various details about a person are shown. One of them is "Date of Birth". My view is like this <div class="form-items"> <%: Html.Label("DateOfBirth", "Date of Birth:") %> <%: Html.EditorFor(m => m.DateOfBirth) %> <%: Html.ValidationMessageFor(m => m.DateOfBirth) %> </div> I'm using an editor template i found, to show only the date correctly : <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.DateTime?>"%> <%= Html.TextBox("", (Model.HasValue ? Model.Value.ToShortDateString() : string.Empty))%> I used LinqToSql designer to create my model from an sql database. In order to do some validation i made a partial class Person to extend the one created by the designer (under the same namespace) : [MetadataType(typeof(IPerson))] public partial class Person : IPerson { //To create buddy class } public interface IPerson { [Required(ErrorMessage="Please enter a name")] string Name { get; set; } [Required(ErrorMessage="Please enter a surname")] string Surname { get; set; } [Birthday] DateTime? DateOfBirth { get; set; } [Email(ErrorMessage="Please enter a valid email")] string Email { get; set; } } I want to make sure that a correct date is entered. So i created a custom DataAnnotation attribute in order to validate the date : public class BirthdayAttribute : ValidationAttribute { private const string _errorMessage = "Please enter a valid date"; public BirthdayAttribute() : base(_errorMessage) { } public override bool IsValid(object value) { if (value == null) { return true; } DateTime temp; bool result = DateTime.TryParse(value.ToString(), out temp); return result; } } Well, my problem is this. Once i enter an incorrect date in the DateOfBirth field then no custom message is displayed even if use the attribute like [Birthday(ErrorMessage=".....")]. The message displayed is the one returned from the db ie "The value '32/4/1967' is not valid for DateOfBirth.". I tried to enter some break points around the code, and found out that the "value" in attribute is always null when the date is incorrect, but always gets a value if the date is in correct format. The same ( value == null) is passed also in the code generated by the designer. This thing is driving me nuts. Please can anyone help me deal with this? Also if someone can tell me where exactly is the point of entry from the view to the database. Is it related to the model binder? because i wanted to check exactly what value is passed once i press the "submit" button. Thank you.

    Read the article

  • How should i organize authority code?

    - by acidzombie24
    I have users that fall into the following Not logged in Not Verified Verified Moderator Admin All code that only admin and moderators can access (like banning) is in ModeratorUser which inherits from verified which inherits from BaseUser. Some pages are accessible to all users such as public profiles. If a user is logged in he can leave a comment. To check this i use if (IsVerifiedUser). Now here is the problem. To avoid problems if a user is banned he is not recognized as a verified user. However in the rare case i need to know if he is verified i can use usertype & Verified. Should i not be doing this? I have a bunch of code in my VerifiedUser class and find i am moving tons of it to BaseUser. Is this something i help because a not logged in user can access the page? Should i handle the ban user in a different way and allow IsVerifiedUser to be true even if the user is banned?

    Read the article

  • JPA returning null for deleted items from a set

    - by Jon
    This may be related to my question from a few days ago, but I'm not even sure how to explain this part. (It's an entirely different parent-child relationship.) In my interface, I have a set of attributes (Attribute) and valid values (ValidValue) for each one in a one-to-many relationship. In the Spring MVC frontend, I have a page for an administrator to edit these values. Once it's submitted, if any of these fields (as <input> tags) are blank, I remove the ValidValue object like so: Set<ValidValue> existingValues = new HashSet<ValidValue>(attribute.getValidValues()); Set<ValidValue> finalValues = new HashSet<ValidValue>(); for(ValidValue validValue : attribute.getValidValues()) { if(!validValue.getValue().isEmpty()) { finalValues.add(validValue); } } existingValues.removeAll(finalValues); for(ValidValue removedValue : existingValues) { getApplicationDataService().removeValidValue(removedValue); } attribute.setValidValues(finalValues); getApplicationDataService().modifyAttribute(attribute); The problem is that while the database is updated appropriately, the next time I query for the Attribute objects, they're returned with an extra entry in their ValidValue set -- a null, and thus, the next time I iterate through the values to display, it shows an extra blank value in the middle. I've confirmed that this happens at the point of a merge or find, at the point of "Execute query ReadObjectQuery(entity.Attribute). Here's the code I'm using to modify the database (in the ApplicationDataService): public void modifyAttribute(Attribute attribute) { getJpaTemplate().merge(attribute); } public void removeValidValue(ValidValue removedValue) { ValidValue merged = getJpaTemplate().merge(removedValue); getJpaTemplate().remove(merged); } Here are the relevant parts of the entity classes: Entity @Table(name = "attribute") public class Attribute { @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "attribute") private Set<ValidValue> validValues = new HashSet<ValidValue>(0); } @Entity @Table(name = "valid_value") public class ValidValue { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "attr_id", nullable = false) private Attribute attribute; }

    Read the article

  • maxlength attribute of a text box from the DataAnnotations StringLength in MVC2

    - by Pervez Choudhury
    I am working on an MVC2 application and want to set the maxlength attributes of the text inputs. I have already defined the stringlength attribute on the Model object using data annotations and it is validating the length of entered strings correctly. I do not want to repeat the same setting in my views by setting the max length attribute manually when the model already has the information. Is there any way to do this? Code snippets below: From the Model: [Required, StringLength(50)] public string Address1 { get; set; } From the View: <%= Html.LabelFor(model => model.Address1) %> <%= Html.TextBoxFor(model => model.Address1, new { @class = "text long" })%> <%= Html.ValidationMessageFor(model => model.Address1) %> What I want to avoid doing is: <%= Html.TextBoxFor(model => model.Address1, new { @class = "text long", maxlength="50" })%> Is there any way to do this?

    Read the article

  • MSTest: Problems with DeploymentItem attribute

    - by Juri
    Hi, I'm currently maintaining an "old" system written in C#.net, removing some obsolete features and doing some refactoring. Thanks god, the previous guy wrote some unit tests (MSTests). I quite comfortable with JUnit tests, but didn't do yet much with MSTests. The test methods have a DeploymentItem attribute, specifying a text file which is parsed by the business logic method that is being tested and a 2nd DeploymentItem where just a path has been specified containing a bunch of TIF files that have to be deployed too. [TestMethod()] [DeploymentItem(@"files\valid\valid_entries.txt")] [DeploymentItem(@"files\tif\")] public void ExistsTifTest() { ... } The tests worked before, but now I had to change the names of the TIF files contained in the \files\tif directory. According to a rule, the TIF filenames have to match a certain pattern which is also checked by the ExistsTifTest() method. Now I had to change the filenames in order to adapt them to the new requirements and suddently the TIF files are no more being deployed as before. Can someone give me a hint why this happens or what may be the cause? The same thing happens also if I add a new text-file say "my2ndTest.txt" beside the "valid_entries.txt" in the \files\valid\ directory with the according DeploymentItem attribute on the test method. The file doesn't get deployed? I got the images now deployed by defining the deployment path directly in the testrunconfig, but I'd like to understand why these things happen or why for instance my new file "my2ndTest.txt" doesn't get deployed while the others do. Thanks a lot. Juri

    Read the article

  • jQuery attribute selector inside a jQuery object

    - by chifliiiii
    Im trying to set up a quicksand with multiple filters and the approach im taking in the following which im not sure if its the best. $filteredItems = $containerClone.find('.portfolio-item-marketing').filter(function(index){ if ( $filterA != 'all' && $filterB != 'all' ) { return jQuery(this).find('.portfolio-item-marketing[data-type~=' + $filterA + ']') || jQuery(this).find('.portfolio-item-marketing[data-type~=' + $filterB + ']'); } if ( $filterA != 'all' && $filterB == 'all' ) { return jQuery(this+'[data-type~='+$filterA+']') ; } if ( $filterA == 'all' && $filterB != 'all' ) { return jQuery(this).find('.portfolio-item-marketing[data-type~=' + $filterB + ']'); } if ( $filterA == 'all' && $filterB == 'all' ) { return jQuery(this).find('.portfolio-item-marketing'); } }); As you see in the code i tried 2 different methods ( First "if" and second "if" ). Im not sure if i can use find inside a filter but i also dont know how to get the attribute from the jQuery object. I can not use jQuery(this).attr('data-type') == $filterA Because the attribute maybe contain various filters .Thats why im trying to use jQuery "~=" Should i give up and end using a indexOf ?

    Read the article

  • Updating CoreData xcdatamodel file troubles - attribute type change

    - by San
    I noticed several questions related to this topic go unanswered. Is this such a gray area that nobody really understands it? Here is my problem: I am a midway in the development of my app and the app has never been used ouside of my iphone simulator.One of the attributes in my core data structure requires a type change.Since my app has never been used outside of my iPhone Simulator, I first deleted the sqlite file. Doubling the effort of this step, I also went into iPhone Simulator menu and selected "Reset Content and Settings...". Than, I edited the xcdatamodel file and changed the type of my attribute. I saved the file and exited. Without any other changes, I compiled. I expected it to fail because of my type change. It did not! After this, I assigned a value with new type to my attribute and it fails to compile?! Is there something else that I need to do for the change to take an effect? I would really, really appreciate an answer to my question. Thank you!

    Read the article

  • Correctly assigning value to a Core Data attribute with an integer data-type

    - by Gordon Fontenot
    I'm missing something here, and feeling like an idiot about it. I'm using a UIPickerView in my app, and I need to assign the row number to a 32-bit integer attribute for a Core Data object. To do this, I am using this method: -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { object.integerValue = row; } This is giving me a warning: warning: passing argument 1 of 'setIntegerValue:' makes pointer from integer without a cast What am I mixing up here? --Edit 1-- Ok, so I can get rid of the warning by changing the method to do the following: NSNumber *number = [NSNumber numberWithInteger:row]; object.integerValue = rating; However, I still get a value of 0 for object.integerValue if I use NSLog to print it out. object.integerValue has a max value of 5, so I print out number instead, and then I'm getting a number above 62,000,000. Which doesn't seem right to me, since there are 5 rows. If I NSLog the row variable, I get a number between 0 and 5. So why do I end up with a completely different number after casting the number to NSNumber? --Edit 2-- Ok, so I'm realizing that there is some fundamental idea that I don't understand. I now understand that the 60 million + number can be cast back to the correct 0-5 number by using integerValue. So, it seems my question is how can I save an integer between 0-5 to the attribute if the NSNumber that is returned is over 60 million? Do I need to be using a different data type?

    Read the article

  • validation properties by attribute

    - by netmajor
    I create class with two property - name,link(below). I use simple property validation by Required and StringLength attribute. I bind this class object to WPF ListBox(with textBoxs). But when I have textbox empty or write words longer than 8 sign nothing happens :/ What should I do to fires ErrorMessage? Or how to implement validation in other way ? I also try use : if (value is int) { throw new ArgumentException("Wpisales stringa!!"); } But it only fires in debug mode :/ My class with implementation of attribute validation: public class RssInfo : INotifyPropertyChanged { public RssInfo() { } public RssInfo(string _nazwa, string _link) { nazwa = _nazwa; link = _link; } private string nazwa; [Required(ErrorMessage = "To pole jest obowiazkowe nAZWA")] public string Nazwa { get { return nazwa; } set { if (value != nazwa) { nazwa = value; onPropertyChanged("Nazwa"); } if (value is int) { throw new ArgumentException("Wpisales stringa!!"); } } } private string link; [Required(ErrorMessage="To pole jest obowiazkowe link")] [StringLength(8, ErrorMessage = "Link cannot be longer than 8 characters")] public string Link { get { return link; } set { if (value != link) { link = value; onPropertyChanged("Link"); } } } #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; #endregion private void onPropertyChanged(string propertyName) { if (this.PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } }

    Read the article

  • Hudson plugin, Java error "... disagree on InnerClasses attribute"

    - by StackedCrooked
    I am trying to be able to step through the code of a Hudson plugin called SVNPublisher. I checked out the code for SVNPublisher, used Netbeans to open the project, and clicked "Debug Main project". This results in a Firefox window opening address http://localhost:8080 which shows the Hudson main page. Clicking the "New Job" link results in an error page: HTTP ERROR: 500 jar:file:/home/francis/svn/svnpublisher/target/work/webapp/WEB-INF/lib/hudson-core-1.319.jar!/lib/hudson/newFromList/form.jelly:43:47: <j:forEach> hudson.scm.SubversionTagAction and hudson.scm.SubversionTagAction$DescriptorImpl disagree on InnerClasses attribute RequestURI=/newJob Caused by: org.apache.commons.jelly.JellyTagException: jar:file:/home/francis/svn/svnpublisher/target/work/webapp/WEB-INF/lib/hudson-core-1.319.jar!/lib/hudson/newFromList/form.jelly:43:47: hudson.scm.SubversionTagAction and hudson.scm.SubversionTagAction$DescriptorImpl disagree on InnerClasses attribute at org.apache.commons.jelly.impl.TagScript.handleException(TagScript.java:713) at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:282) at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95) ... I am very new to Hudson and not very experienced with Java so I'm pretty much clueless on the meaning of this error. Can anyone help?

    Read the article

  • Rails: unable to set any attribute of child model

    - by Bryan Roth
    I'm having a problem instantiating a ListItem object with specified attributes. For some reason all attributes are set to nil even if I specify values. However, if I specify attributes for a List, they retain their values. Attributes for a List retain their values: >> list = List.new(:id => 20, :name => "Test List") => #<List id: 20, name: "Test List"> Attributes for a ListItem don't retain their values: >> list_item = ListItem.new(:id => 17, :list_id => 20, :name => "Test Item") => #<ListItem id: nil, list_id: nil, name: nil> UPDATE #1: I thought the id was the only attribute not retaining its value but realized that setting any attribute for a ListItem gets set to nil. list.rb: class List < ActiveRecord::Base has_many :list_items, :dependent => :destroy accepts_nested_attributes_for :list_items, :reject_if => lambda { |a| a[:name].blank? }, :allow_destroy => true end list_item.rb: class ListItem < ActiveRecord::Base belongs_to :list validates_presence_of :name end schema.rb ActiveRecord::Schema.define(:version => 20100506144717) do create_table "list_items", :force => true do |t| t.integer "list_id" t.string "name" t.datetime "created_at" t.datetime "updated_at" end create_table "lists", :force => true do |t| t.string "name" t.datetime "created_at" t.datetime "updated_at" end end

    Read the article

  • Virtual properties duplicated during serialization when XmlElement attribute used

    - by Laramie
    The Goal: XML serialize an object that contains a list of objects of that and its derived types. The resulting XML should not use the xsi:type attribute to describe the type, to wit the names of the serialized XML elements would be an assigned name specific to the derived type, not always that of the base class, which is the default behavior. The Attempt: After exploring IXmlSerializable and IXmlSerializable with eerie XmlSchemaProvider methods and voodoo reflection to return specialized schemas and an XmlQualifiedName over the course of days, I found I was able to use the simple [XmlElement] attribute to accomplish the goal... almost. The Problem: Overridden properties appear twice when serializing. The exception reads "The XML element 'overriddenProperty' from namespace '' is already present in the current scope. Use XML attributes to specify another XML name or namespace for the element." I attempted using a *Specified property (see code), but it didn't work. Sample Code: Class Declaration using System; using System.Collections.Generic; using System.Xml.Serialization; [XmlInclude(typeof(DerivedClass))] public class BaseClass { public BaseClass() { } [XmlAttribute("virt")] public virtual string Virtual { get; set; } [XmlIgnore] public bool VirtualSpecified { get { return (this is BaseClass); } set { } } [XmlElement(ElementName = "B", Type = typeof(BaseClass), IsNullable = false)] [XmlElement(ElementName = "D", Type = typeof(DerivedClass), IsNullable = false)] public List<BaseClass> Children { get; set; } } public class DerivedClass : BaseClass { public DerivedClass() { } [XmlAttribute("virt")] public override string Virtual { get { return "always return spackle"; } set { } } } Driver: BaseClass baseClass = new BaseClass() { Children = new List<BaseClass>() }; BaseClass baseClass2 = new BaseClass(){}; DerivedClass derivedClass1 = new DerivedClass() { Children = new List<BaseClass>() }; DerivedClass derivedClass2 = new DerivedClass() { Children = new List<BaseClass>() }; baseClass.Children.Add(derivedClass1); baseClass.Children.Add(derivedClass2); derivedClass1.Children.Add(baseClass2); I've been wrestling with this on and off for weeks and can't find the answer anywhere.

    Read the article

  • Can I do my own HTTP header attribute?

    - by wokena
    Hi, can I make my own headers in HTTP request? e.g. This is normal HTTP request GET / HTTP/1.1 Host: google.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT x.x; xx; rv:x.x.x.x) xxx Firefox/3.0.10 (.NET CLR 3.5.30729) Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: xx,en-us;q=0.7,en;q=0.3 Accept-Encoding: gzip,deflate Accept-Charset: windows-1250,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive and this is header with my "attribute" GET / HTTP/1.1 Host: google.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT x.x; xx; rv:x.x.x.x) xxx Firefox/3.0.10 (.NET CLR 3.5.30729) Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: xx,en-us;q=0.7,en;q=0.3 Accept-Encoding: gzip,deflate Accept-Charset: windows-1250,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Name: John and I will have "attribute" in server response. I'll use "attrubutes" in HTTP headers instead of sessions attributes... BTW.Sorry for my english... ;)

    Read the article

  • Spring bean's DESTROY-METHOD attribute and web-application "prototype"d bean

    - by EugeneP
    Can get work the attribute "destroy-method". First, even if I type non-existing method name into "destroy-method" attribute, Spring initialization completes fine (already strange!). Next, when a bean has a "prototype" scope, then I suppose it must be destroyed before the application is closed. That not happens, it is simply never called in my case. Though, after extracting this bean I can call this method explicitly and it does its job. Could you explain why this method is never called in my Spring 2.5 case? p.s. The method exists, it is public and has no arguments. It seems to be a more difficult task then I thought. The problem is that this destroy method is called whenever the context is closed, and this is a rare case. My question is this: I have a web app. I have a "prototype"-scoped bean. What I need is when the current session is closed, this destroy method was automatically called by Spring. I can do it by hand, but is there any solution how to make Spring do this job? It destroys the bean after the session is destroyed, it might be possible for Spring to call a method on that bean before destroying it?

    Read the article

  • Use Lambda in Attribute constructor to get method's parameters

    - by Anthony Shaw
    I'm not even sure if this is possible, but I've exhausted all of my ideas trying to figure this out, so I figured I'd send this out to the community and see what you thought. And, if it's not possible, maybe you'd have some ideas as well. I'm trying to make an Attribute class that I can add to a method that would allow me to use a lambda expression to get each parameter of the method public ExampleAttribute : Attribute { public object Value { get; set; } public ExampleAttribute(--something here to make the lambda work--, object value) { Value = value; } } I'd like to be able to something like this below: [Example(x=x.Id, 4)] [Example(x=x.filter, "string value")] public ActionResult Index(int Id, string filter) { return View(); } I understand that I might be completely dreaming with this idea. I'm basically trying to write a model to allow for self-documenting REST API Documentation. In a recent project here at work we wrote a dozen or so services with 5 to 15 methods on each, I figure it's easier to write something to do this, than to hand code a documentation page for each. I would plan to eventually release this as an open-source project once I have it in a place that I feel it's releasable.

    Read the article

  • MVC3 custom validation attribute for an "at least one is required" situation

    - by Pricey
    Hi I have found this answer already: MVC3 Validation - Require One From Group Which is fairly specific to the checking of group names and uses reflection. My example is probably a bit simpler and I was just wondering if there was a simpler way to do it. I have the below: public class TimeInMinutesViewModel { private const short MINUTES_OR_SECONDS_MULTIPLIER = 60; //public string Label { get; set; } [Range(0,24, ErrorMessage = "Hours should be from 0 to 24")] public short Hours { get; set; } [Range(0,59, ErrorMessage = "Minutes should be from 0 to 59")] public short Minutes { get; set; } /// <summary> /// /// </summary> /// <returns></returns> public short TimeInMinutes() { // total minutes should not be negative if (Hours <= 0 && Minutes <= 0) { return 0; } // multiplier operater treats the right hand side as an int not a short int // so I am casting the result to a short even though both properties are already short int return (short)((Hours * MINUTES_OR_SECONDS_MULTIPLIER) + (Minutes * MINUTES_OR_SECONDS_MULTIPLIER)); } } I want to add a validation attribute either to the Hours & Minutes properties or the class itself.. and the idea is to just make sure at least 1 of these properties (Hours OR minutes) has a value, server and client side validation using a custom validation attribute. Does anyone have an example of this please? Thanks

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >