While loop takes control of everything​, i.e. stop a while loop

Hi everybody,
I have a problem with a while loop, which I don't manage to stop as it
takes control of everything.
So, the problem is the following.
I wrote a vi to control an Optical Spectrum Analyzer and I need it to
scan a trace every Ta seconds. The scan must start when the user
presses the button "Start datalogging!" and must stop when the user
presses the button "Stop datalogging!" (this button is configured as
"swith after pression").
The problem is, anyway, that after starting the datalogging operation,
the user interface becomes kinda inaccessible, the mouse pointer
assumes the "hand format" and you can't push any button (actually you
can't move the scroll bars either, nothing), but the one to abort the
execution, making thus impossible to stop the acquisition or any other
operation.
It seems like the operation of collecting data is so "CPU consuming"
that LABVIEW can't "listen" to any input.
The LABVIEW version I am using is the 8.5.1.
I hope somebody can help me solving this problem.
Thanks a lot,
Gianluca

Hi,
You may want to try the following:
1) create a while loop, leave the conditional terminal open for now
2) inside the while loop, create an event structure (on the same palette as 'while'- and 'for' loops)
3) Add an event by right-cllicking the top textfield of the event structure, choose your startbutton-control in the left menu, and in the right menu scroll down to 'value change'. Before exiting this menu make sure to uncheck the checkbox for 'lock front panel'
4 inside the eventstructure for your start-button, put your start-button control - it needs to be read by the program to work properly (unless you chose another form of mechanical action). Wire it through the wall of the event-structure and to the conditional terminal, insert a boolean 'not' to reverse the polarity.
5) Add a constant to the 'timeout' value on the left upper corner (outside the event structure),give it the value 100 [ms]
6) select the timeout page in the structure (it was there by default as the first page)
7) insert your scanning program in here, it will iterate (start) every 100ms (due to your constant in step 5)
8) add another event, select your stop button control in the left menu, select 'value change' in the right menu
9) Place your stop-button control inside the new page in the event-structure, wire a line through the frame down to the conditional terminal
10) you are done
Brgds
T

