Can't reuse HTTPRequest  --- how can I reuse this code?

public var getCategories: HttpRequest = HttpRequest {
    location: "http://lydias-kitchen.com/FXcategories.php";
    onInput: function(is: java.io.InputStream) {
        try {
            if(is.available()> 0){
              categories.parser.input = is;
              categories.parser.parse();
         } finally {
             is.close();
             var a = ids.size();
             println ("categories ids size = {a}");
             var b = bind (a-1);
             for (i in [0 .. b]){
                println("ids = { ids} names = {names[i]}");
categories.newCategoryItem = com.javafx.preview.control.MenuItem {
text: names[i]
id: ids[i]
onMouseClicked: function(e:javafx.scene.input.MouseEvent) {
Main.CategoryId = e.node.id;
println("category id = {Main.CategoryId}") ;
recipes.getRecipes.start();
font: Font {name: "Times New Roman" size: 20}
graphic: ImageView {image: Image {url: "{__DIR__}images/ball.png"}
fitWidth: 32
fitHeight: 32
insert newCategoryItem into Main.categoryItems;
{code}
I use the above code to get a PHP file to return all the recipe categories in a database table. The insert -> creates a dynamic menu. the println has confirmed that each menu item is assigned the correct text and recipe ID.
I can click any one of the 19 "category" menu items generated and the "OnMouseClicked:" will call and start getRecipes.
The code for getRecipes is identical to the code shown except that the returned recipes are inserted into the "recipe" menu instead of the "category" menu.
Now it doesn't matter if I click an item in the "Recipe" or "Category" menu ......... any attempt to reuse the HTTPRequest functions will return:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: request reuse not permitted
at javafx.io.http.HttpRequest.start(HttpRequest.fx:1316)
at jim2.categories$categories$Script$1Local$5$1ForPart$3.invoke$(categories.fx:59)
at com.sun.javafx.functions.Function1.invoke(Function1.java:44)
at com.sun.javafx.functions.Function1.invoke$(Function1.java:38)
at javafx.scene.Node.impl_processMouseEvent(Node.fx:2938)
at javafx.scene.Node.preprocessMouseEvent(Node.fx:2967)
at javafx.scene.Scene$MouseHandler.process(Scene.fx:1559)
at javafx.scene.Scene$MouseHandler.process(Scene.fx:1421)
at javafx.scene.Scene.impl_processMouseEvent(Scene.fx:686)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.fx:1016)
at com.sun.javafx.tk.swing.SwingScene$SwingScenePanel.doMouseEvent(SwingScene.java:446)
at com.sun.javafx.tk.swing.SwingScene$SwingScenePanel.mouseClicked(SwingScene.java:454)
at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Since this is a recipe program you can see that I'm going to have to call the database for data each time a different category or recipe is called.
*QUESTION: What do I have to do to get the HTTPRequest to work repeatly*
Edited by: JWK on Feb 28, 2011 11:54 AM

Exactly what it says; Create a new http request every single time you want to retrieve the data:
//Records data retrieved from the request.
var data : String;
function makeRequest() : Void {
    //Create a new request object every time this function is called.
    var request : HttpRequest = HttpRequest {
        location: "http://en.wikipedia.org/"
        onInput: function(io : InputStream) {
            //Read input to data string and close input stream
    //Make the request connect.
    request.start();
//Get the data
makeRequest();
//Get the data again.
makeRequest();Each individual HttpRequest object is meant to be used once and only once so you need to create a new one each time.

Similar Messages

  • I have gmail and hotmail account on my macbook. In gmail I can visualize all the mailboxes but in hotmail i only can see the inbox ¿how can I visualize the rest of the mailboxes? thanks

    I have gmail and hotmail account on my macbook.
    In gmail I can visualize all the mailboxes but in hotmail i only can see the inbox ¿how can I visualize the rest of the mailboxes?
    I have the same problem with my ipad; the solution would be the same?
    thanks

    Hello Sophie59
    You should be able to see two different tabs when setting up the email if you go to Other > Add Mail Account. Once you enter in the email address and password, you should be at the next screen to provide more details about the email as far as incoming and outgoing servers and at the top there will be a blue section to add it in as a POP or IMAP email account. Check out the article below for further troubleshooting and emails setup options.
    iOS: Troubleshooting Mail
    http://support.apple.com/kb/ts3899
    iOS: Adding an email account
    http://support.apple.com/kb/ht4810
    Regards,
    -Norm G.

  • I have an iphone4 and my husband merge his numbers with mine and i think it was deleted can you tell me how can he get his number back on his phone

    have an iphone4 and my husband merge his numbers with mine and i think it was deleted can you tell me how can he get his number back on his phone

    Do you possibly mean the contacts have been merged?
    If so, where are each of you syncing contacts?  A supported application on the computer? iCloud or another cloud service? An Exchange server?
    WIthout details, it's difficult to offer specific resolutions.

  • HT5621 I bought my iMac from someone. Everything was changed over to my name however when I try to update programs it only shows the old users apple ID and I can't update. How do I change this so I can update the applications and have everything fully und

    I bought my iMac from someone. Everything was changed over to my name however when I try to update programs it only shows the old users apple ID and I can't update. How do I change this so I can update the applications and have everything fully under me?

    The first thing to do with a second-hand computer is to erase the internal drive and install a clean copy of OS X. You — not the previous owner — must do that. How you do it depends on the model, and on whether you already own another Mac. If you're not sure of the model, enter the serial number on this page. Then find the model on this page to see what OS version was originally installed.
    1. You don't own another Mac.
    If the machine shipped with OS X 10.4 or 10.5, you need a boxed and shrink-wrapped retail Snow Leopard (OS X 10.6) installation disc from the Apple Store or a reputable reseller — not from eBay or anything of the kind. If the machine has less than 1 GB of memory, you'll need to add more in order to install 10.6. Preferably, install as much memory as it can take, according to the technical specifications.
    If the machine shipped with OS X 10.6, you need the installation media that came with it: gray installation discs, or a USB flash drive for some MacBook Air models. For early MBA models, you may need a USB optical drive or Remote Disc. You should have received the media from the previous owner, but if you didn't, order replacements from Apple. A retail disc, or the gray discs from another model, will not work.
    To boot from an optical disc or a flash drive, insert it, then reboot and hold down the C key at the startup chime. Release the key when you see the gray Apple logo on the screen.
    If the machine shipped with OS X 10.7 or later, you don't need media. It should boot into Internet Recovery mode when you hold down the key combination option-command-R at the startup chime. Release the keys when you see a spinning globe.
    2. You do own another Mac.
    If you already own another Mac that was upgraded in the App Store to the version of OS X that you want to install, and if the new Mac is compatible with it, then you can install it. Use Recovery Disk Assistant to create a bootable USB device and boot the new Mac from it by holding down the C key at the startup chime. Alternatively, if you have a Time Machine backup of OS X 10.7.3 or later on an external hard drive (not a Time Capsule or other network device), you can boot from that by holding down the option key and selecting it from the row of icons that appears. Note that if your other Mac was never upgraded in the App Store, you can't use this method.
    Once booted in Recovery, launch Disk Utility and select the icon of the internal drive — not any of the volume icons nested beneath it. In the Partition tab, select the default options: a GUID partition table with one data volume in Mac OS Extended (Journaled) format. This operation will permanently remove all existing data on the drive.
    After partitioning, quit Disk Utility and run the OS X Installer. You will need the Apple ID and password that you used to upgrade. When the installation is done, the system will automatically reboot into the Setup Assistant, which will prompt you to transfer the data from another Mac, its backups, or from a Windows computer. If you have any data to transfer, this is usually the best time to do it.
    Then run Software Update and install all available system updates from Apple. To upgrade to a major version of OS X newer than 10.6, get it from the Mac App Store. Note that you can't keep an upgraded version that was installed by the previous owner. He or she can't legally transfer it to you, and without the Apple ID you won't be able to update it in Software Update or reinstall, if that becomes necessary. The same goes for any App Store products that the previous owner installed — you have to repurchase them.
    3. Other issues
    If you see a lock screen when trying to boot from installation media or in Recovery mode, then a firmware password was set by the previous owner, or the machine was remotely locked via iCloud. You'll either have to contact the owner or take the machine to an Apple Store or another authorized service provider to be unlocked. You may be asked for proof of ownership.
    If the previous owner "accepted" the bundled iLife applications (iPhoto, iMovie, and Garage Band) in the App Store so that he or she could update them, then they're linked to that Apple ID and you won't be able to download them without buying them. Reportedly, Mac App Store Customer Service has sometimes issued redemption codes for these apps to second owners who asked.
    If the previous owner didn't deauthorize the computer in the iTunes Store under his Apple ID, you wont be able to  authorize it immediately under your ID. In that case, you'll either have to wait up to 90 days or contact iTunes Support.
    When trying to create a new iCloud account, you might get a failure message: "Account limit reached." Apple imposes a limit of three iCloud account setups per device. Erasing the device does not reset the limit. You can still use an account that was created on another device, but you won't be able to create a new one. Contact iCloud Support for more information.

  • I am residing in India and have purchased Ipad 3 from US, I have lost my invoice and also the small pin which helps in inserting sim card, Can anyone help me how can I get a copy of duplicate invoice from India and a PIN for my Ipad 3

    Dear Friends,
    I have purchased Ipad 3 from the US but unfortunately while returning back to India I have lost in transit the copy of Invoice and a tiny PIN which helps in inserting 3G card.
    Can anyone help me how can I get the duplicate copy of my invoice and an extra PIN from India and whether any Apple Store in India can issue me the duplicate copy of Invoice for the product purchased from US and also are the require to issue me an extra PIN on request.
    Thanking you all in anticipation....
    Regards,
    Bankim Mehta

    You can use a paper clip instead of the PIn that came with the iPad.
    http://support.verizonwireless.com/clc/devices/knowledge_base.html?id=54813
     Cheers, Tom

  • I have a line drawing (black on white paper) i have scanned and need to make the white paper transparent, maintaining the line drawing, can i and then HOW can i do this in PS?

    i have a line drawing (black on white paper) i have scanned and need to make the white paper transparent, maintaining the line drawing, can i and then HOW can i do this in PS? this is for my business logo. ive used it for years but with a solid background. id like to have it just be the drawing over my photos with a transparent background.

    First let me apologize for posting a reply that was only suitable for advanced users.  Photoshop is broad and powerful therefore has a huge learning curve.  In fact I would state no one knows and uses all of Photoshop.  When we first get Photoshop it intimidate us and we're very uncomfortable using it.  Many thing are not intuitive there in much learning involved.  After some time we begin to know something and we are able to do some thing.  Learning become rapid and we start playing in Photoshop.  It is very important to play with Photoshop.  Playing with Photoshop and asking for help with in forums like this IMO is the best way to learn. 
    Photoshop Power lies in layers, selection and automation.  However it takes knowledge to use photoshop well so most powerful tool you have ins Photoshop is the gray matter between your ears.  Most at one time or another want to watermark or put a logo on their image.  So its best to automate this process. All run into a problem in the process. "Size"  We find our assets vary in size and aspect ratios. Landscape, Portraits, Panoramas and others. This complicates automation.  Vector graphics works best when size vary greatly.  If you can not work out how to create a vector solution like a custom shape.  Create your Logo and watermark large thing scale down better the up. Text scale well for text uses vectors graphics however if you rasterize text it will not scale well.
    I do not type or do English well so let me do some screen captures.  I can not stress enough how important Black, White, Grays and Blending is when it come to image processing.  Become friends with Multiply, Screen, Overlay and Luminosity blending.....
    However when there is a white or black background though you can blend them you can not add a style like a drop shadow, emboss or make it invisible setting fill to 0 so only the style is visible.  When there is contrast between the logo and background it is easy to separate the two. To select the background and delet it to have the logo with a transparent background.  Many tools can be used to create the selection hee I use my action kill white.
    Vector Shape would work better for scaling However it would be best to create the logo from scratch in a vector program like illustrator but I never had the resources to justify the Creative suite. I only had Photoshop.  Recently Adobe gave me and other a year subscription to the creative suite for our participation here.  I still have not installed anything but Photoshop,  A while back I found a program that can create vector patf for black and white art work.  It will not be as good as using something like illustrator. However vector paths can be edited in Photoshop and cleaned up some. Here is the PSD it 13MB because od the gradient http://www.mouseprints.net/old/dpr/AmPm24-7.psd

  • I have just installed a 2TB time capsule on my iMac i7, it see my second 1TB hard drive but the 256 SSD doesn't come up in the list of hard drives I can back up. How can I enable the time machine to see my first SSD 256gb hard drive?

    I have just installed a 2TB time capsule on my iMac i7, it see my second 1TB hard drive but the 256 SSD doesn't come up in the list of hard drives I can back up. How can I enable the time machine to see my first SSD 256gb hard drive?

    iLife is preinstalled on all the Macs. If you purchased iLife in the App Store or your computer came without DVDs, open App Store > Purchases and download the applications. If your Mac came with discs, insert the Applications DVD and install iLife applications

  • I downloaded an app off the store which said it was free and part of the 5 year promotion. I've been charged for the app by the store. I don't want the app and there's no one to speak to about it. Who can I call and how can I get the app off my phone?

    I downloaded an app off the store which said it was free and part of the 5 year promotion.
    I've been charged for the app by the store. I don't want the app and there's no one to speak to about it.
    Who can I call?
    How can I get the app off my phone?
    How do I get my money back from something I wouldn't have ordered?

    You cannot call anyone.  You contact them as everyone else does:  http://www.apple.com/support/itunes/contact/
    You delete the app as you do any other app.  Hold an icon until they wiggle.  Tap the "x".  This is covered in the manual.

  • Just  bought a new phone and want to delete everything off my old phone so I can sell it. How do I do this?

    just  bought a new phone and want to delete everything off my old phone so I can sell it. How do I do this?

    Read here...
    What to do before selling or giving away your iPhone, iPad, or iPod touch

  • I am creating a web form from a template and I need to change a field. It is just a text field at the moment but I need to change it to a field that the customer can fill in. How do I do this?

    I am creating a web form from a template and I need to change a field. It is just a text field at the moment but I need to change it to a field that the customer can fill in. How do I do this?

    See this thread:
    http://answers.acrobatusers.com/Is-add-instructional-text-text-field-disappear-clicked-q19 5078.aspx

  • After installing Windows 8.1 on my Nokia Lumia Icon , I no longer receive email, although I can send it.  How do I fix this problem?

    After updating to Windows 8.1, I no longer receive email, although I can send email.  How do I fix this problem?

        Lets ensure your service device is running in top form! What email account are you using? ( ie, Google, Yahoo, etc) Have you removed and re-added the e-mail address since this occurring?
    YosefT_VZW
    Follow us on Twitter @VZWSupport

  • I can't update my apps, but I can download news. How can I update normally my apps?

    I can't update my apps, but I can download news. How can I update normally my apps? Thanks!

    Hi Dnasc,
    I have two more suggestions:
    1. Reset your iPad - hold down the Home and Power buttons at the same and continue to hold them down until you see the Sliver Apple (ignore the red slider). You will not lose any data. I know this sounds like it might not do anything, but this afternoon I deleted and re-added my iCloud account on my iPad (experimenting so I could answer another question), and it really messed up my Photostream. Did the reset, and everything in the photostream reloaded successfully without any further problems. A reset can do wonders to help "clear your iPad's mind"....
    2. Go into iTunes and update the Apps on your computer, then hook up your iPad and sync....
    I hope one of these works for you!
    Cheers,
    GB

  • My friend is unable to open CR2 files in bridge but I can in CS6. How can I help him

    My friend is unable to open CR2 files in bridge but I can in CS6. How can I help him

    What version of Bridge and Camera Raw is your friend using?  And what camera is this from?
    Each camera must be supported specifically and older versions of Adobe products don’t get updated for newer cameras.
    Your CS6 is obviously new enough and has been updated to a new enough version of the Camera Raw plug-in but perhaps theirs is older or hasn’t been updated.
    Here is a list of cameras that Adobe supports along with the version of the Camera Raw plug-in that is needed to read them:
    http://helpx.adobe.com/creative-suite/kb/camera-raw-plug-supported-cameras.html
    For versions older than CS6, the highest CR version is +1 of the CS version—CS5 can use CR6.x but not CR 7 or 8.
    The exception is CS6 which is still be sold by Adobe so can be updated to CR8 even though it initially shipped with CR7.

  • Hi sir am using FCP 7 I Want export 2.30 min Movie. But my My FCP is allow only 2 hr video to export can u help me how can i do.

    hi sir am using FCP 7 on Mac Pro. I Want export more than 2 hrs file like 2.30 min Movie. But my My FCP is allow only 2 hr video to export can u help me how can i do.

    Try FCP Studio forum, this is FCPX forum.

  • I cannot get itunes to download.  I have a PC with windows 7.  I had itunes but got a message that told me to uninstall and reinstall intunes.  I uninstalled but now can't reinstall. How can I get itunes to install again?

    I cannot get itunes to download.  I have a PC with windows 7.  I had itunes but got a message that told me to uninstall and reinstall intunes.  I uninstalled but now can't reinstall. How can I get itunes to install again?  I click on the download itunes button and it immediatly takes me to the page that says thank you for installing itunes.  But it doesn't install.  I'm getting so frustrated!!  Can anyone tell me how to install itunes????  Thanks.

    This iPod Classic Community forum is a bad place to post your problem with iTunes,  phone support wouild be good. but if you like to talk to support people, post your iTunes problem to the iTunes community forum.
    Or you can read this Apple Support Article on Re-installing iTunes
    Have a nice day!

Maybe you are looking for