Write only property in Objective-C

Another valid approach is to declare the normal property and make the getter unavailable @interface MyClass @property NSString * var; – (NSString *)var UNAVAILABLE_ATTRIBUTE; @end This will raise a compile-time error in case someone tries to access the getter. The main advantage of this approach is that you actually have a real propertyTM and not … Read more

.NET Dictionary as a Property

Here’s a quick example class Example { private Dictionary<int,string> _map; public Dictionary<int,string> Map { get { return _map; } } public Example() { _map = new Dictionary<int,string>(); } } Some use cases var e = new Example(); e.Map[42] = “The Answer”;

Variable does not exist in the current context while debugging

It’s possible the local variables have been optimised away by the JIT compiler. Since you’re using Visual Studio you might be able to switch the configuration to Debug and rebuild. If not, you can configure the JIT compiler to disable optimisations and generate tracking information – see here on how to set the configuration. This … Read more

Spring 3.0.5 doesn’t evaluate @Value annotation from properties

Found what the issue was. Copy/paste from comments: Are you sure you have <context:property-placeholder> in the same application context as your MyClass bean (not in the parent context)? – axtavt You’re right. I moved <context:property-placeholder> from the context defined by the ContextLoaderListener to the servlet context. Now my values get parsed. Thanks a lot! – … Read more

Configure Tomcat to use properties file to load DB connection information

We often distribute webapps by providing a WAR, and a Context XML file, which gets placed into your tomcat/conf/Catalina/localhost directory, and can load the webapp from any path. There is a reference document here. This provides the following advantages: Context parameters can be configured here and read by the webapp DataSources can be defined and … Read more

Load environment-specific properties for use with PropertyPlaceholderConfigurer?

Essentially you have a finished JAR which you want to drop into another environment, and without any modification have it pick up the appropriate properties at runtime. If that is correct, then the following approaches are valid: 1) Rely on the presence of a properties file in the user home directory. Configure the PropertyPlaceholderConfigurer to … Read more

View all fields / properties of bean in JSP / JSTL

Replace object with the bean to determine. <c:set var=”object” value=”${product}” /> Display all declared fields and their values. <c:if test=”${not empty object[‘class’].declaredFields}”> <h2>Declared fields <em>&dollar;{object.name}</em></h2> <ul> <c:forEach var=”field” items=”${object[‘class’].declaredFields}”> <c:catch><li><span style=”font-weight: bold”> ${field.name}: </span>${object[field.name]}</li> </c:catch> </c:forEach> </ul> </c:if> Display all declared methods. <c:if test=”${not empty object[‘class’].declaredMethods}”> <h2>Declared methods<em>&lt;% object.getName() %&gt;</em></h2> <ul> <c:forEach var=”method” items=”${object[‘class’].declaredMethods}”> <c:catch><li>${method.name}</li></c:catch> … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)