Similar Messages

  • Closed loop velocity control based on load cell force

    Hello,
    My application is for a drill, that drills into rocks of various densities for the purpose of collecting rock core samples.
    My setup has 2 motors which get controlled, one spins the drill bit at a constant velocity, the other moves the drill mechanism along a Z axis.
    For efficient cutting, it is desired to apply a constant force between the drill bit and the rock.  I have a load cell which measures the force being exerted by the drill bit on the rock surface, and this force can be adjusted by changing the velocity of the Z axis.  So I would like to employ closed loop control to adjust the Z axis velocity to maintain a constant force on the rock.
    Platform: cRIO 9073, with NI 9505 & 9215 Modules, Labview 2010 Full with RT and FPGA modules.
    The load cell is by Transducer Techniques, and I use their TMO-1 module to condition the signal, the output of which is attached to an input of the 9215 module, where 0-100 lbs equates to 0-8VDC.
    The motors and encoders for the Drill and Z axis are connected directly to the 9505 modules.
    Right now I am using a modified version the example found in ...\examples\CompactRIO\Module Specific\NI 9505\Velocity Control (closed loop)\Velocity Control (closed loop) - NI 9505.lvproj to accomplish velocity control of the motors.
    My questions are:
    1) Do I have the appropriate NI hardware/software for this task?
    2) With my current hardware setup, what would be an appropriate way to control my Z axis velocity rate based on Analog feedback from the load cell?
    3) Development time is a critical factor, so are there any toolkits etc that are easy to get started with that would drastically decrease my development time, or do I already have everything I need?
    Thank you for your time
    -MK Hokie

    1. Your hardware and software look appropriate assuming the motors are compatible with the 9505s.  You didn't mention the NI SoftMotion module in your software list which is something you will need.
    2.  There are a few ways of doing this.  One method would be to have a force PID loop that would attempt to maintain a force setpoint by directly outputting values to your torque loop.  In this case, the drill would essentially move as fast as it could while maintaining the force setpoint.  Another option is to have the force loop output a velocity setpoint.  You would then have a velocity PID loop that outputs torque values to the torque loop.  By adding this additional velocity loop you could have control over your maximum and minimum velocities.  There are likely other alternatives as well, but these are the first two that come to mind.
    3.  Unfortunately there are no shipping examples that close the loop on force feedback.  My advice would be to start with the NI 9505 shipping example and adapt it to your needs.  There are quite a few things you will want to change though.  Do you know if you will need to use the trajectory generator to move the drill into position before starting the force control?
    Assuming you don't need any trajectory generation, you can scrap the entire RT portion of the NI 9505 example and just create the necessary FPGA code.  On the FPGA, you won't need the Spline or Synchronization code either because this information would no longer be coming from RT.   You could take these out and replace the position loop with a force loop and possibly a velocity loop and your FPGA program would basically be finished.  In fact the only real motion IP that you will need is for the encoders (assuming you want velocity control) and PID.  Then you would need to create an RT VI that allows you to send down enable, disable, PID gains, and setpoints. 
    If you do need trajectory generation, you would want to keep most of the example code the way that it is, but then program in a 'Force Mode' that utilizes the force and velocity controly as described above.  You could think of it as having two different routines programmed side by side. 
    Regards,
    Burt S

  • Stopping a while loop using the time difference of two tick counts

    Hi Guys,
    I'm currently writing a code which test how long does it take for a formula node to perform its operation. The program uses a while loop to perform the calculation, and the program stops after calculating when tick count has reached 10 seconds. The program then displays the number of iterations it does in 10 seconds. 
    So initially I created 2 frames of sequence structure. In my first frame I have my initial tick count, and in my second frame I have my final tick count and the while loop. I used the subtract function and divide the output by 1000 to get the time difference. Then using the comparison function, I set if output > 10 then the program should stop, to do this I linked the output of the comparison function to the stop button inside the while loop. 
    However, when I tried to run the code, the program just didn't run. Hence I created a similar program which puts the last tick count in new frame sequence. When I ran this code, the program never stopped. 
    Do you guys have any idea what went wrong with my codes.
    Thank you!
    Erry
    Solved!
    Go to Solution.
    Attachments:
    1. Tick Count.vi ‏27 KB
    tickcoun2.vi ‏27 KB

    Dataflow!
    In both VI's the stop terminal of the while loop is controlled by a boolean whose source is ouside of the while loop.  So that loop will either run once, or run forever, depending on the value of the boolean that is calculated before the loop starts and shows up at the tunnel going into the loop.
    I would recommend looking at the online LabVIEW tutorials
    LabVIEW Introduction Course - Three Hours
    LabVIEW Introduction Course - Six Hours

  • Take Control of Workflow with Workflow Analyzer!  See Note 1369938.1

    Take Control of Workflow with Workflow Analyzer!  Immediate Analysis and Output of your EBS Workflow Environment.          
    The EBS Workflow Analyzer is a script that reviews the current Workflow Footprint, analyzes the configurations, environment, providing feedback, and recommendations on Best Practices and areas of concern.          
    Video - Watch a 9-minute overview video (9:00)          
    Go to [Doc 1369938.1|https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&id=1369938.1] for more details and Script Download.          
    Proactive Benefits:          
    Immediate Analysis and Output of Workflow Environment          
                   Identifies Aged Records          
                   Identifies Workflow Errors & Volumes          
                   Identifies looping Workflow items and stuck activities          
                   Identifies Workflow System Setup and configurations          
                   Identifies and Recommends Workflow Best Practices          
    Easy To Add Tool for regular Workflow Maintenance          
    Execute Analysis anytime to compare trending from past outputs          
    [Please send any items to Feedback.|https://communities.oracle.com/portal/server.pt?open=514&objID=224&mode=2&threadid=297966]
    Edited by: user715498 on Feb 14, 2012 11:09 AM
    Edited by: user715498 on Feb 14, 2012 11:12 AM

    14. Once my photos look the way I want, I then export them to JPEG. I have set up a Photoshop droplet for Lightroom that will then do all my sharpening after export.
    That's it! I know it sounds like a lot of steps, but once you've done it a couple of times it goes by really quick. I'm really loving most things about Lightroom in terms of its cataloging and export options. But the image quality of the Lightroom raw conversions just isn't there yet. I've found by integrating both Capture NX and Lightroom I can get top quality results while still gaining advantage of Lightroom's many nice features. It took me a few days of exploration and experimentation to nail down the optimal workflow for my needs. Hopefully this will help some others out and maybe give them some ideas of their own toward a better workflow.
    Please feel free to share your thoughts or own experience on all of this.
    Thanks to Tony Long for his suggestion in this thread, which caused me to go on a search for the optimal Lightroom/Capture workflow: http://www.adobeforums.com/cgi-bin/webx?7@@.3bc719df/3
    If you are interested in taking a look at the final output of the workflow listed above, please look here: http://photos.unsavory.com/p634883589
    Cheers everyone!
    -©aine

  • How can i take control of an ipad using my apple ID..??

    I have bought a used ipad mini 2 [wifi + retina], & while trying to sync the apps from my PC using my apple ID, the ipad keeps asking for the authorization of the PC even though the authorization was successful using my ID. then i authorized the PC with the previous users apple ID, and the syncing was successful..! however i want to use my apple ID to run the ipad, & take control of it. can anyone advise how can i get rid of the previous ID, & use my own one..?? Thanks!

    The Seller should have performed these Steps Before you took possion of the Device.
    What to do before selling or giving away your iPhone, iPad, or iPod touch
    NOTE:  You may need to contact the Seller
    salm4n wrote:
    I have bought a used ipad mini 2
    i want to use my apple ID to run the ipad, & take control of it
    Restore the Device as New and Set it up using your Apple ID.
    See  Erase your device  Here  >  http://support.apple.com/kb/HT4137

  • Stop dependant while loops with 1 button

    Hi,
    I am developing a utility that allows a user to configure up to 2 devices (both use same driver with a different board number), click initialize, which then brings up a file dialog and displays arrays for the data to be collected and some error messages for each measurement.  The user then clicks the Start/Stop button to begin collecting and logging data.  Currently i have a Wait(ms) block to allow the user to set often the measurement should be made.  Currently the Start/Stop button allows collection to be started, paused, and started again.  My problem is trying to have a master stop button that should stop all loops immediately when it is pressed.
    I tried using a global variable for the stop button, but the measurement and logging while loop doesnt stop until after the wait(ms) block times out.  Can anyone give suggestions.  If i need to restructure the VI into different loops, I can do that.  I just want to understand the right way to program something like this.
    The VIs are attached.  I removed the device specific measurement VI so that anyone can open the vis and run them to see how it works.
    Attachments:
    2Devices_withoutMeasurementVI.vi ‏112 KB
    BuildOutput.vi ‏27 KB
    stopGlobal.vi ‏5 KB

    Ok.  I had a chance to take a look at your code and I think you don't quite understand the concept of "dataflow".  Let me see if I can help.
    First of all...when I refer to your upper structure, I am referring to the first while loop, sequence structure, and subsequent while loops.  When I refer to your lower structure, I am referring to the while loop containing the event structure.  Just so we get our terminology straight.
    I believe that you are under the illusion that your upper structure contains three parallel while loops.  It does not.  It contains three SERIAL while loops.  There is dataflow dependency between the while loops.  The sequence structure requires data that is not available until the first while loop has finished executing, so the sequence structure cannot start executing until the first while loop has terminated.
    The second while loop requires inputs from the first frame of the sequence structure (which, by the way, you don't need and should get rid of...the sequence structure, I mean), so it cannot start executing until the first frame of the sequence structure has terminated.  The third while loop requires inputs from the second while loop...so, again, the third while loop cannot run until the second while loop has finished executing.
    Now, for your stop button.  You have that global stopping all three loops.  So here's what is happening in your program:
    Your program starts.  The first while loop executes in parallel with the loop which contains the event structure.
    At some point you press the "stop" button.  Both the first while loop and the loop containing the event structure finish executing.
    The first frame of your sequence structure executes.
    The second frame of your sequence structure executes.  The second while loop reads the "stop" value from the global, so it executes once and then finishes.
    The third while loop starts executing.  Again, the loop reads the "stop" value from the global, so it executes once and then finishes.
    Then your program terminates.
    You need to restructure your program, because right now it doesn't make any sense at all.  Your block diagram would benefit from some serious tidying up as well, your wiring is a mess.  I suggest you look into a state machine architecture for this program.

  • What would be the simplest way to view and take control over the internet?

    Hi All:
    Can some one tell me what would be the best and simplest way to connect from my laptop to another laptop through the internet?
    I have DYNdns running on the second laptop and have a host name assigned to that system for it to update the IP since the system uses different internet connections. The services that I would like to be able to have are the viewing and controlling of the system. I've read some where in this NG that if I have a copy of ARD admin. installed on that system also, it would be one way to do it... can some one verify this and please let me know if there are any specific settings I need to have on either one of the systems.
    I can connect to the second laptop while in my home network with no problem and perform all tasks. when trying to connect through the internet.. the system shows offline .
    Both systems are identical in hardware an software, Intel 2.16, 2G's RAM, OS X ver 10.5.2 all up to date and ARD 3.2
    Yes, I'm new to ARD and yes I'm searching the NG and the net. but I figure it doesn't hurt to ask since time is limited.
    All help greatly appreciated ..
    TIA
    Oscar A.

    To be able to connect to a workstation from outside it's network, the ports that ARD uses must be open on both ends of the connection. ARD uses ports 3283 and 5900 so those must be open.
    If your workstations get their addresses from an NAT device rather than being "real", the ports also need to be forwarded in the router to the workstation's internal IP address. ARD uses port 3283 for the reporting and updating function, so if your Macs are getting their IP addresses through NAT, since you can only forward a port to a single workstation, you can only get reports, push package/files to etc. for a single workstation.
    ARD uses the VNC protocol for observation and control, though, and there are a range of IP addresses for that protocol, starting with 5900. ARD uses 5900 by default, so that port would be forwarded to the first workstation. You would, I believe, need to install VNC servers on the systems (since the ARD client cannot listen on any port other than 5900 while VNC servers can be set for other ports such as 5901, 5902, etc. You would then forward 5901 to the second workstation (and on to 5902, 5903, etc.). You can then use the following information:
    Remote Desktop 2: How to specify a port number for a VNC client
    to connect.
    The only other options are: 1) to run the ARD administrator on a workstation on the network, and then take control of that system from outside, either via VNC or another copy of ARD, or 2) set up a virtual private network (VPN) so that when you connect from outside, your admin system is officially part of the local network.
    Hope this helps.

  • Code golf: stop two while loops with guaranteed iteration ratio

    Proposal
    In the vein of the Perl tradition, I'd like to see if there's any interest in solving short programming puzzles in LabVIEW. Anyone can post a problem and define the rules for solving it.
    Here's a beginning/intermediate question to whet your "palette".
    Description
    With one user-action, how would you stop two while loops such that the ratio of their iterations is the always the same? One concrete way to visualize this situation is in taking measurements: two instruments use the same timing source to take measurements, but second divides the clock down so that it is an integer factor slower than the first. For example, if the slower instrument is four times slower, then at the end of the VI, if the slower instrument takes 100 measurements, the faster instrument has taken 400.
    Rules
    You may only use vi.lib
    You cannot include any other subVIs
    Your solution must pass for loop1 interval as low as 25 ms
    Template (attached in LabVIEW 2009)
    If folks are interested in this, then let's figure out how to make future problems better. Please post your suggestions and critiques, but only if you also post a submission ;-)
    Solved!
    Go to Solution.
    Attachments:
    Multirate Loop Code Golf.vi ‏11 KB

    Norbert_B wrote:
    a) You work with an integer factor of speed. While this matches many application areas, there are still cases where the factor has to be floating point (e.g. 2.5). Additionally, the factor might "invert", so the master loop runs slower than the slave (factor 0.5 for instance).
    It sounds like you're about to post another code golf question. If you think the problem scope is too small, you're welcome to fashion one to your taste. Thanks for volunteering :-D
    Norbert_B wrote:
    b) This example does not take into account that the hardware has to be synchronized with more accuracy than the software supplies (PXI?). If hardware synchronization is required, there are two possible ways:
    - The factor can be included in the synchronization (using PLL for instance)
    - The factor has to be software implemented by data reduction for the task running at the lower pace.
    Hrm, maybe puzzles aren't really your thing after all. You are correct: I did not define every constraint that can lead to a provable best closed-form solution, but that does not prevent people from stating their assumptions and forming creative, well-reasoned, and still correct designs. I overlooked this reading of the description and neglected to add a statement that said solvers were free to add their own conditions. I will do so in the fugure :-)
    If we choose the first of your suggestions, the VI must still retrieve the data at different rates. You can dedicate a loop for each instrument to decouple any jitter and latency introduced by their connectivity or internal operation; this adds some margin of safety when there is thread and driver contention. You can also implement a single counting loop like altenbach and forego the multiloop complexity.
    Norbert_B wrote:
    c) You don't state anything about "what happens with the data". Is this time consuming? Does it introduce additional delay in loop iterations? Is it OK to have data loss?
    I don't know -- you decide, you disclose, and you solve :-)
    In my specific situation, the measurements are time consuming and do add delay (each data "sample" is 5-20 megabytes), none can be lost, and the data must be available for others to analyze later. In addition, the amount of data is saturating the hard disk throughput. If a particular write takes too long, the instrument driver may overwrite a yet unfetched sample, which is unacceptable. I did not add these details to the problem discripton becuase they don't impact the puzzle.
    I don't want to burden people with my situation and ask them to solve my problem: I want to encourage them to bring their intuition and experience to a discussion. This is the design process at its heart: understanding why and how constraints affect your decisions. If a person states the additional conditions they've assumed, readers can learn why, and more importantly, when a Notifier might be more desirable than an Occurance or a Queue more robust than a Data Value Reference.
    The best NI-published advice for stopping multiple while loops (https://www.google.com/search?q=labview+stop+multiple+while+loops) is laughable (and is the "solution" in my template).
    Would you care to re-approach and contribute to this puzzle? I suspect you have a lot to offer :-)

  • Stopping a while loop inside a while loop

    Hello,
    I have a while loop which is inside a while loop which houses my enetire application, When stopping the inner while loop portions of my outer loop stop working, How do I setup the inner while stop that it will not interfeer with the outer while loop?
    Thanks,
    Gil,

    It sounds like he is using a simple archetecture.  But switching to a different archetecture may not be necessary.  Simply because it doesn't work, doesn't mean scrap the whole thing and start over.  He's got a bug and needs to fix it.  Is it the best archetecture to use, absolutely not, but simple or general archetectures can be effective based on the application.
    Post your VI so we can take a look and give you some pointers and suggestions for improvement.
    Reese, (former CLAD, future CLD)
    Some people call me the Space Cowboy!
    Some call me the gangster of love.
    Some people call me MoReese!
    ...I'm right here baby, right here, right here, right here at home

  • Video Furnace: Failed while creating player controls...

    I need some help figuring out how to get Video Furnace to work on my computer. It had run very easily before; I was on campus, and I clicked on the icon, it came up, and played smoothly, but I can't get it to work any longer. It keeps saying: The Audio device is unavailable or busy. Playback will continue without audio. After that message, Another error message pops up saying: Error, Failed while creating player controls. Then the Instream quits.
    I used my roommate's computer to access the video I was supposed to watch and ir worked fine on hers; she has the same exact computer as me, and I was in the same room, only a couple of feet away. I was thinking maybe I messed up my audio settings or soemthing? I don't know what to do. Anyone have any suggestions?
    Thanks.

    Kumar
    Instead of creating a player and a processor from one datasource you can use javax.media.control.FrameGrabbingControl to grab frames from the video stream. To do this you need the following code
    * grabs a frame's buffer from the web cam / device
    * @returns A frames buffer
    public Buffer grabFrameBuffer ( )
    if ( player != null )
    FrameGrabbingControl fgc = (FrameGrabbingControl)player.getControl ( "javax.media.control.FrameGrabbingControl" );
    if ( fgc != null )
    return ( fgc.grabFrame() );
    else
    System.err.println ("Error : FrameGrabbingControl is null");
    return ( null );
    else
    System.err.println ("Error : Player is null");
    return ( null );
    * grabs a frame's buffer, as an image, from the web cam / device
    * @returns A frames buffer as an image
    public Image grabFrameImage ( )
    Buffer buffer = grabFrameBuffer();
    if ( buffer != null )
    // Convert it to an image
    BufferToImage btoi = new BufferToImage ( (VideoFormat)buffer.getFormat() );
    if ( btoi != null )
    Image image = btoi.createImage ( buffer );
    if ( image != null )
    return ( image );
    else
    System.err.println ("Error : BufferToImage cannot convert buffer");
    return ( null );
    else
    System.err.println ("Error : cannot create BufferToImage instance");
    return ( null );
    else
    System.out.println ("Error : Buffer grabbed is null");
    return ( null );
    The first method takes frame grabbing control of your player which you have already created from the datasource of the camera and it grabs a frame, returns it as a buffer, then calls the second methos which converts the buffer to an image.
    It is very straight forward and I was kicking myself when I figured you could do it this way - I had been weeks playing around with the player and processor from one datasource.
    hope this helps!

  • Take control of VPN Client

    Dear All,
    someone can tell me if is possible take control of the remote client connected by VPN, through application like Remote Desktop or NetSupport?
    We use a VPN Concentrator and one of our customer need to take control of the client-desktop that connected by VPN.
    Thanks in advance.
    Maurizio Pederneschi

    Upsolutely you can , we do it all the time with our Concentrator 3005, if we need to connect to an already connected pptp client to assist we rdp to their machine using that same tunnel. Now you need to keep in mind that in order to RDP to the clients machine while that tunnel is up between the concentrator and the user's machine you will need to use the same users login credentials whatever they use at their end in order to keep the tunnel up without interruption.
    I have not tried netsupport and do not know how Netsupport works but I would assume it should work as the netsuport traffic is sent through the tunnel.
    Rgds
    Jorge

  • Stopping a while loop with a button in cvi

    Hi people,
    I am a newbie with CVI but I have used LabView Heaps. The issue I have is I want to be able to use a toggle button or a command button to stop a while loop. I used GetCtrlVal on the toggle before the while loop. I then enter the while loop and then GetCtrlVal at the end to see if the button has been pressed. The issue I have is that once I enter the loop I am unable to press any buttons on the Panel. I would normally have put a delay in the loop but the issue is I am wanting to control a robot in "realtime", thus any delays in the program results in the robot moving further than what I wanted it to. Any ideas? If you have any suggestions that would be much appreciated thank you.

    This should be in the CVI group but...
    At the tail end of your while loop add a call to function ProcessDrawEvents():
    When your program executes in a callback function or in code that does not call RunUserInterface or GetUserEvent, LabWindows/CVI does not update the user interface. Functions that are overly time-consuming can "lock out" user interface updates. To allow LabWindows/CVI to process these updates, call ProcessDrawEvents.

  • Control does not stay in case structure while using motion VIs

    Hi,
    I have a motion control card PCI 7344 connected to my PC. I am able to control the motor at the required speed till the required position using an encoder. Now I have put my motion control VIs in a case structure in such a way that, if Case1 is selected then the motor should to position P at speed S, if case 2 is selected then the motor should move to position Q at speed S and if case3 is selected then the motor should to position R at speed S. I am selecting cases 1,2,3 etc. by scanning a set of numbers seperated by spaces which look like this,
    1 2 5 7 3
    This number scanning is done using a while loop. Now, when the first number is scanned in the above set of numbers. The number 1 is obtained and the control is switched to case1. But before the motor reaches position P, the control switches to case2 and before completing the execution, the program scans case5 and so on. That means that the control does not stay till the move in the case 1 is completed. I'm sure there must be a way to retain the control to a case and stop the next number to be scanned before the functions in the particular are completely executed. I thought of one method, i.e. by using the move complete VI provided in LabVIEW, but I could not implement it. Please help me out with this.
    Regards,
    Giridhar Rajan
    Automation Engineer,
    Cruiser Controls,
    Mumbai, India

    Hi,
    Our motion controllers allow you to preemptively start a move in the middle of a current move.  For example if you are moving from point A to B and based on some logic, you determine you need to immediately start moving to point C.  A preemptive move allows you to just load the new target position and call start.  You do NOT have to first stop the current move and then start the new move.
    In your case, you want the first move to complete before the second move starts.  There are two ways to handle this.  First, wait for the move to complete via a Wait For Move Complete function/VI call, or use the Check For Move Complete function/VI in a loop.  Second, use Blend Start instead of the regular start.  A Blend Start (if blend factor is set to 0) waits for the first move to complete before the second move starts. 
    Check out the help topics for Start Motion and Blend Motion to learn more.
    Thanks,
    Rodger S.

  • Failing to take control of navigation

    Hi,
    Im trying to take control of the navigation. Im using MyFaces.
    let me explain:
    I wish to have my own piece of code to parse the request URI and control the navigation to the next JSF page.
    This functionality is desired for accomplishing a permalinks scheme of some sort.
    For example
    The link root/yuval/yuvals_stuff should cause the following to happen:
    - I parse the request with a servlet filter and know that we need to load some data for yuval.
    - I use a ViewHandler to load the data (it delegates the call to some service that gets the data from the database)
    - I now forward the user to a known jsf page that is bounded with the viehandler and presents yuval's stuff .
    Actually, the first time i try to use the code, the navigation goes well. But right after refresh or calling the same url again I get an exception. The code and the exception are provided here:
    Here is what i do inside a servlet filter (I also tried to put this code inside the faces servlet, just for testing):
    <code>
    FacesContext fc = FacesUtils.getFacesContext(req, res);
    String action = "#{viewPollViewHandler.go2}";
    javax.faces.application.Application application = fc.getApplication();
    MethodBinding mb = application.createMethodBinding("#{viewPollViewHandler.go2}",null);
    String outcome = (String)mb.invoke(fc, null);
    String fromAction = mb.getExpressionString();
    NavigationHandler navigationHandler = application.getNavigationHandler();
    navigationHandler.handleNavigation(fc, fromAction, outcome);
    String viewId = fc.getViewRoot().getViewId();
    UIViewRoot view = fc.getApplication().getViewHandler().createView(fc, viewId);
    view.setViewId(viewId);
    fc.setViewRoot(view);
    fc.getExternalContext().dispatch(viewId);
    fc.responseComplete();
    </code>
    Explanation:
    First we try to get the FacesContext, using the current request and response objects. Now we know what action we want to invoke on what ViewHandler, so we go ahead and make a method binding for this method through the JSF Application context. Now we invoke the method and get the outcome String from it. Till now everything seems to work ok � we get the ViewHandler's method invoked correctly and we get the proper outcome String from it.
    This means the ViewHandler is now populated with our needed data, so all we have left to do is go to the presentation page that uses this ViewHandler.
    We use JSF's NavigationHandler to navigate as usual, giving it a "fromAction" and an outcome. Now we want the name of the page for this navigation, so we get the view id from the FacesContext. The view id is correct and points to the next page as states in the faces-navigation.xml, so we set it as the new view root and try to "dispatch()" (which is the same as "forward()") to it.
    The result seems sufficient, as we get to the next page and all the data is presented correctly (sometimes, in IE only we experienced some javascript errors that were unknown). The big problem occurs when trying to hit "REFRESH" or clicking back and then trying the original href link again. We suddenly get a NullPointerException that occurred in the "getValue()" method of JSF's getValueBinding()".
    Can anyone contribute?
    Thank in advance!
    Yuval.

    Hey all,
    The following link shows how to solve the problem:
    http://wiki.apache.org/myfaces/InvokingJsfPagesWithStandardUrls#head-6c1aaf488d48f938896da962aaa4361ec3ffaf70

  • Labview Loop Takes 100% cpu

    Hello,
    I'm wondering the best way to send a serial command when a button is pressed.  Right now I have a while loop that checks if the button is pressed each time.  If is is, it sends the serial command and adds the response to a text box via a shift register.  If not, the original text box info is passed to the shift register.  However, this loop takes 100% cpu (ok, only one core at 100% so technically %50), and I think its because the text box is getting overwriten every cycle.  However, I'm not sure how else to do it.  Attached is a print screen, let me know if you would like the file.
    Thanks,
    Eric
    Solved!
    Go to Solution.
    Attachments:
    loop1.png ‏42 KB

    An event structure is the best way.  The next best way is to simply put in a wait in the loop.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

Maybe you are looking for

  • Can you open more than one ER file at a time?

    I was wondering if you can open more than one file at a time in ER? I attempted it, however, it does not appear that I can do that like other Adobe products.  (If not, it would be  nice to have the ability of working, or opening more than one file at

  • Alternative to DVD player : MAC book air

    i have purchased a Office Suite :mac 2012 CD and I am using MAC book air w/o externl dvd player. How can I install the software w/o connecting external DVD.

  • Flex Project ; Compile Locally

    When I set up a Flex project in Flex Buiilder 2 , and select Flex Data Services, Compile Application locally in Flex Builder , then select root folder, root URL and context root, the application fails to compile locally . I get an error in the proble

  • Can someone help me open raw files from bridge in CS3?

    MIne used to work and it quit.  I've tried uninstalling and reinstalling the program and it won't work.  I'm using Windows 7.  Help!  Please!

  • Image Quality Processing Multiple Images

    When I first installed PSE, I could process multiple images and have the new image auto saved at the same image quality of the original. Now it changes to a value of "3" ...and I can't figure out how to predefine it to a higher quality