Daily Archives

Articles indexed Monday June 14 2010

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

  • Using regular expression to trim html

    - by Tim
    Been trying to solve this for a while now. I need a regex to strip the newlines, tabs and spaces between the html tags demonstrated in the example below: Source: <html> <head> <title> Some title </title> </head> </html> Wanted result: <html><head><title>Some title</title></head></html> The trimming of the whitespaces before the "Some title" is optional. I'd be grateful for any help

    Read the article

  • I need to copy the text from a gridview texbox to the others in the column.

    - by Gilberto Munoz
    This is my code in c# protected void ibtCopiar_Click(object sender, ImageClickEventArgs e) { GridViewRow grdrows = DGPlanilla.Rows[0]; TextBox tb1 = (TextBox)grdrows.FindControl("TextBox1"); string valor = tb1.Text; if (valor != null || valor != "0") { foreach (GridViewRow grdrow in DGPlanilla.Rows) { grdrow.Cells[5].Text = valor; } } } this my code for the button when i debug i see that the value i have in the firts box is pass to the other textboxes in the column, but when it dysplay the page onle the first box show the value i have enter. the other texboxes don´t change.

    Read the article

  • Pass a parameter from one jsp to another using form.action

    - by Ntz
    I have an ID that I need in the next jsp once the user click a button. I am trying to do the following: FirstJSP.jsp: function getSecond() { var frm = document.getElementById("frm"); frm.action = "**second.jsp?id=myId;"** frm.submit(); } ... form id="frm" ..... input type="button" value="Next" onclick="getSecond()"/ ...... This code takes me to my second page, but if I tried to access the id, it gives me an error since the id is null. I access the id in the second page by: final Long passedId = Long.parseLong(request.getParameter("id")); I think I am not passing the parameter correctly, but I don't know how to do it. Any ideas? Thank you so much!

    Read the article

  • NHibernate Projection Components

    - by reggieboyYEAH
    Hello guys im trying to hydrate a DTO using projections in NHibernate this is my code IList<PatientListViewModel> list = y.CreateCriteria<Patient>() .SetProjection(Projections.ProjectionList() .Add(Projections.Property("Birthdate"), "Birthdate") .Add(Projections.Property("Doctor.Id"), "DoctorId") .Add(Projections.Property("Gender"), "Gender") .Add(Projections.Property("Id"), "PatientId") .Add(Projections.Property("Patient.Name.Fullname"), "Fullname") ) .SetResultTransformer(Transformers.AliasToBean<PatientListViewModel>()) .List<PatientListViewModel>(); this code is throwing an exception? anyone know what is the problem? here is the error message Message: could not resolve property: Patient.Name.Fullname of: OneCare.Domain.Entities.Patient

    Read the article

  • Can't import matplotlib

    - by None
    I installed matplotlib using the Mac disk image installer for MacOS 10.5 and Python 2.5. I installed numpy then tried to import matplotlib but got this error: ImportError: numpy 1.1 or later is required; you have 2.0.0.dev8462. It seems to that version 2.0.0.dev8462 would be later than version 1.1 but I am guessing that matplotlib got confused with the ".dev8462" in the version. Is there any workaround to this?

    Read the article

  • Simple logic in javascript

    - by Saurabh
    I have four variables of type integer - var tip_1, tip_2, tip_3, tip_4; The value of these variables are getting fill by some other logic which is always between 1 to 10. I need to maintain a hash with variable name as "key" and value as "value" by following these rules - The variable with MAX value should be the first element in the hash and so on. e.g. if tip_1 = 4, tip_2 = 1, tip_3 = 2, tip_4 = 10 then hash should be something like, Hash = {tip_4, 10} {tip_1, 4} {tip_3, 2} {tip_1, 1} In case of tie following order should be considered - tip_1 tip_2 tip_3 tip_4;

    Read the article

  • Auto update CSS from SASS/SCSS in Rails?

    - by Vulgrin
    Maybe I'm confused on how SASS/SCSS works within Rails (2.3.8.) but I was under the impression that if I included the option Sass::Plugin.options[:always_update] = true that whenever I changed my SCSS file and then hit the page (controller) again, the SCSS would recompile. I can't seem to get this to work, and can't seem to find a good tutorial / example for it. I've tried setting the above property in the Environment.rb file, but it didn't seem to do anything. I tried putting it in its own initializer with require 'sass' but that doesn't seem to work either. What am I missing? Or am i just forced to keep a terminal open with a sass --watch command running to be able to rapidly debug / change my styles? thx

    Read the article

  • SQLite/iPhone read copyright symbol

    - by Marco A
    Hi All, I am having problems reading the copyright symbol from a sqlite db that I have for my App that I am developing. I import the information manually, ie, from an excel sheet. I have tried two ways of doing it and failed with both: 1) Tried replacing the copyright symbol with "\u00ae" (unicode combination) within excel and then importing the modified file. - Result: I get the combination of \u00ae as a part of the string, it doesnt detect the unicode combination. 2) Tried leaving as it is. Importing the excel with the copyright symbol. - Result: I get a symbol that is different from the copyright, its something like an AE put together.looks like this: Æ Heres my code how I read from DB: -(void) readCategoriesFromDatabase:(NSString *) rest_input { // Init the products Array categories = [[NSMutableArray alloc] init]; // Open the database from the users filessytem rest_input = [rest_input stringByAppendingString:@"'"]; NSString *newString; newString = [@"select distinct category from food where restaurant='" stringByAppendingString:rest_input]; const char *cat_sqlStatement = [newString UTF8String]; sqlite3_stmt *cat_compiledStatement; if(sqlite3_prepare_v2(database, cat_sqlStatement, -1, &cat_compiledStatement, NULL) == SQLITE_OK) { // Loop through the results and add them to the feeds array while(sqlite3_step(cat_compiledStatement) == SQLITE_ROW) { NSString *catName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(cat_compiledStatement,0)]; // Create a new product object with the data from the database Product *category = [[Product alloc] initWithName:catName]; // Add the product object to the respective Array [categories addObject:category]; [category release]; } sqlite3_finalize(cat_compiledStatement); } NSLog(@"Finished Accessing Database to gather Categories...."); } I open the DB with this function: -(void) checkAndCreateDatabase{ NSLog(@"Checking/Creating Database...."); NSFileManager *fileManager = [NSFileManager defaultManager]; success = [fileManager fileExistsAtPath:databasePath]; [fileManager removeFileAtPath:databasePath handler:nil]; NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName]; [fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil]; [fileManager release]; if (sqlite3_open([databasePath UTF8String], &database) != SQLITE_OK) { sqlite3_close(database); database = nil; } NSLog(@"Finished Checking/Creating Database...."); } Thanks to anything that can help me out.

    Read the article

  • Getting certain rows from list of rows(C#3.0)

    - by Newbie
    I have a datatable having 44 rows. I have converted that to list and want to take the rows from 4th row till the last(i.e. 44th). I have the below program IEnumerable<DataRow> lstDr = dt.AsEnumerable().Skip(4).Take(dt.Rows.Count); But the output is Enumeration yielded no results I am using c#3.0 Please help.

    Read the article

  • Entity Framework 4: C# !(ReferenceEquals()) vs !=

    - by Eric J.
    Unless a class specifically overrides the behavior defined for Object, ReferenceEquals and == do the same thing... compare references. In property setters, I have commonly used the pattern private MyType myProperty; public MyType MyProperty { set { if (myProperty != value) { myProperty = value; // Do stuff like NotifyPropertyChanged } } } However, in code generated by Entity Framework, the if statement is replaced by if (!ReferenceEquals(myProperty, value)) Using ReferenceEquals is more explicit (as I guess not all C# programmers know that == does the same thing if not overridden). Is there any difference that's escaping me between the two if-variants? Are they perhaps accounting for the possibility that POCO designers may have overridden ==? In short, if I have not overridden ==, am I save using != instead of ReferencEquals()?

    Read the article

  • How do I call Informix stored procedures from Perl?

    - by superjtc
    How do I call informix stored procedures from Perl? I use DBD::ODBC to connect to informix database, but I don't know how to call procedures. my code like this: my $dbh=DBI->connect("dbi:".DBDRIVE.":".DBNAME,DBUSER,DBPASS,{RaiseError=>0,PrintError=>0,AutoCommit=>1}) ||die $DBI::errstr; $dbh->do("execute procedure sp_test('2010-05-01 00:00:00')") || warn "failed\n"; $dbh->disconnect(); when I run it, it didn't get error. But I get nothing when I check the database. the store procedure works fine if I run it in database directly. Anyone can help me out?

    Read the article

  • Using PHP to read a web page with fsockopen(), but fgets is not working

    - by asdasd
    Im using this code here: http://www.digiways.com/articles/php/httpredirects/ public function ReadHttpFile($strUrl, $iHttpRedirectMaxRecursiveCalls = 5) { // parsing the url getting web server name/IP, path and port. $url = parse_url($strUrl); // setting path to '/' if not present in $strUrl if (isset($url['path']) === false) $url['path'] = '/'; // setting port to default HTTP server port 80 if (isset($url['port']) === false) $url['port'] = 80; // connecting to the server] // reseting class data $this->success = false; unset($this->strFile); unset($this->aHeaderLines); $this->strLocation = $strUrl; $fp = fsockopen ($url['host'], $url['port'], $errno, $errstr, 30); // Return if the socket was not open $this-success is set to false. if (!$fp) return; $header = 'GET / HTTP/1.1\r\n'; $header .= 'Host: '.$url['host'].$url['path']; if (isset($url['query'])) $header .= '?'.$url['query']; $header .= '\r\n'; $header .= 'Connection: Close\r\n\r\n'; // sending the request to the server echo "Header is: ".str_replace('\n', '\n', $header).""; $length = strlen($header); if($length != fwrite($fp, $header, $length)) { echo 'error writing to header, exiting'; return; } // $bHeader is set to true while we receive the HTTP header // and after the empty line (end of HTTP header) it's set to false. $bHeader = true; // continuing untill there's no more text to read from the socket while (!feof($fp)) { echo "in loop"; // reading a line of text from the socket // not more than 8192 symbols. $good = $strLine = fgets($fp, 128); if(!$good) { echo 'bad'; return; } // removing trailing \n and \r characters. $strLine = ereg_replace('[\r\n]', '', $strLine); if ($bHeader == false) $this-strFile .= $strLine.'\n'; else $this-aHeaderLines[] = trim($strLine); if (strlen($strLine) == 0) $bHeader = false; echo "read: $strLine"; return; } echo "after loop"; fclose ($fp); } This is all I get: Header is: GET / HTTP/1.1\r\n Host: www.google.com/\r\n Connection: Close\r\n\r\n in loopbad So it fails the fgets($fp, 128);

    Read the article

  • programmatically creating property list from json to include an array

    - by Michael Robinson
    [{"memberid":"18", "useridFK":"30", "loginName":"Johnson", "name":"Frank", "age":"23", "place":"School", },] Someone else posted a similar question but without the fact that it was coming from a JSON deserialization. Quinn had some suggestions but it was confused about where to place/replace the following code (if it's correct): NSDictionary *item1 = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@" member",[NSNumber numberWithInt:3],nil] forKeys:[NSArray arrayWithObjects:@"Title",@"View",nil]]; into this: NSData *jsonData = [jsonreturn dataUsingEncoding:NSUTF32BigEndianStringEncoding]; NSError *error = nil; NSDictionary * dict = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error]; if (dict) { rowsArray = [dict objectForKey:@"member"]; [rowsArray retain]; } My Array.plist needs to look like the following: Root: Dictionary V Rows: Array V Item 0: Dictionary Title: String 18 V Children Array V Item 0 Dictionary Title String 30 etc. Thanks in advance. Every tutorial on JSON only shows a simple array being returned, never a 2-D..It's driving me crazy trying to figure this out.

    Read the article

  • How do I get a less than in a javascript for loop in XSL to work?

    - by Kyle
    I am using CDATA to escape the script but in IE8's debugger I still get this message: "Expected ')'" in the for loop conditions. I am assuming it still thinks that the ; in the &lt; generated by CDATA is ending the loop conditions. Original script in my XSL template: <script type="text/javascript" language="javascript"> <![CDATA[ function submitform(form){ var oErrorArray = new Array(); for (i=0;i<form.length;i++) eval("oErrorArray["+i+"]=oError"+i); var goForm = true; for(i=0;i<form.length;i++) { oErrorArray[i].innerHTML = ""; if(form[i].value="")){ oErrorArray[i].innerHTML = "Error - input field is blank"; goForm = false; } } if(goForm == true) form.submit(); } function resetform(form){ form.reset(); } ]]> </script> Code generated after transformation (from IE8 debugger): <script type="text/javascript" language="javascript"> function submitform(form){ var oErrorArray = new Array(); for (i=0;i&lt;form.length;i++) eval("oErrorArray["+i+"]=oError"+i); goForm = true; for(i=0;i&lt;form.length;i++) { oErrorArray[i].innerHTML = ""; if(form[i].value="")){ oErrorArray[i].innerHTML = "Error - input field is blank"; goForm = false; } } if(goForm == true) form.submit(); } function resetform(form){ form.reset(); } </script> Error reported by IE8 debugger: Expected ')' login.xml, line 29 character 30 (which is right after the first "form.length")

    Read the article

  • Need help with NSString that returns (null)

    - by Guy Dor
    Hi, I have a problem with my string that returns (null) Here's the MainViewController: NSString *leftWebViewUrl; MainViewController *mainViewController; @property (nonatomic, retain) NSString *leftWebViewUrl; @property (nonatomic, retain) MainViewController *mainViewController; leftWebViewUrl = [NSString stringWithString:leftWebView.request.URL.absoluteString]; leftSharingViewController.leftWebViewUrl = leftWebViewUrl; Here's the leftSharingViewController (just the NSString declaration) NSString *leftWebViewUrl; @property (nonatomic, retain) NSString *leftWebViewUrl; From some reason I get (null) Thanks

    Read the article

  • Disable Autocommit in H2 with Hibernate/C3P0 ?

    - by HDave
    I have a JPA/Hibernate application and am trying to get it to run against H2 (as well as other databases). Currently I am using Atomikos for transaction and C3P0 for connection pooing. Despite my best efforts I am still seeing this in the log file (and DAO integration tests are failing): [20100613 23:06:34] DEBUG [main] SessionFactoryImpl.(242) | instantiating session factory with properties: .....edited for brevity.... hibernate.connection.autocommit=true, ....more stuff follows The connection URL to H2 has AUTOCOMMIT=OFF, but according to the H2 documentation: this will not work as expected when using a connection pool (the connection pool manager will re-enable autocommit when returning the connection to the pool, so autocommit will only be disabled the first time the connection is used So I figured (apparently correctly) that Hibernate is where I'll have to indicate I want autocommit off. I found the autocommit property documented here and I put it in my EntityManagerFactory config as follows: <bean id="myappTestLocalEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="persistenceUnitName" value="myapp-core" /> <property name="persistenceUnitPostProcessors"> <bean class="com.myapp.core.persist.util.JtaPersistenceUnitPostProcessor"> <property name="jtaDataSource" ref="myappPersistTestJdbcDataSource" /> </bean> </property> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="showSql" value="true" /> <property name="database" value="$DS{hibernate.database}" /> <property name="databasePlatform" value="$DS{hibernate.dialect}" /> </bean> </property> <property name="jpaProperties"> <props> <prop key="hibernate.transaction.factory_class">com.atomikos.icatch.jta.hibernate3.AtomikosJTATransactionFactory</prop> <prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup</prop> <prop key="hibernate.connection.autocommit">false</prop> <prop key="hibernate.format_sql">true"</prop> <prop key="hibernate.use_sql_comments">true</prop> </property> </bean>

    Read the article

  • How to output multiple rows from an SQL query using the mysqli object

    - by Jonathan
    Assuming that the mysqli object is already instantiatied (and connected) with the global variable $mysql, here is the code I am trying to work with. class Listing { private $mysql; function getListingInfo($l_id = "", $category = "", $subcategory = "", $username = "", $status = "active") { $condition = "`status` = '$status'"; if (!empty($l_id)) $condition .= "AND `L_ID` = '$l_id'"; if (!empty($category)) $condition .= "AND `category` = '$category'"; if (!empty($subcategory)) $condition .= "AND `subcategory` = '$subcategory'"; if (!empty($username)) $condition .= "AND `username` = '$username'"; $result = $this->mysql->query("SELECT * FROM listing WHERE $condition") or die('Error fetching values'); $this->listing = $result->fetch_array() or die('could not create object'); foreach ($this->listing as $key => $value) : $info[$key] = stripslashes(html_entity_decode($value)); endforeach; return $info; } } there are several hundred listings in the db and when I call $result-fetch_array() it places in an array the first row in the db. however when I try to call the object, I can't seem to access more than the first row. for instance: $listing_row = new Listing; while ($listing = $listing_row-getListingInfo()) { echo $listing[0]; } this outputs an infinite loop of the same row in the db. Why does it not advance to the next row? if I move the code: $this->listing = $result->fetch_array() or die('could not create object'); foreach ($this->listing as $key => $value) : $info[$key] = stripslashes(html_entity_decode($value)); endforeach; if I move this outside the class, it works exactly as expected outputting a row at a time while looping through the while statement. Is there a way to write this so that I can keep the fetch_array() call in the class and still loop through the records?

    Read the article

  • Getting a JFrame's actual current location

    - by Ian Fellows
    Hello community, I am trying to create a (child) JFrame which slides out from underneath one side of a second (parent) JFrame. The goal is to then have the child follow the parent around when it is moved, and respond to resizing events. This is somewhat related to this question. I have tried using a ComponentListener, but with this method the child only moves once the parent has come to a stop, whereas I would like the child to move as the parent is dragged around the screen. Another option I attempted was to start a new refresher thread that continually updated the child's location using getLocation() or getLocationOnScreen(), but the lag was the same as with ComponentListener. Is there a way to get the true actual location of a JFrame even in the midst of a drag? or if not, is there a way to get the effect of a sheet sliding out from underneath and following the Frame around?

    Read the article

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