Search Results

Search found 13011 results on 521 pages for 'catch block'.

Page 222/521 | < Previous Page | 218 219 220 221 222 223 224 225 226 227 228 229  | Next Page >

  • trying to show/hide a div but something is not working

    - by Paul
    window.addEvent('domready', function(){ $('detail_block_table').addEvent('click', function(){ if ($('detail_showDiv').getStyle('display') == 'none') { $('detail_showDiv').setStyle('display','block'); } else { $('detail_showDiv').setStyle('display','none'); } }); }); This is the code, it looks fine but something prevents it from working. Any ideas?

    Read the article

  • java: converting part of a ByteBuffer to a string

    - by Jason S
    I have a ByteBuffer containing bytes that were derived by String.getBytes(charsetName), where "containing" means that the string comprises the entire sequence of bytes between the ByteBuffer's position() and limit(). What's the best way for me to get the string back? (assuming I know the encoding charset) Is there anything better than the following (which seems a little clunky) byte[] ba = new byte[bbuf.remaining()]; bbuf.get(ba); try { String s = new String(ba, charsetName); } catch (UnsupportedEncodingException e) { /* take appropriate action */ }

    Read the article

  • Easy way to keep counting up infinitely

    - by Andrew Alexander
    What's a good way to keep counting up infinitely? I'm trying to write a condition that will keep going until there's no value in a database, so it's going to iterate from 0, up to theoretically infinity (inside a try block, of course). How would I count upwards infinitely? Or should I use something else? I am looking for something similar to i++ in other languages, where it keeps iterating until failure.

    Read the article

  • Implication of (not) rethrowing exception after logging

    - by dotnetdev
    Hi, In a team environment, if I handle an exception (like so): protected void Page_Load(object sender, EventArgs e) { this.exTest(); } public void exTest() { try { throw new Exception("sjsj"); } catch (Exception ex) { string s = ex.Message; throw; } } What is the implication of not rethrowing the exception (throw)? Even without the keyword the custom error settings in web.config are used (redirection to specified page). Thanks

    Read the article

  • Android: SQLite content accessing error

    - by vnshetty
    I've following code, it gives run time error as below... why? try{ String myPath = DB_PATH + DB_NAME; mDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){} Runtime Error: :sqlite returned: error code = 1, msg = no such table: android_metadata :SELECT locale FROM android_metadata failed :Failed to setLocale() when constructing, closing the database :android.database.sqlite.SQLiteException: no such table: android_metadata

    Read the article

  • Regular expression on a URL

    - by alphaexe
    I need to be able to catch when the URL contains a image of multiple file types or follow this syntax. http://localhost:8080/fdlic-web/webpic/101 Here is what i have so far. (.*)(jpg|gif|png|bmp|jpeg|webpic/(\d+))$

    Read the article

  • dialog.show() crashes my application, why?

    - by user1739462
    I'm new in adroid. I like to do things when the color reach a value. I like (for example) show the alert if r is bigger than 30, but the application go in crash. Thank for very simple answares. public class MainActivity extends Activity { private AlertDialog dialog; private AlertDialog.Builder builder; private BackgroundColors view; public class BackgroundColors extends SurfaceView implements Runnable { public int grand=0; public int step=0; private boolean flip=true; private Thread thread; private boolean running; private SurfaceHolder holder; public BackgroundColors(Context context) { super(context); } Inside this loop while running is true. is impossible to show dialogs ?? public void run() { int r = 0; while (running){ if (holder.getSurface().isValid()){ Canvas canvas = holder.lockCanvas(); if (r > 250) r = 0; r += 10; if (r>30 && flip){ flip=false; // ********************************* dialog.show(); // ********************************* // CRASH !! } try { Thread.sleep(300); } catch(InterruptedException e) { e.printStackTrace(); } canvas.drawARGB(255, r, 255, 255); holder.unlockCanvasAndPost(canvas); } } } public void start() { running = true; thread = new Thread(this); holder = this.getHolder(); thread.start(); } public void stop() { running = false; boolean retry = true; while (retry){ try { thread.join(); retry = false; } catch(InterruptedException e) { retry = true; } } } public boolean onTouchEvent(MotionEvent e){ dialog.show(); return false; } protected void onSizeChanged(int xNew, int yNew, int xOld, int yOld){ super.onSizeChanged(xNew, yNew, xOld, yOld); grand = xNew; step =grand/15; } } public void onCreate(Bundle b) { super.onCreate(b); view = new BackgroundColors(this); this.setContentView(view); builder = new AlertDialog.Builder(this); builder.setMessage("ciao"); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Log.d("Basic", "It worked"); } }); dialog = builder.create(); } public void onPause(){ super.onPause(); view.stop(); } public void onResume(){ super.onResume(); view.start(); } }

    Read the article

  • Drupal: link to latest node of a certain content type

    - by james6848
    I have a link within a block. At the moment it goes to a list of newsletter nodes: <p><a href="<?php global $base_url; print $base_url;?>/news-events/newsletter">Read our latest newsletter</a></p> What I would prefer is to have it go to the latest node of the content type 'newsletter', is this possible?

    Read the article

  • Fold C Preprocessor in VIM

    - by Sunny
    Is it possible to fold C preprocessor in VIM. For example: #if defined(DEBUG) //some block of code myfunction(); #endif I want to fold it so that it becomes: +-- 4 lines: #if defined(DEBUG)---

    Read the article

  • Create jquery dropdown like RDP Menu Bar

    - by user51701
    I'm not all that familiar with jquery so I'm not quite sure how to do this. Basically, I want a block of html to stay hidden at the top of the page with a ~3px edge sticking out (something to mouseover), and when you mouse over it, the hidden section slides down. Basically I want it to work like the RDP full screen menu bar works. Any thoughts on what the best way of doing this is?

    Read the article

  • How do I create a new instance of a different class when saving a model

    - by Will
    I have a Class A that when it is instantiated and saved for the first time or modified it will create an instance of Class B and save it also I want them to be in the same transaction and I want it to be handled in the Model not a controller. I know how to do this in a conteoller with the ‘transaction do’ block but how do I do it in the model? Thanks

    Read the article

  • Can I display twovalues in a Silverlight TextBlock?

    - by Subhen
    Can I data bind two proporties values in a single textblock. For Example some thing like following, though this is noth the correct code: <TextBlock Margin="5" Text="{Binding property1,Binding property2}" Style="{StaticResource Style1}" /> I want to display two values in a single text block . Thanks, Subhendu

    Read the article

  • How can I write this shorter?

    - by nLL
    public static string GetUa(HttpRequest hr) { try { string visitorBrowser = hr.UserAgent.ToString(); string originalBrowser = hr.ServerVariables["X-OperaMini-Phone-UA"]; string anotherOriginalBrowser = hr.ServerVariables["X-Device-User-Agent"]; //novarra if (!String.IsNullOrEmpty(originalBrowser)) { return "OPERAMINI " + originalBrowser; } else { if (!String.IsNullOrEmpty(anotherOriginalBrowser)) { return "NOVARRA " + anotherOriginalBrowser; } else { return visitorBrowser; } } } catch { return "No UA Found"; } }

    Read the article

  • C# ApplicationContext usage

    - by rd42
    Apologies if my terminology is off, I'm new to C#. I'm trying to use an ApplicationContext file to store mysql conn values, like dbname, username, password. The class with mysql conn string is "using" the namespace for the ApplicationContext, but when I print out the connection string, the values are making it. A friend said, "I'm not initializing it" but couldn't stay to expand on what "it" was. and the "Console.WriteLine("1");" in ApplicationContext.cs never shows up. Do I need to create an ApplicationContext object and the call Initialize() on that object? Thanks for any help. ApplicationContext.cs: namespace NewApplication.Context { class ApplicationContext { public static string serverName; public static string username; public static string password; public static void Initialize() { //need to read through config here try { Console.WriteLine("1"); XmlDocument xDoc = new XmlDocument(); xDoc.Load(".\\Settings.xml"); XmlNodeList serverNodeList = xDoc.GetElementsByTagName("DatabaseServer"); XmlNodeList usernameNodeList = xDoc.GetElementsByTagName("UserName"); XmlNodeList passwordNodeList = xDoc.GetElementsByTagName("Password"); } catch (Exception ex) { // MessageBox.Show(ex.ToString()); //TODO: Future write to log file username = "user"; password = "password"; serverName = "localhost"; } } } } MySQLManager.cs: note: dbname is the same as the username as you'll see in the code, I copied this from a friend who does that. using System; using System.Collections.Generic; using System.Linq; using System.Text; using MySql.Data; using MySql.Data.MySqlClient; using NewApplication.Context; namespace NewApplication.DAO { class MySQLManager { private static MySqlConnection conn; public static MySqlConnection getConnection() { if (conn == null || conn.State == System.Data.ConnectionState.Closed) { string connStr = "server=" + ApplicationContext.serverName + ";user=" + ApplicationContext.username + ";database=" + ApplicationContext.username + ";port=3306;password=" + ApplicationContext.password + ";"; conn = new MySqlConnection(connStr); try { Console.WriteLine("Connecting to MySQL... "); Console.WriteLine("Connection string: " + connStr + "\n"); conn.Open(); // Perform databse operations // conn.Close(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } return conn; } } } and, thanks for still reading, this is the code that uses the two previous files: class LogDAO { MySqlConnection conn; public LogDAO() { conn = MySQLManager.getConnection(); } Thank you, rd42

    Read the article

  • Junit before class ( non static )

    - by Roman
    Are there any best practices to get Junit execute a function once in a test file , and it should also not be static. like @BeforeClass on non static function? Here is an ugly solution : @Before void init(){ if (init.get() == false){ init.set(true); // do once block } } well this is something i dont want to do , and i am looking for an integrated junit solution.

    Read the article

  • Implementing a kext that intercepts file system usage.

    - by UraN
    Hi, how do most of antivirus software block file system io in case of an infected file? I suppose all the magic resides in some custom kext to do that. Can anyone point me to some topics on this? Some working example would also be great. I've read apple docs about kext development, but mostly it's all about hardware drivers and i could not find what i need. Thanx.

    Read the article

  • Unfamiliar Javascript Syntax

    - by user1051643
    Long and short of the story is, whilst reading John Resig's blog (specifically http://ejohn.org/blog/javascript-trie-performance-analysis/) I came across a line which makes absolutely no sense to me whatsoever. Essentially it boils down to object = object[key] = something; (this can be found in the first code block of the article I've linked.) This has proven rather difficult to google, so if anyone can offer some insight / a good online resource for me to learn for myself, I'd much appreciate it.

    Read the article

  • Writing text file on local server MVC 2.0

    - by Liado
    Hi, i'm trying to write a text file on remote server, i'm using the following code: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Index(UserModels model) { if (!ModelState.IsValid) { return View("Index"); } try { using (StreamWriter w = new StreamWriter(Server.MapPath(TEXT_FILE_NAME), true)) { w.WriteLine(model.Email.ToString()); // Write the text } } catch { } the folder is still empty, can someone help? what should be the problem? Thanks

    Read the article

  • How to use one script for diff and diff3 in Subversion?

    - by lamcro
    I have a perl script that determines what external diff to use depending on the file's content. I would like to use it determine external diff3 also. Which is the best method to know how my script is being called? I was planning to catch the last three parameters, and verify if they are all files, to use the diff3 options, but I'm hoping there is a cleaner method.

    Read the article

< Previous Page | 218 219 220 221 222 223 224 225 226 227 228 229  | Next Page >