Search Results

Search found 135 results on 6 pages for 'zipcode'.

Page 2/6 | < Previous Page | 1 2 3 4 5 6  | Next Page >

  • SQL query to count and list the different counties per zip code

    - by Chris
    I have a sql server 2005 table called ZipCode, which has all the US ZIPs in it. For each entry, it lists the zip, county, city, state, and several other details. Some zipcodes span multiple cities and some even span multiple counties. As a result, some zipcodes appear many times in the table. I am trying to query the table to see which zipcodes go across multiple counties. This is what I have so far: select zipcode, count(zipcode) as total, county, state from zipcode group by zipcode, county, state order by zipcode Of 19248 records in the result set, here are the first several records returned: zipcode total county state 00501 2 SUFFOLK NY 00544 2 SUFFOLK NY 00801 3 SAINT THOMAS VI 00802 3 SAINT THOMAS VI 00803 3 SAINT THOMAS VI 00804 3 SAINT THOMAS VI 00805 1 SAINT THOMAS VI 00820 2 SAINT CROIX VI 00821 1 SAINT CROIX VI 00822 1 SAINT CROIX VI 00823 2 SAINT CROIX VI 00824 2 SAINT CROIX VI In this particular example, each zip with a total of two or more happens to be in the table more than once, and it's because the "cityaliasname" (not shown) or some other column differs. But I just want to know which zips are in there more than once because the county column differs. I searched before posting this and I found many questions about counting records but I could not figure out how to apply them to my problem. Please forgive me if there is already a question whose answer applies to this question.

    Read the article

  • Jquery to find a name on html page and add hyperlink

    - by mikejones12
    Here is my example: I have a a website that contains the following: <body> Jim Nebraska zipcode 65437 Tony lives in California his zipcode is 98708 </body> I would like to be able to search for zip codes on the page and wrap them with hyperlinks like: <body> Jim Nebraska zipcode <a href="/65437.htm">65437</a> Tony lives in California his zipcode is <a href="/65437.htm">98708</a> </body> Could I use a regex selector to find the string and then wrap the string, or replace it with the new hyperlink? I am new to Jquery and looking for someone to point me in the right direction. Thank you, Mike

    Read the article

  • Why does my ko computed observable not update bound UI elements when its value changes?

    - by Allen
    I'm trying to wrap a cookie in a computed observable (which I'll later turn into a protectedObservable) and I'm having some problems with the computed observable. I was under the opinion that changes to the computed observable would be broadcast to any UI elements that have been bound to it. I've created the following fiddle JavaScript: var viewModel = {}; // simulating a cookie store, this part isnt as important var cookie = function () { // simulating a value stored in cookies var privateZipcode = "12345"; return { 'write' : function (val) { privateZipcode = val; }, 'read': function () { return privateZipcode; } } }(); viewModel.zipcode = ko.computed({ read: function () { return cookie.read(); }, write: function (value) { cookie.write(value); }, owner: viewModel }); ko.applyBindings(viewModel);? HTML: zipcode: <input type='text' data-bind="value: zipcode"> <br /> zipcode: <span data-bind="text: zipcode"></span>? I'm not using an observable to store privateZipcode since that's really just going to be in a cookie. I'm hoping that the ko.computed will provide the notifications and binding functionality that I need, though most of the examples I've seen with ko.computed end up using a ko.observable underneath the covers. Shouldn't the act of writing the value to my computed observable signal the UI elements that are bound to its value? Shouldn't these just update? Workaround I've got a simple workaround where I just use a ko.observable along side of my cookie store and using that will trigger the required updates to my DOM elements but this seems completely unnecessary, unless ko.computed lacks the signaling / dependency type functionality that ko.observable has. My workaround fiddle, you'll notice that the only thing that changes is that I added a seperateObservable that isn't used as a store, its only purpose is to signal to the UI that the underlying data has changed. // simulating a cookie store, this part isnt as important var cookie = function () { // simulating a value stored in cookies var privateZipcode = "12345"; // extra observable that isnt really used as a store, just to trigger updates to the UI var seperateObservable = ko.observable(privateZipcode); return { 'write' : function (val) { privateZipcode = val; seperateObservable(val); }, 'read': function () { seperateObservable(); return privateZipcode; } } }(); This makes sense and works as I'd expect because viewModel.zipcode depends on seperateObservable and updates to that should (and does) signal the UI to update. What I don't understand, is why doesn't a call to the write function on my ko.computed signal the UI to update, since that element is bound to that ko.computed? I suspected that I might have to use something in knockout to manually signal that my ko.computed has been updated, and I'm fine with that, that makes sense. I just haven't been able to find a way to accomplish that.

    Read the article

  • undefined method `output_data' for #<EventManager:0x007fa4220320c8> (NoMethodError)

    - by Roger Camps
    I keep getting this error: event_manager.rb:83:in': undefined method output_data' for #<EventManager:0x007fc5018320c0> (NoMethodError) I am following the exercise on this website: Here is my code (My error comes towards the end with DEF OUTPUT_DATA ...): # Dependencies require "csv" # Class Definition class EventManager INVALID_PHONE_NUMBER = "0000000000" INVALID_ZIPCODE = "00000" def initialize puts "EventManager Initialized." filename = "event_attendees.csv" @file = CSV.open(filename, {:headers => true, :header_converters => :symbol}) end def print_names @file.each do |line| puts line.inspect puts line[2] + " " + line[3] end end #printing home phone number method def print_numbers @file.each do |line| number = clean_number(line[:homephone]) puts number end end #cleaning numbers method def clean_number(number) cleaner= number.delete('.' + ')' + '(' + '-') if cleaner.length == 10 # Do Nothing elsif cleaner.length == 11 if cleaner.start_with?("1") cleaner = cleaner[1..-1] else cleaner = INVALID_PHONE_NUMBER end else cleaner = INVALID_PHONE_NUMBER end return cleaner end def clean_zipcode(original) if original.nil? zipcode = INVALID_ZIPCODE elsif original.length < 5 while original.length < 5 original = original.insert(0, "0") end else return original end return zipcode end def print_zipcodes @file.each do |line| zipcode = clean_zipcode(line[:zipcode]) puts zipcode end def output_data output = CSV.open("event_attendees_clean.csv", "w") @file.each do |line| output << line end end end end # Script manager = EventManager.new #manager.print_numbers #manager.print_zipcodes manager.output_data I've tried several things, checked all through the internet and I just can't figure it out myself. I will really appreciate any help. Thank you in advance!

    Read the article

  • JQuery text display problem?

    - by SLAPme
    Kind of new to JQuery and I was wondering how can I state that the users submitted info was saved when they click the submit button by displaying the message Changes saved at the top of the form and then have it disappear when the user leaves the web page and return back to it? Right now my code only displays that changes were saved at the bottom of the form outside of the lists and will not disappear when the users leave the web page and return back to it. Here is the JQuery code. $(function() { $(".save-button").click(function() { $.post($("#contact-form").attr("action"), $("#contact-form").serialize(), function(html) { $("div.contact-info-form").html(html); $('#contact-form').append('<li>Changes saved!</li>'); }); return false; // prevent normal submit }); }); Here is the html code. <div id="contact-info-form" class="form-content"> <h2>Contact Information</h2> <form method="post" action="index.php" id="contact-form"> <fieldset> <ul> <li><label for="address">Address 1: </label><input type="text" name="address" id="address" size="25" class="input-size" value="<?php if (isset($_POST['address'])) { echo $_POST['address']; } else if(!empty($address)) { echo $address; } ?>" /></li> <li><label for="address_two">Address 2: </label><input type="text" name="address_two" id="address_two" size="25" class="input-size" value="<?php if (isset($_POST['address_two'])) { echo $_POST['address_two']; } else if(!empty($address_two)) { echo $address_two; } ?>" /></li> <li><label for="city_town">City/Town: </label><input type="text" name="city_town" id="city_town" size="25" class="input-size" value="<?php if (isset($_POST['city_town'])) { echo $_POST['city_town']; } else if(!empty($city_town)) { echo $city_town; } ?>" /></li> <li><label for="state_province">State/Province: </label> <?php echo '<select name="state_province" id="state_province">' . "\n"; foreach($state_options as $option) { if ($option == $state_province) { echo '<option value="' . $option . '" selected="selected">' . $option . '</option>' . "\n"; } else { echo '<option value="'. $option . '">' . $option . '</option>'."\n"; } } echo '</select>'; ?> </li> <li><label for="zipcode">Zip/Post Code: </label><input type="text" name="zipcode" id="zipcode" size="5" class="input-size" value="<?php if (isset($_POST['zipcode'])) { echo $_POST['zipcode']; } else if(!empty($zipcode)) { echo $zipcode; } ?>" /></li> <li><label for="country">Country: </label> <?php echo '<select name="country" id="country">' . "\n"; foreach($countries as $option) { if ($option == $country) { echo '<option value="' . $option . '" selected="selected">' . $option . '</option>' . "\n"; } else if($option == "-------------") { echo '<option value="' . $option . '" disabled="disabled">' . $option . '</option>'; } else { echo '<option value="'. $option . '">' . $option . '</option>'."\n"; } } echo '</select>'; ?> </li> <li><label for="email">Email Address: </label><input type="text" name="email" id="email" size="25" class="input-size" value="<?php if (isset($_POST['email'])) { echo $_POST['email']; } else if(!empty($email)) { echo $email; } ?>" /><br /><span>We don't spam or share your email with third parties. We respect your privacy.</span></li> <li><input type="submit" name="submit" value="Save Changes" class="save-button" /> <input type="hidden" name="contact_info_submitted" value="true" /> <input type="submit" name="submit" value="Preview Changes" class="preview-changes-button" /></li> </ul> </fieldset> </form> </div>

    Read the article

  • JQuery form submit Question?

    - by SLAPme
    I'm kind of new to JQuery and was wondering how can I have the following text appear when the user submits there changes <p>Your changes have been saved.</p>? How do I fix my code so it displays this message? JQuery script. $(function() { $(".save-button").click(function() { $.post($("#contact-form").attr("action"), $("#contact-form").serialize(), function(html) { $("div.contact-info-form").html(html); }); return false; // prevent normal submit }); }); Here is the html. <div id="contact-info-form" class="form-content"> <h2>Contact Information</h2> <form method="post" action="index.php" id="contact-form"> <fieldset> <ul> <li><label for="address">Address 1: </label><input type="text" name="address" id="address" size="25" class="input-size" value="<?php if (isset($_POST['address'])) { echo $_POST['address']; } else if(!empty($address)) { echo $address; } ?>" /></li> <li><label for="address_two">Address 2: </label><input type="text" name="address_two" id="address_two" size="25" class="input-size" value="<?php if (isset($_POST['address_two'])) { echo $_POST['address_two']; } else if(!empty($address_two)) { echo $address_two; } ?>" /></li> <li><label for="city_town">City/Town: </label><input type="text" name="city_town" id="city_town" size="25" class="input-size" value="<?php if (isset($_POST['city_town'])) { echo $_POST['city_town']; } else if(!empty($city_town)) { echo $city_town; } ?>" /></li> <li><label for="state_province">State/Province: </label> <?php echo '<select name="state_province" id="state_province">' . "\n"; foreach($state_options as $option) { if ($option == $state_province) { echo '<option value="' . $option . '" selected="selected">' . $option . '</option>' . "\n"; } else { echo '<option value="'. $option . '">' . $option . '</option>'."\n"; } } echo '</select>'; ?> </li> <li><label for="zipcode">Zip/Post Code: </label><input type="text" name="zipcode" id="zipcode" size="5" class="input-size" value="<?php if (isset($_POST['zipcode'])) { echo $_POST['zipcode']; } else if(!empty($zipcode)) { echo $zipcode; } ?>" /></li> <li><label for="country">Country: </label> <?php echo '<select name="country" id="country">' . "\n"; foreach($countries as $option) { if ($option == $country) { echo '<option value="' . $option . '" selected="selected">' . $option . '</option>' . "\n"; } else if($option == "-------------") { echo '<option value="' . $option . '" disabled="disabled">' . $option . '</option>'; } else { echo '<option value="'. $option . '">' . $option . '</option>'."\n"; } } echo '</select>'; ?> </li> <li><label for="email">Email Address: </label><input type="text" name="email" id="email" size="25" class="input-size" value="<?php if (isset($_POST['email'])) { echo $_POST['email']; } else if(!empty($email)) { echo $email; } ?>" /><br /><span>We don't spam or share your email with third parties. We respect your privacy.</span></li> <li><p>Changes have been saved</p><input type="submit" name="submit" value="Save Changes" class="save-button" /> <input type="hidden" name="contact_info_submitted" value="true" /> <input type="submit" name="submit" value="Preview Changes" class="preview-changes-button" /></li> </ul> </fieldset> </form> </div>

    Read the article

  • Nullpointerexcption & abrupt IOStream closure with inheritence and subclasses

    - by user1401652
    A brief background before so we can communicate on the same wave length. I've had about 8-10 university courses on programming from data structure, to one on all languages, to specific ones such as java & c++. I'm a bit rusty because i usually take 2-3 month breaks from coding. This is a personal project that I started thinking of two years back. Okay down to the details, and a specific question, I'm having problems with my mutator functions. It seems to be that I am trying to access a private variable incorrectly. The question is, am I nesting my classes too much and trying to mutate a base class variable the incorrect way. If so point me in the way of the correct literature, or confirm this is my problem so I can restudy this information. Thanks package GroceryReceiptProgram; import java.io.*; import java.util.Vector; public class Date { private int hour, minute, day, month, year; Date() { try { BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); System.out.println("What's the hour? (Use 1-24 military notation"); hour = Integer.parseInt(keyboard.readLine()); System.out.println("what's the minute? "); minute = Integer.parseInt(keyboard.readLine()); System.out.println("What's the day of the month?"); day = Integer.parseInt(keyboard.readLine()); System.out.println("Which month of the year is it, use an integer"); month = Integer.parseInt(keyboard.readLine()); System.out.println("What year is it?"); year = Integer.parseInt(keyboard.readLine()); keyboard.close(); } catch (IOException e) { System.out.println("Yo houston we have a problem"); } } public void setHour(int hour) { this.hour = hour; } public void setHour() { try { BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); System.out.println("What hour, use military notation?"); this.hour = Integer.parseInt(keyboard.readLine()); keyboard.close(); } catch (NumberFormatException e) { System.out.println(e.toString() + ":doesnt seem to be a number"); } catch (IOException e) { System.out.println(e.toString()); } } public int getHour() { return hour; } public void setMinute(int minute) { this.minute = minute; } public void setMinute() { try (BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in))) { System.out.println("What minute?"); this.minute = Integer.parseInt(keyboard.readLine()); } catch (NumberFormatException e) { System.out.println(e.toString() + ": doesnt seem to be a number"); } catch (IOException e) { System.out.println(e.toString() + ": minute shall not cooperate"); } catch (NullPointerException e) { System.out.println(e.toString() + ": in the setMinute function of the Date class"); } } public int getMinute() { return minute; } public void setDay(int day) { this.day = day; } public void setDay() { try { BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); System.out.println("What day 0-6?"); this.day = Integer.parseInt(keyboard.readLine()); keyboard.close(); } catch (NumberFormatException e) { System.out.println(e.toString() + ":doesnt seem to be a number"); } catch (IOException e) { System.out.println(e.toString()); } } public int getDay() { return day; } public void setMonth(int month) { this.month = month; } public void setMonth() { try { BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); System.out.println("What month 0-11?"); this.month = Integer.parseInt(keyboard.readLine()); keyboard.close(); } catch (NumberFormatException e) { System.out.println(e.toString() + ":doesnt seem to be a number"); } catch (IOException e) { System.out.println(e.toString()); } } public int getMonth() { return month; } public void setYear(int year) { this.year = year; } public void setYear() { try { BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); System.out.println("What year?"); this.year = Integer.parseInt(keyboard.readLine()); keyboard.close(); } catch (NumberFormatException e) { System.out.println(e.toString() + ":doesnt seem to be a number"); } catch (IOException e) { System.out.println(e.toString()); } } public int getYear() { return year; } public void set() { setMinute(); setHour(); setDay(); setMonth(); setYear(); } public Vector<Integer> get() { Vector<Integer> holder = new Vector<Integer>(5); holder.add(hour); holder.add(minute); holder.add(month); holder.add(day); holder.add(year); return holder; } }; That is the Date class obviously, next is the other base class Location. package GroceryReceiptProgram; import java.io.*; import java.util.Vector; public class Location { String streetName, state, city, country; int zipCode, address; Location() { try { BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); System.out.println("What is the street name"); streetName = keyboard.readLine(); System.out.println("Which state?"); state = keyboard.readLine(); System.out.println("Which city?"); city = keyboard.readLine(); System.out.println("Which country?"); country = keyboard.readLine(); System.out.println("Which zipcode?");//if not u.s. continue around this step zipCode = Integer.parseInt(keyboard.readLine()); System.out.println("What address?"); address = Integer.parseInt(keyboard.readLine()); } catch (IOException e) { System.out.println(e.toString()); } } public void setZipCode(int zipCode) { this.zipCode = zipCode; } public void setZipCode() { try { BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); System.out.println("What zipCode?"); this.zipCode = Integer.parseInt(keyboard.readLine()); keyboard.close(); } catch (NumberFormatException e) { System.out.println(e.toString() + ":doesnt seem to be a number"); } catch (IOException e) { System.out.println(e.toString()); } } public void set() { setAddress(); setCity(); setCountry(); setState(); setStreetName(); setZipCode(); } public int getZipCode() { return zipCode; } public void setAddress(int address) { this.address = address; } public void setAddress() { try { BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); System.out.println("What minute?"); this.address = Integer.parseInt(keyboard.readLine()); keyboard.close(); } catch (NumberFormatException e) { System.out.println(e.toString() + ":doesnt seem to be a number"); } catch (IOException e) { System.out.println(e.toString()); } } public int getAddress() { return address; } public void setStreetName(String streetName) { this.streetName = streetName; } public void setStreetName() { try { BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); System.out.println("What minute?"); this.streetName = keyboard.readLine(); keyboard.close(); } catch (IOException e) { System.out.println(e.toString()); } } public String getStreetName() { return streetName; } public void setState(String state) { this.state = state; } public void setState() { try { BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); System.out.println("What minute?"); this.state = keyboard.readLine(); keyboard.close(); } catch (IOException e) { System.out.println(e.toString()); } } public String getState() { return state; } public void setCity(String city) { this.city = city; } public void setCity() { try { BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); System.out.println("What minute?"); this.city = keyboard.readLine(); keyboard.close(); } catch (IOException e) { System.out.println(e.toString()); } } public String getCity() { return city; } public void setCountry(String country) { this.country = country; } public void setCountry() { try { BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); System.out.println("What minute?"); this.country = keyboard.readLine(); keyboard.close(); } catch (IOException e) { System.out.println(e.toString()); } } public String getCountry() { return country; } }; their parent(What is the proper name?) class package GroceryReceiptProgram; import java.io.*; public class FoodGroup { private int price, count; private Date purchaseDate, expirationDate; private Location location; private String name; public FoodGroup() { try { setPrice(); setCount(); expirationDate.set(); purchaseDate.set(); location.set(); } catch (NullPointerException e) { System.out.println(e.toString() + ": in the constructor of the FoodGroup class"); } } public void setPrice(int price) { this.price = price; } public void setPrice() { try (BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in))) { System.out.println("What Price?"); price = Integer.parseInt(keyboard.readLine()); } catch (NumberFormatException e) { System.out.println(e.toString() + ":doesnt seem to be a number"); } catch (IOException e) { System.out.println(e.toString() + ": in the FoodGroup class, setPrice function"); } catch (NullPointerException e) { System.out.println(e.toString() + ": in FoodGroup class. SetPrice()"); } } public int getPrice() { return price; } public void setCount(int count) { this.count = count; } public void setCount() { try (BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in))) { System.out.println("What count?"); count = Integer.parseInt(keyboard.readLine()); } catch (NumberFormatException e) { System.out.println(e.toString() + ":doesnt seem to be a number"); } catch (IOException e) { System.out.println(e.toString() + ": in the FoodGroup class, setCount()"); } catch (NullPointerException e) { System.out.println(e.toString() + ": in FoodGroup class, setCount"); } } public int getCount() { return count; } public void setName(String name) { this.name = name; } public void setName() { try { BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); System.out.println("What minute?"); this.name = keyboard.readLine(); } catch (IOException e) { System.out.println(e.toString()); } } public String getName() { return name; } public void setLocation(Location location) { this.location = location; } public Location getLocation() { return location; } public void setPurchaseDate(Date purchaseDate) { this.purchaseDate = purchaseDate; } public void setPurchaseDate() { this.purchaseDate.set(); } public Date getPurchaseDate() { return purchaseDate; } public void setExpirationDate(Date expirationDate) { this.expirationDate = expirationDate; } public void setExpirationDate() { this.expirationDate.set(); } public Date getExpirationDate() { return expirationDate; } } and finally the main class, so I can get access to all of this work. package GroceryReceiptProgram; public class NewMain { public static void main(String[] args) { FoodGroup test = new FoodGroup(); } } If anyone is further interested, here is a link the UML for this. https://www.dropbox.com/s/1weigjnxih70tbv/GRP.dia

    Read the article

  • Select XML nodes as rows

    - by Bjørn
    I am selecting from a table that has an XML column using T-SQL. I would like to select a certain type of node and have a row created for each one. For instance, suppose I am selecting from a people table. This table has an XML column for addresses. The XML is formated similar to the following: <address> <street>Street 1</street> <city>City 1</city> <state>State 1</state> <zipcode>Zip Code 1</zipcode> </address> <address> <street>Street 2</street> <city>City 2</city> <state>State 2</state> <zipcode>Zip Code 2</zipcode> </address> How can I get results like this: Name         City         State Joe Baker   Seattle      WA Joe Baker   Tacoma     WA Fred Jones  Vancouver BC

    Read the article

  • Java inheritance and super() isn't working as expected

    - by dwwilson66
    For a homework assignment, I'm working with the following. It's an assigned class structure, I know it's not the best design by a long shot. Class | Extends | Variables -------------------------------------------------------- Person | None | firstName, lastName, streetAddress, zipCode, phone CollegeEmployee | Person | ssn, salary,deptName Faculty | CollegeEmployee | tenure(boolean) Student | person | GPA,major So in the Faculty class... public class Faculty extends CollegeEmployee { protected String booleanFlag; protected boolean tenured; public Faculty(String firstName, String lastName, String streetAddress, String zipCode, String phoneNumber,String ssn, String department,double salary) { super(firstName,lastName,streetAddress,zipCode,phoneNumber, ssn,department,salary); String booleanFlag = JOptionPane.showInputDialog (null, "Tenured (Y/N)?"); if(booleanFlag.equals("Y")) tenured = true; else tenured = false; } } It was my understanding that super() in Faculty would allow access to the variables in CollegeEmployee as well as Person. With the code above, it compiles fine when I ONLY include the Person variables. As soon as I try to use ssn, department, or salary I get the following compile errors. Faculty.java:15: error: constructor CollegeEmployee in class CollegeEmployee can not be applied to the given types: super(firstName,lastName,streetAddress,zipCode,phoneNumber,ssn,department,salary); ^ Required: String,String,String,String,String Found: String,String,String,String,String,String,String,String reason: actual and formal argument lists differ in length I'm completely confused by this error...which is the actual and formal? Person has five arguments, CollegeEmployee has 3, so my guess is that something's funky with how the parameters are being passed...but I'm not quite sure where to begin fixing it. What am I missing?

    Read the article

  • Cannot add namespace prefix to children using XSL

    - by Erdal
    I checked many answers here and I think I am almost there. One thing that is bugging me (and for some reason my peer needs it) follows: I have the following input XML: <?xml version="1.0" encoding="utf-8"?> <MyRoot> <MyRequest CompletionCode="0" CustomerID="9999999999"/> <List TotalList="1"> <Order CustomerID="999999999" OrderNo="0000000001" Status="Shipped"> <BillToAddress ZipCode="22221"/> <ShipToAddress ZipCode="22222"/> <Totals Tax="0.50" SubTotal="10.00" Shipping="4.95"/> </Order> </List> <Errors/> </MyRoot> I was asked to produce this: <ns:MyNewRoot xmlns:ns="http://schemas.foo.com/response" xmlns:N1="http://schemas.foo.com/request" xmlns:N2="http://schemas.foo.com/details"> <N1:MyRequest CompletionCode="0" CustomerID="9999999999"/> <ns:List TotalList="1"> <N2:Order CustomerID="999999999" Level="Preferred" Status="Shipped"> <N2:BillToAddress ZipCode="22221"/> <N2:ShipToAddress ZipCode="22222"/> <N2:Totals Tax="0.50" SubTotal="10.00" Shipping="4.95"/> </N2:Order> </ns:List> <ns:Errors/> </ns:MyNewRoot> Note the children of the N2:Order also needs N2: prefix as well as the ns: prefix for the rest of the elements. I use the XSL transformation below: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="/MyRoot"> <MyNewRoot xmlns="http://schemas.foo.com/response" xmlns:N1="http://schemas.foo.com/request" xmlns:N2="http://schemas.foo.com/details"> <xsl:apply-templates/> </MyNewRoot> </xsl:template> <xsl:template match="/MyRoot/MyRequest"> <xsl:element name="N1:{name()}" namespace="http://schemas.foo.com/request"> <xsl:copy-of select="namespace::*"/> <xsl:apply-templates select="@* | node()"/> </xsl:element> </xsl:template> <xsl:template match="/MyRoot/List/Order"> <xsl:element name="N2:{name()}" namespace="http://schemas.foo.com/details"> <xsl:copy-of select="namespace::*"/> <xsl:apply-templates select="@* | node()"/> </xsl:element> </xsl:template> </xsl:stylesheet> This one doesn't process the ns (I couldn't figure this out). When I process thru the above the XSL transformation with AltovaXML I end up with below: <MyNewRoot xmlns="http://schemas.foo.com/response" xmlns:N1="http://schemas.foo.com/request" xmlns:N2="http://schemas.foo.com/details"> <N1:MyRequest CompletionCode="0" CustomerID="9999999999"/> <List xmlns="" TotalList="1"> <N2:Order CustomerID="999999999" Level="Preferred" Status="Shipped"> <BillToAddress ZipCode="22221"/> <ShipToAddress ZipCode="22222"/> <Totals Tax="0.50" SubTotal="10.00" Shipping="4.95"/> </N2:Order> </List> <Errors/> </MyNewRoot> Note that N2: prefix for the children of Order is not there after the XSL transformation. Also additional xmlns="" in the Order header (for some reason). I couldn't figure out putting the ns: prefix for the rest of the elements (like Errors and List). First of all, why would I need to put the prefix for the children if the parent already has it. Doesn't the parent namespace dictate the children nodes/attribute namespaces? Secondly, I want to add the prefixes in the above XML as expected, how can I do that with XSL?

    Read the article

  • SQL Server Query solution cum Suggestion Required

    - by Nirmal
    Hello All... I have a following scenario in my SQL Server 2005 database. zipcodes table has following fields and value (just a sample): zipcode latitude longitude ------- -------- --------- 65201 123.456 456.789 65203 126.546 444.444 and place table has following fields and value : id name zip latitude longitude -- ---- --- -------- --------- 1 abc 65201 NULL NULL 2 def 65202 NULL NULL 3 ghi 65203 NULL NULL 4 jkl 65204 NULL NULL Now, my requirement is like I want to compare my zip codes of place table and update the available latitude and longitude fields from zipcode table. And there are some of the zipcodes which has no entry in zipcode table, so that should remain null. And the major issue is like I have more then 50,00,000 records in my db. So, query should support this feature. I have tried some of the solutions but unfortunately not getting proper output. Any help would be appreciated...

    Read the article

  • MSSql Query solution cum Suggestion Required

    - by Nirmal
    Hello All... I have a following scenario in my MSSql 2005 database. zipcodes table has following fields and value (just a sample): zipcode latitude longitude ------- -------- --------- 65201 123.456 456.789 65203 126.546 444.444 and "place" table has following fields and value : id name zip latitude longitude -- ---- --- -------- --------- 1 abc 65201 NULL NULL 2 def 65202 NULL NULL 3 ghi 65203 NULL NULL 4 jkl 65204 NULL NULL Now, my requirement is like I want to compare my zip codes of "place" table and update the available latitude and longitude fields from "zipcode" table. And there are some of the zipcodes which has no entry in "zipcode" table, so that should remain null. And the major issue is like I have more then 50,00,000 records in my db. So, query should support this feature. I have tried some of the solutions but unfortunately not getting proper output. Any help would be appreciated...

    Read the article

  • ASP.NET C# - do you need a separate datasource for each gridview? [closed]

    - by Brian McCarthy
    Do you need a separate datasource for each gridview if each gridview is accessing the same database but different tables in the database? I'm getting an error on AppSettings that says non-invocable member. What is the problem with it? Here's the c# code-behind: protected void Search_Zip_Plan_Age_Button_Click(object sender, EventArgs e) { var _with1 = this.ZipPlan_SqlDataSource; _with1.SelectParameters.Clear(); _with1.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("PriceFinderConnectionString").ToString; _with1.SelectCommand = "ssp_get_zipcode_plan"; _with1.SelectParameters.Add("ZipCode", this.ZipCode.Text); _with1.SelectParameters.Add("PlanCode", this.PlanCode.Text); _with1.SelectParameters.Add("Age", this.Age.Text); _with1.SelectCommandType = SqlDataSourceCommandType.StoredProcedure; _with1.CancelSelectOnNullParameter = false; Search_Results_GridView.DataBind(); } thanks!

    Read the article

  • Code Complete 2ed, composition and delegation.

    - by Arlukin
    Hi there. After a couple of weeks reading on this forum I thought it was time for me to do my first post. I'm currently rereading Code Complete. I think it's 15 years since the last time, and I find that I still can't write code ;-) Anyway on page 138 in Code Complete you find this coding horror example. (I have removed some of the code) class Emplyee { public: FullName GetName() const; Address GetAddress() const; PhoneNumber GetWorkPhone() const; ... bool IsZipCodeValid( Address address); ... private: ... } What Steve thinks is bad is that the functions are loosely related. Or has he writes "There's no logical connection between employees and routines that check ZIP codes, phone numbers or job classifications" Ok I totally agree with him. Maybe something like the below example is better. class ZipCode { public: bool IsValid() const; ... } class Address { public: ZipCode GetZipCode() const; ... } class Employee { public: Address GetAddress() const; ... } When checking if the zip is valid you would need to do something like this. employee.GetAddress().GetZipCode().IsValid(); And that is not good regarding to the Law of Demeter ([http://en.wikipedia.org/wiki/Law_of_Demeter][1]). So if you like to remove two of the three dots, you need to use delegation and a couple of wrapper functions like this. class ZipCode { public: bool IsValid(); } class Address { public: ZipCode GetZipCode() const; bool IsZipCodeValid() {return GetZipCode()->IsValid()); } class Employee { public: FullName GetName() const; Address GetAddress() const; bool IsZipCodeValid() {return GetAddress()->IsZipCodeValid()); PhoneNumber GetWorkPhone() const; } employee.IsZipCodeValid(); But then again you have routines that has no logical connection. I personally think that all three examples in this post are bad. Is it some other way that I haven't thougt about? //Daniel

    Read the article

  • SQL Query - Need some basic help

    - by Chuck Folds
    I'm in need of some basic TSQL help. Here's my table layout: Orders Table SSN ZipCode ZipLookup Table ZipCode State All columns are varchars. How would I get a list of States with the number of distinct SSN's in each state? Preferably, if a particular SSN has orders from multiple states only the state with the most orders would be counted for that SSN. Thank you for any tips you can give me.

    Read the article

  • User Mailer Failing

    - by Trevor Nederlof
    I have setup a process in my User model to send a bunch of @users to a mailing script, user_mailer.rb I am using the http://postageapp.com app to send out emails. The users are getting to the User_mailer but I am getting an error from there. Can anyone please point me in the right direction. User Model: class User < ActiveRecord::Base acts_as_authentic def self.mail_out weekday = Date.today.strftime('%A').downcase @users = find(:all, :conditions => {"#{weekday}sub".to_sym => 't'}) UserMailer.deliver_mail_out(@users) end end User_mailer.rb class UserMailer < ActionMailer::Base def mail_out(users) @recipients = { } users.each do |user| @recipients[user.email] = { :zipcode => user.zipcode } end from "[email protected]" subject "Check out the trailer of the day!" body :user => user end end mail_out.html.erb {{zipcode}}, Please check out the trailer of the day at http://www.dailytrailer.net Thank you! -- The DailyTrailer.net Team User db schema create_table "users", :force => true do |t| t.string "email" t.date "birthday" t.string "gender" t.string "zipcode" t.datetime "created_at" t.datetime "updated_at" t.string "crypted_password" t.string "password_salt" t.string "persistence_token" t.string "mondaysub", :default => "f", :null => false t.string "tuesdaysub", :default => "f", :null => false t.string "wednesdaysub", :default => "f", :null => false t.string "thursdaysub", :default => "f", :null => false t.string "fridaysub", :default => "f", :null => false t.string "saturdaysub", :default => "f", :null => false t.string "sundaysub", :default => "f", :null => false end Error: /var/lib/gems/1.8/gems/rails-2.3.5/lib/commands/runner.rb:48: undefined method `name' for #<User:0xb6e8ae48> (NoMethodError) from /home/tnederlof/Dropbox/Ruby/daily_trailer/app/models/user_mailer.rb:5:in `mail_out' from /home/tnederlof/Dropbox/Ruby/daily_trailer/app/models/user_mailer.rb:4:in `each' from /home/tnederlof/Dropbox/Ruby/daily_trailer/app/models/user_mailer.rb:4:in `mail_out' from /home/tnederlof/.gem/ruby/1.8/gems/actionmailer-2.3.5/lib/action_mailer/base.rb:459:in `__send__' from /home/tnederlof/.gem/ruby/1.8/gems/actionmailer-2.3.5/lib/action_mailer/base.rb:459:in `create!' from /home/tnederlof/.gem/ruby/1.8/gems/actionmailer-2.3.5/lib/action_mailer/base.rb:452:in `initialize' from /home/tnederlof/.gem/ruby/1.8/gems/actionmailer-2.3.5/lib/action_mailer/base.rb:395:in `new' from /home/tnederlof/.gem/ruby/1.8/gems/actionmailer-2.3.5/lib/action_mailer/base.rb:395:in `method_missing' from /home/tnederlof/Dropbox/Ruby/daily_trailer/app/models/user.rb:13:in `mail_out' from (eval):1 from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `eval' from /var/lib/gems/1.8/gems/rails-2.3.5/lib/commands/runner.rb:48 from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require' from script/runner:3

    Read the article

  • NOAA web service for current weather

    - by Brian
    I want to get the current weather conditions from the NOAA. I know they have a SOAP web service that can be used to get weather forecasts and XML files for current weather conditions for each of their weather stations. I could just use the XML file for the weather station nearest to where I want, but there doesn't seem to be an easy way to search for the proper xml file by zipcode. Is there a simple way to get current weather conditions by zipcode from the NOAA?

    Read the article

  • Not allowing characters after Space. Mysql Insert With PHP

    - by Jake
    Ok so I think this is easy but I dont know (I'm a novice to PHP and MySQL). I have a select that is getting data from a table in the database. I am simply taking whatever options the user selects and putting it into a separate table with a php mysql insert statement. But I am having a problem. When I hit submit, everything is submitted properly except for any select options that have spaces don't submit after the first space. For example if the option was COMPUTER REPAIR, all that would get sent is COMPUTER. I will post code if needed, and any help would be greatly appreciated. Thanks! Ok here is my select code: <?php include("./config.php"); $query="SELECT id,name FROM category_names ORDER BY name"; $result = mysql_query ($query); echo"<div style='overflow:auto;width:100%'><label>Categories (Pick three that describe your business)</label><br/><select name='select1'><option value='0'>Please Select A Category</option>"; // printing the list box select command while($catinfo=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option>$catinfo[name]</option><br/> "; } echo"</select></div>"; ?> And here is my insert code ( Just to let you know its got everything not just the select!) ?php require("./config.php"); $companyname = mysql_real_escape_string(addslashes(trim($_REQUEST['name']))); $phone = mysql_real_escape_string(addslashes($_REQUEST['phone'])); $zipcode = mysql_real_escape_string(addslashes($_REQUEST['zipcode'])); $city = mysql_real_escape_string(addslashes($_REQUEST['city'])); $description = mysql_real_escape_string(addslashes($_REQUEST['description'])); $website = mysql_real_escape_string(addslashes($_REQUEST['website'])); $address = mysql_real_escape_string(addslashes($_REQUEST['address'])); $other = mysql_real_escape_string(addslashes($_REQUEST['other'])); $payment = mysql_real_escape_string(addslashes($_REQUEST['payment'])); $products = mysql_real_escape_string(addslashes($_REQUEST['products'])); $email = mysql_real_escape_string(addslashes($_REQUEST['email'])); $select1 = mysql_real_escape_string(addslashes($_REQUEST['select1'])); $select2 = mysql_real_escape_string(addslashes($_REQUEST['select2'])); $select3 = mysql_real_escape_string(addslashes($_REQUEST['select3'])); $save=$_POST['save']; if(!empty($save)){ $sql="INSERT INTO gj (name, phone, city, zipcode, description, dateadded, website, address1, other2, payment_options, Products, email,cat1,cat2,cat3) VALUES ('$companyname','$phone','$city','$zipcode','$description',curdate(),'$website','$address','$other','$payment','$products','$email','$select1','$select2','$select3')"; if (!mysql_query($sql,$link)) { die('Error: ' . mysql_error()); } echo "<br/><h2><font color='green' style='font-size:15px'>1 business added</font></h2>"; mysql_close($link); } ?>

    Read the article

  • Updated data is not loaded in the same browser(using Ajax )

    - by Mouli
    Initilly load some datas into dropdown list. It contain company code and company related fields in Textbox. Using Ajax to load the company related Fields in onchange Function I edit the company related fields and update it. Its updated Successfully then i Click the back button and refresh the browser. I select the updated company form the dropdown list. It always list the old value insted of updated data. I want to show the updated fields into corresponding textbox. This part of coding is to load the companyname into dropdown list <% DBAccess dbAccess = Util.initDatabaseAccess(); ResultSet rs = null; ResultSet rsEdit = null; int updateSuccess = 0; String button = request.getParameter("saveAction"); rs = dbAccess.executeQuery("select companyname,Companycode,companyid from yosemitecompany where cmpstatus=1 order by companyname"); %> My Ajax function <script> function showCompanyDetails(str) { if (str=="") { document.getElementById("CompanyName").innerHTML=""; return; } if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { var resValue=new Array(); resValue = xmlhttp.responseText.split("$"); document.getElementById("CompanyName").value=resValue[0]; document.getElementById("StreetName1").value=(resValue[1]!=null && !resValue[1].equalsIgnoreCase("null") && resValue[1].length>0?resValue[1]:""); document.getElementById("StreetName2").value=(resValue[2]!=null && !resValue[2].equalsIgnoreCase("null") && resValue[2].length>0?resValue[2]:""); document.getElementById("City").value=(resValue[3]!=null && !resValue[3].equalsIgnoreCase("null") && resValue[3].length>0?resValue[3]:""); document.getElementById("Zipcode").value=trim((resValue[5]!=null && !resValue[5].equalsIgnoreCase("null") && resValue[5].length>0?resValue[5]:"")); document.getElementById("officePhone").value=(resValue[6]!=null && !resValue[6].equalsIgnoreCase("null") && resValue[6].length>0?resValue[6]:""); document.getElementById("Fax1").value=(resValue[7]!=null && !resValue[7].equalsIgnoreCase("null") && resValue[7].length>0?resValue[7]:""); document.getElementById("email").value=(resValue[8]!=null && !resValue[8].equalsIgnoreCase("null") && resValue[8].length>0?resValue[8]:""); document.getElementById("WebSite").value=(resValue[9]!=null && !resValue[9].equalsIgnoreCase("null") && resValue[9].length>0?resValue[9]:""); document.getElementById("description").value=(resValue[10]!=null && !resValue[10].equalsIgnoreCase("null") && resValue[10].length>0?resValue[10]:""); document.getElementById("companycode").value=resValue[11]; document.getElementById("tempCompanyId").value=resValue[12]; document.getElementById("tempStateId").value=resValue[13]; stateID = resValue[13]; countryID = resValue[14]; processAjaxRequestPost('ajaxRequestPost','SingleListHandler','getCountryListDetails', document.getElementById("tempCompanyId").value); showTimezone(resValue[15]); document.getElementById("userName").value=resValue[16]; document.getElementById("passWord").value=resValue[17]; } } xmlhttp.open("GET","customerDetail.jsp?val="+str,true); xmlhttp.send(); } </script> My Update function <%if(updateSuccess <= 0){ if(button != null && button.equalsIgnoreCase("update")) { String companyCode = request.getParameter("companycode").trim(); String companyName = request.getParameter("CompanyName").trim(); String StreetName1 = request.getParameter("StreetName1").trim(); String StreetName2 = request.getParameter("StreetName2").trim(); String City = request.getParameter("City").trim(); String Zipcode = request.getParameter("Zipcode").trim(); String officePhone = request.getParameter("officePhone").trim(); String Fax1 = request.getParameter("Fax1").trim(); String email = request.getParameter("email").trim(); String WebSite = request.getParameter("WebSite").trim(); String description = request.getParameter("description").trim(); String companyid = request.getParameter("tempCompanyId").trim(); String stateId = request.getParameter("tempStateId").trim(); String timeZone = request.getParameter("timezone").trim(); String uploadCustomerLogo = request.getParameter("uploadCustomerLogo").trim(); String userName = request.getParameter("userName").trim(); String passWord = request.getParameter("passWord").trim(); String smtpInsertFlag = "NO"; String getCompanyId = null; updateSuccess = dbAccess.executeUpdate("update yosemitecompany set companyname='"+com.zoniac.util.Util.deQuoteForSingleQuote(companyName)+"', streetname1='"+com.zoniac.util.Util.deQuoteForSingleQuote(StreetName1)+"', streetname2='"+com.zoniac.util.Util.deQuoteForSingleQuote(StreetName2)+"', cityname='"+com.zoniac.util.Util.deQuoteForSingleQuote(City)+"', zipcode='"+com.zoniac.util.Util.deQuoteForSingleQuote(Zipcode)+"', phonenumber1='"+com.zoniac.util.Util.deQuoteForSingleQuote(officePhone)+"', fax1='"+com.zoniac.util.Util.deQuoteForSingleQuote(Fax1)+"', email1='"+com.zoniac.util.Util.deQuoteForSingleQuote(email)+"', website='"+com.zoniac.util.Util.deQuoteForSingleQuote(WebSite)+"', description='"+com.zoniac.util.Util.deQuoteForSingleQuote(description)+"',timezoneid="+timeZone+", stateid="+stateId+" where companyid='"+companyid+"'"); if(rs != null) { rs = null; dbAccess.close(); } } %> My customerDetail.jsp File <% String val = request.getParameter("val"); DBAccess dbAccess = Util.initDatabaseAccess(); ResultSet rs = null; String outputResult = null; String ff = "NO"; rs = dbAccess.executeQuery("select companyname,streetname1,streetname2,cityname,(select statename from state where stateid = (select stateid from yosemitecompany where companyid ="+val+"))as state,zipcode,phonenumber1,fax1,email1,website,description,companycode,companyid,(select stateid from state where stateid = (select stateid from yosemitecompany where companyid ="+val+"))as statecode,(select countryid from country where countryid =(select countryid from state where stateid = (select stateid from yosemitecompany where companyid ="+val+")))as countryid,timezoneid from yosemitecompany where companyid = "+val+""); if(rs.next()){ outputResult = rs.getString(1)+"$"+rs.getString(2)+"$"+rs.getString(3)+"$"+rs.getString(4)+"$"+rs.getString(5)+"$"+rs.getString(6)+"$"+rs.getString(7)+"$"+rs.getString(8)+"$"+rs.getString(9)+"$"+rs.getString(10)+"$"+rs.getString(11)+"$"+rs.getString(12)+"$"+rs.getString(13)+"$"+rs.getString(14)+"$"+rs.getString(15)+"$"+rs.getString(16); } rs = null; rs = dbAccess.executeQuery("select username,password from EMAILAUTHENTICATIONDETAILS where companyid="+val); if(rs.next()){ ff="YES"; outputResult += "$"+rs.getString(1)+"$"+rs.getString(2); } if(ff.equals("NO")){ outputResult += "$$"; } out.println(outputResult); outputResult = null; ff = "NO"; if(rs!=null) { rs = null; dbAccess.close(); } %>

    Read the article

  • Jquery question : maintain focus upon appending a row?

    - by PoppySeedsAndAppleJuice
    The function below checks whether the id entered is already in the database, and if it is, then it adds some html to the table. I'm not sure if it's directly related to my issue or not, but, essentially, a user will place the focus on the id input field and enters an id. Using ajax, it posts to a php script and returns data if rows are found and nothing if it doesn't. If the user then tabs over to the next input field (zipcode), or clicks in another input field, they essentially have to do so twice. The cursor "flashes" in the field briefly and then focuses out. I tried adding in a focus(), but the behavior didn't change. So, the html looks like this: <table id="tableSearchData" class="searchlist" style="width: 789px;"> <thead> <tr> <th>ID</th> <th>Zip Code</th> <th>Radius (in miles)</th> </tr> </thead> <tbody> <tr class="odd"> <!-- PROBLEM is described below --> <!-- User clicks in <input name="id[]"> and ID is checked --> <!-- User presses "tab" or clicks in <input name="zipcode[] (in the *same* row) and cursor flashes, then goes out of focus so that the user has to click in the field again --> <td class="center sorting_1"><input type="text" value="" name="id[]"></td> <td class="center"><input type="text" value="" name="zipcode[]"></td> <td class="center"><input type="text" value="" name="radius[]"></td> </tr> </tbody> </table> Here's the jquery function... Like I said, I'm not sure if it's directly related to the problem I'm having, but, thought I should include it because I suppose it's likely there is something happening there... $("#tableSearchData > tbody > tr > td > input[name=id[]]").focusout(function() { var row = $(this).closest("tr").get(0); var sData = $(this).serialize(); $.ajax({ type: "POST", url: "checkid.php", data: sData, success: function(html) { $(row).replaceWith(html); $(".preset").each(function() { $(this).attr("disabled", true); }); $(row).closest("input[name=zipcode[]]").focus(); } }); });

    Read the article

  • jquery - "click" on keypress?

    - by WonderBugger
    I have an ajax search form that works fine if you click "submit" in that you enter a zipcode, click the "Enter" button and up pops results instantly. I'm trying to make it so that if the user presses "enter" on the keyboard, it has the same effect. It looks like it's submitting, but no results come up... I tried: if($('#search').length) { $('#zipcode').keyup(function(e) { if(e.keyCode == 13) { e.preventDefault(); $('#search').submit(); } }); }

    Read the article

  • Web Services Example - Part 1: Declarative

    - by Denis T
    In this edition of the ADF Mobile blog we'll tackle part 1 of our Web Service examples. In this posting we'll take a look at using a declarative SOAP Web Service. Getting the sample code: Just click here to download a zip of the entire project. You can unzip it and load it into JDeveloper and deploy it either to iOS or Android. Please follow the previous blog posts if you need help getting JDeveloper or ADF Mobile installed. Defining our Web Service: First off, we should mention that this sample code is using a public web service provided free by CDYNE Corporation that provides weather forecasts by zipcode. Sometimes this service goes down so please ensure you know it's up before reporting this example isn't working. Let's take a look at the web service.  We created this by using the "Web Service Data Control" from the New Gallery and using this link to this wsdl:  "http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"   This web service has several methods but we're interested in GetCityForecastByZIP which takes a single string parameter for the zipcode and the second method, GetWeatherInformation that enumerates all possible forecast descriptions and associated image URLs.  The latter we'll use in the next edition but we included it here for completeness. Defing the Application: After adding a feature to the adfmf-feature.xml file, we added a taskflow to host the application flow.  This comprises of a home screen with a list with items for each method in the web service, "Forecast by Zip" and "Weather Info".  In this application we've also decided to hide the navigation bar since there is only one feature in the application. Forecast by Zip: The "Forecast By ZIP" option first presents the user with a screen where they can enter a zipcode and when the "Search" button is tapped, it executes the GetCityForecastByZIP method.  This is done by binding an Action binding to that method. The easiest way to accomplish this is to just drag & drop the method from the Data Control palette to the AMX page and drop it as a button and let the framework hook it up for you.  There is an inputText component on the page that is bound to a pageFlowScope variable called "zip".  This is used as the parameter to the Action binding when it is executed.  Because the actionListener attribute of the commandButton executes the Web Service each time, we ensure that the method is invoked every time the button is clicked. Weather Info: Unlike the previous method, this time instead of explictly executing the web service method we are using deferred invocation.  What this means is that we will bind to the results of the method and the framework will execute the method when it the data is required to be rendered.  We do this by simply doing a drag & drop of the results of the GetWeatherInformation to the AMX page.  When the page is rendered and the bindings are resolved the framework invokes the method.  This executes the method only when it is needed and fills the Data Control provider.  Because we never re-execute the method, you can click from Home to Weather Info and back many times and the web service is only ever invoked once. Issues and Possible Improvements: One thing you will quickly realize with this example is that the error handling is done by the framework for you. For simple examples this is fine but for real applications you'll want to customize these error messages.  With the declarative invocation of web services, this is difficult.  This is one aspect we'll address in the second installment of the web service examples where we will show you how to do programmatic invocation which allows you better error handling. Another issue you will notice with this example is that we can enumerate the weather information but there isn't an easy way to use that information to show the corresponding description and image as part of the forecast results.  We'll show you how to do this in the next example.

    Read the article

  • Django tests failing on invalid keyword argument

    - by Darwin Tech
    I have a models.py like so: from django.db import models from django.contrib.auth.models import User from datetime import datetime class UserProfile(models.Model): user = models.OneToOneField(User) def __unicode__(self): return self.user.username class Project(models.Model): user = models.ForeignKey(UserProfile) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) product = models.ForeignKey('tool.product') module = models.ForeignKey('tool.module') model = models.ForeignKey('tool.model') zipcode = models.IntegerField(max_length=5) def __unicode__(self): return unicode(self.id) And my tests.py: from django.test import TestCase, Client # --- import app models from django.contrib.auth.models import User from tool.models import Module, Model, Product from user_profile.models import Project, UserProfile # --- unit tests --- # class UserProjectTests(TestCase): fixtures = ['admin_user.json'] def setUp(self): self.product1 = Product.objects.create( name='bar', ) self.module1 = Module.objects.create( name='foo', enable=True ) self.model1 = Model.objects.create( module=self.module1, name='baz', enable=True ) self.user1 = User.objects.get(pk=1) ... def test_can_create_project(self): self.project1 = Model.objects.create( user=self.user1, product=self.product1, module=self.module1, model=self.model1, zipcode=90210 ) self.assertEquals(self.project1.zipcode, 90210) But I get a TypeError: 'product' is an invalid keyword argument for this function error. I'm not sure what is failing but I'm guessing something to do with the FK relationships... Any help would be much appreciated.

    Read the article

  • Address String Split in javscript

    - by Arasoi
    Ok folks I have bombed around for a few days trying to find a good solution for this one. What I have is two possible address formats. 28 Main St Somecity, NY 12345-6789 or Main St Somecity, Ny 12345-6789 What I need to do Is split both strings down into an array structured as such address[0] = HousNumber address[1] = Street address[2] = City address[3] = State address[4] = ZipCode My major problem is how to account for the lack of a house number. with out having the whole array shift the data up one. address[0] = Street address[1] = City address[2] = State address[3] = ZipCode [Edit] For those that are wondering this is what i am doing atm . (cleaner version) place = response.Placemark[0]; point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]); FCmap.setCenter(point,12); var a = place.address.split(','); var e = a[2].split(" "); var x = a[0].split(" "); var hn = x.filter(function(item,index){ return index == 0; }); var st = x.filter(function(item,index){ return index != 0; }); var street = ''; st.each(function(item,index){street += item + ' ';}); results[0] = new Hash({ FullAddie: place.address, HouseNum: hn[0], Dir: '', Street: street, City: a[1], State: e[1], ZipCode: e[2], GPoint: new GMarker(point), Lat: place.Point.coordinates[1], Lng: place.Point.coordinates[0] }); // End Address Splitting

    Read the article

< Previous Page | 1 2 3 4 5 6  | Next Page >