If I wanted to save a contact form submission to the database, how can I insert the form scope in as the submission? It's been some time since I used Coldfusion.
The contact forms vary depending on what part of the site it was submitted from, so it needs to scale and handle a form with 5 fields or one with 10 fields. I just want to store the data in a blob table.
In Java is there an equivalent to the C# "using" statement allowing to define a scope for an object:
using (AwesomeClass hooray = new AwesomeClass)
{
// Great code
}
This has probably allready been asked but the keywords make it difficult to find a relevant question.
I like using sentry classes in c++, but I seem to have a mental affliction that results in repeatedly writing bugs like the following:
{
MySentryClass(arg);
// ... other code
}
Needless to say, this fails because the sentry dies immediately after creation, rather than at the end of the scope, as intended. Is there some way to prevent MySentryClass from being instantiated as a temporary, so that the above code either fails to compile, or at least aborts with an error message at runtime?
If I load the following URL in Firefox and login to Facebook, I'm getting a page displaying "An invalid next or cancel parameter was specified."
https://graph.facebook.com/oauth/authorize?client_id=c8caf78d724d142ee82334131ef5c9ce&redirect_uri=http://www.facebook.com/connect/login_success.html&type=user_agent&display=touch&scope=offline_access,publish_stream
But if I change the display parameter to display=page I no longer get this error. Any ideas as to why?
In php we use includes. So variables defined in one file and then their scope spans included files too.
Zend studio has no idea how to get the type of the variable I am using inside an included file, this is very annoying when the variable type is a big class.
Is there a way to hint the ide about variable types? in included files?
in jsf2.0 is it possible to propagate the viewscope to new popup window,
so that if new url is opened as model popup it should get the value from same managed bean.
i tried by passing parent page's javax.faces.ViewState as url parameter to model popup page but getting viewexpired exception with this.
i dont want to use session scope, is there any other solution?
Recently I created a spike of a view engine, in which views are plain classes, and the content is created by using funny using-scope blocks.
The code together with a simple sample site is available at http://code.google.com/p/sharp-view-engine/
Here I'd like to hear your opinions regarding such an idea. Is it completely weird or maybe someone likes it?
I have a UserControl in which a FlowLayoutPanel.
This user control consist of a description and some controls:
[descr.] 123456789, it should be able to be reversed 987654321 [descr.]
So FlowLayoutPanel is used for this scope(RightToLeft - True/False).
Is this a way that the label1 fill the rest of the control(to left or right respectively)?
Are there any formal techniques for refactoring SQL similar to this list here that is for code?
I am currently working on a massive query for a particular report and I'm sure there's plenty of scope for refactoring here which I'm just stumbling through myself bit by bit.
I'm playing with Objective-C Distributed Objects and I'm having some problems understanding how memory management works under the system. The example given below illustrates my problem:
Protocol.h
#import <Foundation/Foundation.h>
@protocol DOServer
- (byref id)createTarget;
@end
Server.m
#import <Foundation/Foundation.h>
#import "Protocol.h"
@interface DOTarget : NSObject
@end
@interface DOServer : NSObject < DOServer >
@end
@implementation DOTarget
- (id)init
{
if ((self = [super init]))
{
NSLog(@"Target created");
}
return self;
}
- (void)dealloc
{
NSLog(@"Target destroyed");
[super dealloc];
}
@end
@implementation DOServer
- (byref id)createTarget
{
return [[[DOTarget alloc] init] autorelease];
}
@end
int main()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
DOServer *server = [[DOServer alloc] init];
NSConnection *connection = [[NSConnection new] autorelease];
[connection setRootObject:server];
if ([connection registerName:@"test-server"] == NO)
{
NSLog(@"Failed to vend server object");
}
else
[[NSRunLoop currentRunLoop] run];
[pool drain];
return 0;
}
Client.m
#import <Foundation/Foundation.h>
#import "Protocol.h"
int main()
{
unsigned i = 0;
for (; i < 3; i ++)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
id server = [NSConnection rootProxyForConnectionWithRegisteredName:@"test-server"
host:nil];
[server setProtocolForProxy:@protocol(DOServer)];
NSLog(@"Created target: %@", [server createTarget]);
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];
[pool drain];
}
return 0;
}
The issue is that any remote objects created by the root proxy are not released when their proxy counterparts in the client go out of scope. According to the documentation:
When an object’s remote proxy is deallocated, a message is sent back to the receiver to notify it that the local object is no longer shared over the connection.
I would therefore expect that as each DOTarget goes out of scope (each time around the loop) it's remote counterpart would be dellocated, since there is no other reference to it being held on the remote side of the connection.
In reality this does not happen: the temporary objects are only deallocate when the client application quits, or more accurately, when the connection is invalidated. I can force the temporary objects on the remote side to be deallocated by explicitly invalidating the NSConnection object I'm using each time around the loop and creating a new one but somehow this just feels wrong.
Is this the correct behaviour from DO? Should all temporary objects live as long as the connection that created them? Are connections therefore to be treated as temporary objects which should be opened and closed with each series of requests against the server?
Any insights would be appreciated.
I'm trying to decide between two ways of instantiating an object & handling any constructor exceptions for an object that is critical to my program, i.e. if construction fails the program can't continue.
I have a class SimpleMIDIOut that wraps basic Win32 MIDI functions. It will open a MIDI device in the constructor and close it in the destructor. It will throw an exception inherited from std::exception in the constructor if the MIDI device cannot be opened.
Which of the following ways of catching constructor exceptions for this object would be more in line with C++ best practices
Method 1 - Stack allocated object, only in scope inside try block
#include <iostream>
#include "simplemidiout.h"
int main()
{
try
{
SimpleMIDIOut myOut; //constructor will throw if MIDI device cannot be opened
myOut.PlayNote(60,100);
//.....
//myOut goes out of scope outside this block
//so basically the whole program has to be inside
//this block.
//On the plus side, it's on the stack so
//destructor that handles object cleanup
//is called automatically, more inline with RAII idiom?
}
catch(const std::exception& e)
{
std::cout << e.what() << std::endl;
std::cin.ignore();
return 1;
}
std::cin.ignore();
return 0;
}
Method 2 - Pointer to object, heap allocated, nicer structured code?
#include <iostream>
#include "simplemidiout.h"
int main()
{
SimpleMIDIOut *myOut;
try
{
myOut = new SimpleMIDIOut();
}
catch(const std::exception& e)
{
std::cout << e.what() << std::endl;
delete myOut;
return 1;
}
myOut->PlayNote(60,100);
std::cin.ignore();
delete myOut;
return 0;
}
I like the look of the code in Method 2 better, don't have to jam my whole program into a try block, but Method 1 creates the object on the stack so C++ manages the object's life time, which is more in tune with RAII philosophy isn't it?
I'm still a novice at this so any feedback on the above is much appreciated. If there's an even better way to check for/handle constructor failure in a siatuation like this please let me know.
I've found many definitions of the 'var' statement but most of them are incomplete (usually from introductory guides/tutorials). Should I use 'var' if the variable & scope has been declared in the params list?
someFunc = function(someVar)
{
// Is it considered good practice to use 'var', even if it is redundant?
var someVar = cheese;
};
I need to include several stored procedure in a single transaction in a single database,
if any of stored procedure fail then roll back transaction of all stored procedure procesed in the scope.
I work with SQL-SERVER 2008
What i did:
create a project,
edited the ui file with the designer tool,
ran the project, everything is ok
tried to add to my cppfile:
connect( pushButton_bracketBegin, SIGNAL( clicked() ), this, SLOT( pushButton_bracketBeginAction() ) );
but i get the error "‘pushButton_bracketBegin’ was not declared in this scope". this is my first project in qt and it should be fairly simple i guess (but yet out of my grasp ) :) appreciate the help
Hi All,
i am reading spring through its official documentation and at one place i came to a line that use prototype scope for for all statefull beans while singleton for stateless beans.
i know there is something as statefull as well stateless beans in EJB but this is not what they have mentioned in the documents.
Can any one explain me what exact this means of statefull as well stateless beans in Spring
Thanks in advance
What is the memory and performance usage compared to creating a object with only a constructor?
The usage here is in creating a Set<Object> or List<Object> that may contain million plus entries and I am concerned with the overhead of using Bloch's Builder Pattern. I have used it in the past, but never in this large of a scope.
Hello,
I am returning the variable I am creating in a using statement inside the using statement (sounds funny):
public DataTable foo ()
{
using (DataTable properties = new DataTable())
{
// do something
return properties;
}
}
Will this Dispose the properties variable??
After doing this am still getting this Warning:
Warning 34 CA2000 : Microsoft.Reliability : In method 'test.test', call System.IDisposable.Dispose on object 'properties' before all references to it are out of scope.
Any Ideas?
Thanks
This shows how to have a static variable inside an object or context:
http://www.mail-archive.com/[email protected]/msg04764.html
But the scope is too large for some needs, is it possible to have a static variable inside an object function ?
After completing a XHTML , CSS project , and Even client is happy, should I try to optimize my HTML, CSS code if there is any scope?
If yes then how to more improve and optimize code and what things can/should be optimized?
Should i optimize to get lowest file size or i should optimize code for better readability?
Everything seems to work fine until i want to submit the form and update the database.
Wildcard mapping works on requests like "/navigation/edit/1", but when i submit the form as:
var ajaxPost = function(Url, Params) {
Ext.Ajax.request({
url: Url,
params: Params,
method: 'POST',
async: false,
scope: this
});
};
it says "200 bad response: syntax error" and in firebug there is "Failed to load source for: http://.../Navigation/edit/1".
Any help?
I always thought that varibales are mapped to stack locations once your Java source is compiled; additionally, they may include the info about the variable names and their scope in classfiles, but that's optional AFAIK.
The question is - how do my Eclipse/IDEA IDEs allow me to set a watch expression containing the local variable name? To me, it's hard to understand :)