Search Results

Search found 10634 results on 426 pages for 'pass'.

Page 61/426 | < Previous Page | 57 58 59 60 61 62 63 64 65 66 67 68  | Next Page >

  • How should I pass the translated text to my object in my multilingual application?

    - by boatingcow
    Up until now, I have maintained a 'dictionary' table in my database, for example: +-----------+---------------------------------------+-----------------------------------------------+--------+ | phrase | en | fr | etc... | +-----------+---------------------------------------+-----------------------------------------------+--------+ | generated | Generated in %1$01.2f seconds at %2$s | Créée en %1$01.2f secondes à %2$s aujourd'hui | ... | | submit | Submit... | Envoyer... | ... | +-----------+---------------------------------------+-----------------------------------------------+--------+ I'll then select all rows from the database for the column that matches the locale we're interested in (or read the cache from a file to speed db lookup) and dump the dictionary into an array called $lng. Then I'll have HTML helper objects like this in my view: $html->input(array('type' => 'submit', 'value' => $lng['submit'], etc...)); ... $html->div(array('value' => sprintf($lng['generated'], $generated, date('H:i')), etc...)); The translations can appear in PDF, XLS and AJAX responses too. The problem with my approach so far is that I now have loads of global $lng; in every class where there is a function that spits out UI code.. How do other people get the translation into the object? Is it one scenario where globals aren't actually that bad? Would it be madness to create a class with accessors when the dictionary terms are all static?

    Read the article

  • How do I pass a DBNull value to a parameterized SELECT statement?

    - by Dan
    I have a SQL statement in C# (.NET Framework 4 running against SQL Server 2k8) that looks like this: SELECT [Column1] FROM [Table1] WHERE [Column2] = @Column2 The above query works fine with the following ADO.NET code: DbParameter parm = Factory.CreateDbParameter(); parm.Value = "SomeValue"; parm.ParameterName = "@Column2"; //etc... This query returns zero rows, though, if I assign DBNull.Value to the DbParameter's Value member even if there are null values in Column2. If I change the query to accommodate the null test specifically: SELECT [Column1] FROM [Table1] WHERE [Column2] IS @Column2 I get an "Incorrect syntax near '@Column2'" exception at runtime. Is there no way that I can use null or DBNull as a parameter in the WHERE clause of a SELECT statement?

    Read the article

  • How to pass content in response from Exception filter in Asp.net WebAPI?

    - by jaffa
    Consider following code: My problem is: 1) I can't seem to cast the errors to HttpContent 2) I can't use the CreateContent extension method as this doesn't exist on the context.Response.Content.CreateContent public class ServiceLayerExceptionFilter : ExceptionFilterAttribute { public override void OnException(HttpActionExecutedContext context) { if (context.Response == null) { var exception = context.Exception as ModelValidationException; if ( exception != null ) { var modelState = new ModelStateDictionary(); modelState.AddModelError(exception.Key, exception.Description); var errors = modelState.SelectMany(x => x.Value.Errors).Select(x => x.ErrorMessage); // Cannot cast errors to HttpContent?? // var resp = new HttpResponseMessage(HttpStatusCode.BadRequest) {Content = errors}; // throw new HttpResponseException(resp); // Cannot create response from extension method?? //context.Response.Content.CreateContent } else { context.Response = new HttpResponseMessage(context.Exception.ConvertToHttpStatus()); } } base.OnException(context); } }

    Read the article

  • Is it okay to pass injected EntityManagers to EJB bean's helper classes and use it?

    - by Zwei steinen
    We have some JavaEE5 stateless EJB bean that passes the injected EntityManager to its helpers. Is this safe? It has worked well until now, but I found out some Oracle document that states its implementation of EntityManager is thread-safe. Now I wonder whether the reason we did not have issues until now, was only because the implementation we were using happened to be thread-safe (we use Oracle). @Stateless class SomeBean { @PersistenceContext private EntityManager em; private SomeHelper helper; @PostConstruct public void init(){ helper = new SomeHelper(em); } @Override public void business(){ helper.doSomethingWithEm(); } } Actually it makes sense.. If EntityManager is thread-unsafe, a container would have to do inercept business() this.em = newEntityManager(); business(); which will not propagate to its helper classes. If so, what is the best practice in this kind of a situation? Passing EntityManagerFactory instead of EntityManager?

    Read the article

  • I'm trying to pass a string from my first ViewController to my second ViewController but it returns NULL

    - by Dashony
    In my first view controller I have 3 input fields each of them take the user input into and saves it into a string such as: address, username and password as NSUserDefaults. This part works fine. In my second view controller I'm trying to take the 3 strings from first controller (address, username and password) create a html link based on the 3 strings. I've tried many ways to access the 3 strings with no luck, the result I get is NULL. Here is my code: //.h file - first view controller with the 3 input fields CamSetup.h #import <UIKit/UIKit.h> @interface CamSetup : UIViewController <UITextFieldDelegate> { NSString * address; NSString * username; NSString * password; IBOutlet UITextField * addressField; IBOutlet UITextField * usernameField; IBOutlet UITextField * passwordField; } -(IBAction) saveAddress: (id) sender; -(IBAction) saveUsername: (id) sender; -(IBAction) savePassword: (id) sender; @property(nonatomic, retain) UITextField *addressField; @property(nonatomic, retain) UITextField *usernameField; @property(nonatomic, retain) UITextField *passwordField; @property(nonatomic, retain) NSString *address; @property(nonatomic, retain) NSString *username; @property(nonatomic, retain) NSString *password; @end //.m file - first view controller CamSetup.m #import "CamSetup.h" @interface CamSetup () @end @implementation CamSetup @synthesize addressField, usernameField, passwordField, address, username, password; -(IBAction) saveAddress: (id) sender { address = [[NSString alloc] initWithFormat:addressField.text]; [addressField setText:address]; NSUserDefaults *stringDefaultAddress = [NSUserDefaults standardUserDefaults]; [stringDefaultAddress setObject:address forKey:@"stringKey1"]; NSLog(@"String [%@]", address); } -(IBAction) saveUsername: (id) sender { username = [[NSString alloc] initWithFormat:usernameField.text]; [usernameField setText:username]; NSUserDefaults *stringDefaultUsername = [NSUserDefaults standardUserDefaults]; [stringDefaultUsername setObject:username forKey:@"stringKey2"]; NSLog(@"String [%@]", username); } -(IBAction) savePassword: (id) sender { password = [[NSString alloc] initWithFormat:passwordField.text]; [passwordField setText:password]; NSUserDefaults *stringDefaultPassword = [NSUserDefaults standardUserDefaults]; [stringDefaultPassword setObject:password forKey:@"stringKey3"]; NSLog(@"String [%@]", password); } - (void)viewDidLoad { [addressField setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"stringKey1"]]; [usernameField setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"stringKey2"]]; [passwordField setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"stringKey3"]]; [super viewDidLoad]; } @end //.h second view controller LiveView.h #import <UIKit/UIKit.h> #import "CamSetup.h" @interface LiveView : UIViewController { NSString *theAddress; NSString *theUsername; NSString *thePassword; CamSetup *camsetup; //here is an instance of the first class } @property (nonatomic, retain) NSString *theAddress; @property (nonatomic, retain) NSString *theUsername; @property (nonatomic, retain) NSString *thePassword; @end //.m second view LiveView.m file #import "LiveView.h" @interface LiveView () @end @implementation LiveView @synthesize theAddress, theUsername, thePassword; - (void)viewDidLoad { [super viewDidLoad]; theUsername = camsetup.username; //this is probably not right? NSLog(@"String [%@]", theUsername); //resut here is NULL NSLog(@"String [%@]", camsetup.username); //and here NULL as well } @end

    Read the article

  • ASP.NET MVC2 - specific fields in form pass via a specific object?

    - by ile
    In database I have Contacts table: ContactID (int) FirstName (varchar) LastName (varchar) ... XmlFields (xml) // This field is xml type To create a new contact, I created two classes - one for regular fields and other to display fields from XmlFields field. In Controller, I have following: public ActionResult Create(Contact contact, FormCollection collection) ... Regular field I catch with contact object and those that need to be stored as xml in XmlFields I try to catch with collection object. Problem is that collection object catches all fields, so I wonder if it is possible to isolate xml fields when posting to a specific object so that I can easily manipulate with them. I need this in separated objects because these xml fields are going to be generated dynamically and will be different for every user. Thanks in advance, Ile

    Read the article

  • How do I pass the value of the previous form element into an "onchange" javascript function?

    - by Jen
    Hello, I want to make some UI improvements to a page I am developing. Specifically, I need to add another drop down menu to allow the user to filter results. This is my current code: HTML file: <select name="test_id" onchange="showGrid(this.name, this.value, 'gettestgrid')"> <option selected>Select a test--></option> <option value=1>Test 1</option> <option value=2>Test 2</option> <option value=3>Test 3</option> </select> This is pseudo code for what I want to happen: <select name="test_id"> <option selected>Select a test--></option> <option value=1>Test 1</option> <option value=2>Test 2</option> <option value=3>Test 3</option> </select> <select name="statistics" onchange="showGrid(PREVIOUS.name, PREVIOUS.VALUE, THIS.value)"> <option selected>Select a data display --></option> <option value='gettestgrid'>Show averages by student</option> <option value='gethomeroomgrid'>Show averages by homeroom</option> <option value='getschoolgrid'>Show averages by school</option> </select> How do I access the previous field's name and value? Any help much appreciated, thx! Also, JS function for reference: function showGrid(name, value, phpfile) { xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Browser does not support HTTP Request"); return; } var url=phpfile+".php"; url=url+"?"+name+"="+value; url=url+"&sid="+Math.random(); xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(null); }

    Read the article

  • How to implement parent-child windows and pass values from child to parent?

    - by Andrew
    I am working on an ASP.NET MVC 2 application. In one of my data entry forms, I have an "employer" field which has a "search" link next to it. When a user clicks on this link, another window is opened with a search form. The user uses the search form to search for the correct employer. A list of employers is shown to the user. Currently, the user has to then copy and paste the correct employer from the child window into the original window. I want to implement it so that each employer search result in the child window is a hyperlink. The user would then click on the correct employer and then the correct employer value would be populated in the original parent window employer field. How would I go about implementing this in ASP.NET MVC 2?

    Read the article

  • MySQL & PHP: auto connect to DB or to properly way to pass host/db to MySQL methods

    - by SODA
    Hi, does anyone know of a known method in PHP to auto connect to MySQL db/table in case an app is using multiple databases on multiple hosts? Question 1: are there scripts around that allow to auto connect to necessary host/DB based on query? Question 2: if above is not possible, is there a known approach to properly passing host/DB info to make sure app is properly connected before executing the query?

    Read the article

  • asp mvc: how to pass parameter to controller using jquery api?

    - by Grayson Mitchell
    I am following the following tutorial (http://www.highoncoding.com/Articles/642_Creating_a_Stock_Widget_in_ASP_NET_MVC_Application.aspx) on using ajax to render a partial form , but in this example parameters are not passed, and I have not been able to work out how to do it... This code works with no parameter function GetDetails() { $("#divDetails").load('Details'); } This is my attempt to add a parameter, but does not work (cant find action) function GetDetails() { $("#divDetails").load('Details?Id=20'); }

    Read the article

  • How do I pass a function to NUnit Throws.Constraints?

    - by Serge Belov
    I'm trying to write some NUnit tests in F# and having trouble passing a function to the ThrowsConstraint. A distilled (non)working sample is below. open System.IO open NUnit.Framework [<TestFixture>] module Example = [<Test>] let foo() = let f = fun () -> File.GetAttributes("non-existing.file") Assert.That(f, Throws.TypeOf<FileNotFoundException>()) This compiles just fine but I get the following from the NUnit test runner: FsTest.Tests.Example.foo: System.ArgumentException : The actual value must be a TestDelegate but was f@11 Parameter name: actual While I'm able to work around the problem using ExpectedException attribute, my question is what is the correct way of using an F# function in this situation?

    Read the article

  • using a Singleton to pass credentials in a multi-tenant application a code smell?

    - by Hans Gruber
    Currently working on a multi-tenant application that employs Shared DB/Shared Schema approach. IOW, we enforce tenant data segregation by defining a TenantID column on all tables. By convention, all SQL reads/writes must include a Where TenantID = '?' clause. Not an ideal solution, but hindsight is 20/20. Anyway, since virtually every page/workflow in our app must display tenant specific data, I made the (poor) decision at the project's outset to employ a Singleton to encapsulate the current user credentials (i.e. TenantID and UserID). My thinking at the time was that I didn't want to add a TenantID parameter to each and every method signature in my Data layer. Here's what the basic pseudo-code looks like: public class UserIdentity { public UserIdentity(int tenantID, int userID) { TenantID = tenantID; UserID = userID; } public int TenantID { get; private set; } public int UserID { get; private set; } } public class AuthenticationModule : IHttpModule { public void Init(HttpApplication context) { context.AuthenticateRequest += new EventHandler(context_AuthenticateRequest); } private void context_AuthenticateRequest(object sender, EventArgs e) { var userIdentity = _authenticationService.AuthenticateUser(sender); if (userIdentity == null) { //authentication failed, so redirect to login page, etc } else { //put the userIdentity into the HttpContext object so that //its only valid for the lifetime of a single request HttpContext.Current.Items["UserIdentity"] = userIdentity; } } } public static class CurrentUser { public static UserIdentity Instance { get { return HttpContext.Current.Items["UserIdentity"]; } } } public class WidgetRepository: IWidgetRepository{ public IEnumerable<Widget> ListWidgets(){ var tenantId = CurrentUser.Instance.TenantID; //call sproc with tenantId parameter } } As you can see, there are several code smells here. This is a singleton, so it's already not unit test friendly. On top of that you have a very tight-coupling between CurrentUser and the HttpContext object. By extension, this also means that I have a reference to System.Web in my Data layer (shudder). I want to pay down some technical debt this sprint by getting rid of this singleton for the reasons mentioned above. I have a few thoughts on what an better implementation might be, but if anyone has any guidance or lessons learned they could share, I would be much obliged.

    Read the article

  • Pass HTML form entries into a Javascript array to then be written to a client side cookie?

    - by Tom
    I'm building a bit of a test-case JS application, something very basic, but have run into some problems. I'm trying to use a HTML form for a user to enter a number, which is then written to a Javascript Array. The user then has the option to write that same array to a local (client side) cookie. (I understand the security implications of this - it's a test-case and not for commercial use.) However, I can't make the connection - how can I capture the HTML entry, press 'submit' which will send it to a JS array, where the user can then press a different 'submit' which will write the array to a text file? If anyone can help I'd appreciate it because it's been nearly 6 hours and it's not funny anymore.

    Read the article

  • Pass Types as arguments to a function in Haskell?

    - by Charles Peng
    The following two functions are extremely similar. They read from a [String] n elements, either [Int] or [Float]. How can I factor the common code out? I don't know of any mechanism in Haskell that supports passing types as arguments. readInts n stream = foldl next ([], stream) [1..n] where next (lst, x:xs) _ = (lst ++ [v], xs) where v = read x :: Int readFloats n stream = foldl next ([], stream) [1..n] where next (lst, x:xs) _ = (lst ++ [v], xs) where v = read x :: Float I am at a beginner level of Haskell, so any comments on my code are welcome.

    Read the article

  • Pass information to php file from javascript while restricting user from doing it their self?

    - by Sean Madigan
    I am making a game where the battle system uses javascript to battle. At the end of the battle you either win or lose. If the user wins, I need to update the mysql database with the XP they earned. The best way I can think of doing this is to have the javascript run an ajax function when the user wins that POSTs something like addxp.php?amount=235, but if I do that then the user can easilly look at the source and see that they can just enter in that page themself to update their xp without battling. But this is the only way I know how to do it? Help please :-/

    Read the article

  • Sencha : how to pass parameter to php using Ext.data.HttpProxy?

    - by Lauraire Jérémy
    I have successfully completed this great tutorial : http://www.sencha.com/learn/ext-js-grids-with-php-and-sql/ I just can't use the baseParams field specified with the proxy... Here is my code that follows tutorial description : __ My Store : Communes.js ____ Ext.define('app.store.Communes', { extend: 'Ext.data.Store', id: 'communesstore', requires: ['app.model.Commune'], config: { model: 'app.model.Commune', departement:'var', // the proxy with POST method proxy: new Ext.data.HttpProxy({ url: 'app/php/communes.php', // File to connect to method: 'POST' }), // the parameter passed to the proxy baseParams:{ departement: "VAR" }, // the JSON parser reader: new Ext.data.JsonReader({ // we tell the datastore where to get his data from rootProperty: 'results' }, [ { name: 'IdCommune', type: 'integer' }, { name: 'NomCommune', type: 'string' } ]), autoLoad: true, sortInfo:{ field: 'IdCommune', direction: "ASC" } } }); _____ The php file : communes.php _____ <?php /** * CREATE THE CONNECTION */ mysql_connect("localhost", "root", "pwd") or die("Could not connect: " . mysql_error()); mysql_select_db("databasename"); /** * INITIATE THE POST */ $departement = 'null'; if ( isset($_POST['departement'])){ $departement = $_POST['departement']; // Get this from Ext } getListCommunes($departement); /** * */ function getListCommunes($departement) { [CODE HERE WORK FINE : just a connection and query but $departement is NULL] } ?> There is no parameter passed as POST method... Any idea?

    Read the article

  • How to pass a class method as an argument for another function in C++ and openGL?

    - by tsubasa
    I know this thing works: void myDisplay() { ... } int main() { ... glutDisplayFunc(myDisplay) ... } so I tried to include myDisplay() function to a class that I made. Because I want to overload it in the future with a different class. However, the compiler complains that argument of type 'void (ClassBlah::)()' does not match 'void(*)()' . Here is the what I try to make: class ClassBlah { .... void myDisplay() .... } ...... int main() { ... ClassBlah blah glutDisplayFunc(blah.myDisplay) ... } Does anybody knows how to fix this problem? Many thanks.

    Read the article

  • How to pass a variable to an awk print parameter...

    - by Jamie
    I'm trying extract the nth + 1 and nth + 3 columns from a file. This is what tried, which is a useful pseudo code: for i in {1..100} ; do awk -F "," " { printf \"%3d, %12.3f, %12.3f\\n\", \$1, \$($i+1), \$($i+3) } " All_Runs.csv > Run-$i.csv which, obviously doesn't work (but it seemed reasonable to hope). How can I do this?

    Read the article

  • how to pass a string to an already opened activity?

    - by Hossein Mansouri
    I have 3 Activities A1,A2,A3 A1 call A2 (A1 goes to stack) A2 call A3 (A2 also goes to stack) And A3 call A1 (A1 should call from stack not new instance...) I don't want to Create new instance of A1 just i want to call it from stack I want to send some Extra String to A1, the problem is here, when i send some String by using putExtra() to A1, A1 can not seen it! I put getIntent() in onResume() for A1 but it s not working... Code in A3 Intent in = new Intent(A3.this,A1.class); in.putExtra("ACTIVITY", "A3"); in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(in); Code in A1 @Override protected void onResume() { super.onResume(); if(getIntent().getExtras().getString("ACTIVITY")=="A3"){ new LoadAllMyOrders().execute(); }else{ new LoadAllMyshops().execute(); } }

    Read the article

  • How do I pass a multi-dimensional array as a GET parameter in PHP?

    - by Onema
    I have the following code. $connect = new Connection (); $response = $connect->putFile($fileName, $destination); header("Location: /test.php?response=" . $response); When I invoke header with the response, the file will stop execution, but I will have no error in the console... I am thinking maybe this array needs to be encoded for the url? if that is the case how? Thank you

    Read the article

  • Is it possible to set a parameterized build or pass an environment variable via a hudson build trigger?

    - by Tim
    I'd like to use hudson to trigger a "promotion" of a build. The build would be a simple script that just copies a release candidate installer file from one location to another. (development dir to release/stable dir) Our build server is not on the public internet, but I want to be able to send an email or a text message or an IM with the build number to hudson, which will parse the build number and then do the copy/move. In looking at the jabber/IM plugin it does not look like this is possible (the parameter part) Has anyone solved this in some way? Should I use some other mechanism? I would prefer not to have to do the manual steps each time (SCP/FTP, etc) - I just want any QA team member to be able to trigger the build server to do the promotion.

    Read the article

< Previous Page | 57 58 59 60 61 62 63 64 65 66 67 68  | Next Page >