ActionListener and Navigation PROBLEM

Hi , I haveing problme wiht ActionListener and Navigation ,
I am using ActionListener and after getting values I am forwarding the
page, but its getting to same page, below is my bean code.
     * this method edit the survey
     * @return
     public String doEditSurvey(ActionEvent event){
          //first get the question ID,questionType ,Question and Releated Answers
          String surveyQuestionID = (String) event.getComponent().getAttributes().get("surveyQuestionID");
          System.err.println("the question id is :"+surveyQuestionID);
          String surveyQuestionDesc = (String) event.getComponent().getAttributes().get("surveyQuestionDesc");
          String questionType = (String) event.getComponent().getAttributes().get("questionType");
          ArrayList surveyQuestionList = (ArrayList) event.getComponent().getAttributes().get("surveyQuestionList");
               Iterator it = surveyQuestionList.iterator();
               while(it.hasNext()){
                    SelectItem selectItem = (SelectItem)it.next();
                    setAnswer(selectItem.getLabel());
                    setAnswer("\n");
               setQuestion(surveyQuestionDesc);               
               setSelectedType(questionType);
          System.err.println("the question id is :"+surveyQuestionID);
          //System.err.println("the surveyQuestionList id is :"+surveyQuestionList);
          System.err.println("the surveyQuestionDesc id is :"+surveyQuestionDesc);
          System.err.println("the questionType id is :"+questionType);
          FacesContext facesCtx = FacesContext.getCurrentInstance();
          facesCtx.responseComplete();
          return "questionTemplate";
so when I return this string , Its not getting their, any idea .
Thanks
Srikanth

Check your faces-config.xml file for the navigation rule questionTemplate.
SirG

Similar Messages

  • Still having navigation problems and need help with how to debug

    Hi,
    I've been porting over a servlet project to JSF and I'm still having navigation problems. I thought the problem might have been because the original project used HTML frames and so the "from-view-id" JSP defined the frame/framesets and the specific JSP that does the submit (and so is named in the "from-view-id" is never defined in a "to-view-id" attribute). I've now switched to using an IFRAME, and that resolves that problem. So now the JSP is defined in a "to-view-id" attribute and it includes an named IFRAME that can be used as a target. I press the submit button and I get not the JSP expected butinstead the same JSP displayed inside its own IFRAME.
    Here is the code for the submit. I've simplified it as much as possible with a static action (originally it was a call to a method) just to try and get things to work. This is the current version:
    <h:commandButton value="View Alias" action="foo" styleClass="select" type="submit" />Here is the navigation rule in faces-config.xml. Again, the problem is that SelectManager get redisplayed in the IFRAME instead of display.jsp.
    <navigation-rule>
       <from-view-id>/SelectManager.jsp</from-view-id>
       <navigation-case>
          <from-outcome>foo</from-outcome>
          <to-view-id>/display.jsp</to-view-id>
       </navigation-case>
    </navigation-rule>I have also tried it without the "from-outcome-value" which I presume means that the "to-view-id" gets displayed unconditionally and it still fails. Any ideas on how I can debug this? (I'm using GlassFish if that's important to know)
    Rob Tanner
    Linfield College

    Raymond, The real trick is avoid doing technical things when coming down with the flu (I should also add that I'm a JSF newbie). Reading your original message this time I see what you're suggesting and found a conversion error although I don't understand it. Here's the code (including the <h:message/>):
                <h:selectOneMenu value="#{members.dcodes}"
                  style="color: #7f0000" id="selector">
                  <f:selectItems value="#{members.departmentList}" />
                </h:selectOneMenu> 
                <h:message for="selector" style="color:white"/>And here's a snippet of the generated HTML:
    <select id="j_id_id26:selector" name="j_id_id26:selector" size="1" style="color: #7f0000">
             <option value="aad" selected="selected">Academic Advising</option>
         <option value="aaf">Academic Affairs</option>
         <option value="adm">Admission</option>
         <option value="up">Upward Bound</option>
    </select>If I select "Admission" for example, the error I get is:
    Conversion Error setting value 'adm' for 'null Converter'.Since everything is a String value, I don't get the error. Could someone please enlighten me.
    Thanks.

  • In a document library : group by view and manage metadata filter & Navigation problem

    Hi all, I encounter a problem when configuring a document library using a group by view and in combination with the Managed Metadata filtering and
    navigation :
    - all the documents appear under my group by, even the ones that does not correspond
    - In the other hand, the number in brackets shows the correct number of documents that should be shown
    See screenshot below. 
    Did you already encounter that issue ? Is there a workaround ?

    Hi,
    According to your post, my understanding is that you wanted to use a group by view and combine with the Managed Metadata filtering and navigation in a document library
    to show the corresponding documents with the correct numbers in SharePoint 2013.
    In my SharePoint 2013, I created a view which was group by two columns and combine with the Metadata Navigation Hierarchies and Key Filters some fields in a document
    library. As a result, it showed only items matching the filter values.
    So, I recommend that you can follow the steps to implement it in your environment.
    Step1: Enable Metadata Navigation and Filtering:
    Metadata Navigation and Filtering is a Site Feature that has to be activated for this to work.
    And, the Metadata Navigation and Filtering feature is enabled by default on most sites.
    If it is not enabled for your site, you can enable it on the Site Features pages for your site.
    You must be a Site Owner or a Site Collection Administrator to enable Metadata Navigation and Filtering.
    1. Go to “Site Settings” and click “Manage site features” under Site Actions.
    2. Find “Metadata Navigation and Filtering” in the Features list and click “Activate”.
    Step2:
    Configure Metadata Navigation:
    You must have a least the Manage Lists permission level to configure metadata navigation for a list or library.
    1. Open the document library for which you want to configure metadata navigation.
    2. Go to “Library Settings” of the document library and click “Metadata navigation settings” under “General Settings”.
    3. In the Configure Navigation Hierarchies section, select the field or fields you want to display in the navigation hierarchy and then click “Add”.
    4. By default, Folders are automatically displayed in the navigation hierarchy. If you do not want folders to display, select Folders, and then click Remove.
    5. In the Configure Key Filters section, select the fields you want to add as Key Filters, and then click “Add”.
    6. In the Configure automatic column indexing for this list, specify whether you want to automatically create indices on this list to increase the performance of the
    queries that users will perform when they use the Navigation Hierarchy and Key Filter columns you've specified. It is recommended that you select the option “Automatically manage column indices on this list”.
    7. Click “OK”.
    Step3: Set a group by two columns by modifying view in the document library:
    1. Go to the “LIBRARY” ribbon of the document library and click the “Modify view”.
    2. Click the “Group By” and select up to two columns to determine what type of group and subgroup the items in the view will be displayed in.
    3. Click “OK”.
    Step4:
    Go back to the document library, apply Navigation Hierarchies and Key Filters to do a test in your environment.
    The result will like as below:
    There is an article about how to apply Metadata Navigation Filtering in SharePoint 2013 for your reference.
    http://blogs.interfacett.com/how-to-apply-metadata-navigation-filtering-in-sharepoint-2013
    Best Regards,
    Linda Li
    TechNet Community Support

  • Web-building my site. FIREFOX and NAVIGATOR is great but not SAFARI. Why?

    Hi,
    I am building my web site http://www.philthesecurityguard.com/ everything works great on FIREFOX and NAVIGATOR but not SAFARI. Example: on my web site, I click on REAL LETTERS in SAFARI and HALF of orange squares appears outside of my letters. FIREFOX and NAVIGATOR have FULL orange squares on the outside of my letters. Another example: The vertical thin partitions on my web is red on FIREFOX and NAVIGATOR, but there is no red line on SAFARI. How come SAFARI is "short circuiting?" (I have Adobe GoLive web builder.) [email protected]

    > Tim G" <[email protected]> wrote
    in message
    > news:gha37j$7lg$[email protected]..
    > "jus2sho" <[email protected]> wrote in
    message
    > news:gha2rf$74r$[email protected]..
    >> Thierry,
    >> Can you elaborate a little on what you said. I'm a
    complete noob that
    >> knows a
    >> little about how to use DW. Will adding the .html
    extension fix my
    >> problem? I
    >> have yet to change it because I don't have access to
    Firefox to try out
    >> right
    >> now. I will in the morning.
    >
    >
    > You absolutely need to have an HTML-compatible
    extension. Whether that is
    > your only problem... well, fix that, and then see.
    Configuring the server would allow the OP to use file names
    with no
    extension [1], which imho would be a better approach [2].
    Cool URIs don't change...
    [1]
    http://www.w3.org/Provider/Style/URI
    [2]
    http://www.w3.org/Provider/Style/URI#remove
    Thierry | Adobe Community Expert | Articles and Tutorials ::
    http://www.TJKDesign.com/go/?0
    Spry Widgets |
    http://labs.adobe.com/technologies/spry/samples/
    [click on
    "Widgets"]
    Spry Menu Bar samples |
    http://labs.adobe.com/technologies/spry/samples/menubar/MenuBarSample.html

  • Navigation Problem in OBIEE

    Hi,
    I have a strange navigation problem. I have the navigation setup from the 1st page of my dashboard to go to the second. When I first bring up the first page, and then click , nothing happens. Now if I refresh this page and then click again, I am able to navigate to the second page. I would to hear if anyone has seen similar issue. Any help is appreciated.
    Thanks,
    Bharat

    Still haven't found a solution to this problem.
    Even if I remove the form1.setTarget( null or other framename/windowname)
    I tried changing to using the onclick="from1.target='mywin';" and also onclick="form1.target='_self'; on the button. Does not work/ have the desired effect of controlling where the page is opened: in same window or in another frame or window.
    For some reason navigation also totally breaks, after a search, with a similar sql as in this message, and I get no error when I debug and step through the code.
    After doing one search, navigation seems to stop working and only the search.jsp page is the target.
    If I do a view first navigation works to new page/servlet output but still not in a new window/frame.
    This simple stuff in a normal simle html page, should not be so hard to accive with SJSC perhaps someone of you in the community or the developers at sun can give us insight into this simple problem.
    It must be fairly common that one likes to control where a page is opened, in the existing window/page/frame or in a new window/frame.
    Anybody else had any problems with navigation not working with similar code ??
    If I remove the do_search() call it works, the navigation continues to function, but still have no control of the destination window/frame.
    Kind Regards
    Roger

  • Format issue causing iBook navigation problems

    Hello!
    I created an iBook for a client, but some of the default functions of an iBook aren’t working when it’s previewed on iPad. My question is: since the file format seems to be the issue, what can be done to alleviate it?
    Problems
    When previewing the iBook on the iPad...
    Framing features such as navigation bar, book info, bookmark tool, etc. are missing
    The pages lack animated page turns
    Right and left page edge riffles are missing
    When the iPad is turned vertically…
    Pages scroll top to bottom instead of left to right as they should
    All images disappear
    Basically, the iBooks works mostly well in landscape mode but not so much in portrait mode. The client checked other iBooks to compare and the iBook I created is the only one with problems with the interface functions.
    Steps Taken To Save & Preview File
    Saved the iBook file as an IBA file. I also Exported it as an iBooks file.
    Sent IBA and iBooks files to the client to preview on his iPad (I don’t have one so I can’t preview it myself).
    The client opened the IBA file using iBooks Author then clicked the “Preview” button.
    The IBA file cross-loads to the iPad and the problems can be seen.
    The client also attempted to load the IBA and iBooks files on the Book Proofer application (this application does accept IBA and iBooks files), but that didn't work either. The client told me that are some file format issues unrelated to content, leading me to believe that it's a format issue.
    Technical Specifications
    iBook Author version I used to create iBook
    1.1 (the latest)
    iBooks version client used to preview iBook
    iBooks version 2.1.1 (April 16, 2012 release)
    iPad version the iBook is being previewed on
    1st Generation 64GB iPad
    File being used to preview on iPad
    The IBA and iBooks files for the iBook
    Could it be file format incompatibilities? Has anyone had this issue before? I hope the information I provided is useful. Any insight about these issues is greatly appreciated!
    Thanks,
    Catrina

    Again, sorry, a 'Shared' .ibooks file has the same format as what users download from the store.
    You don't need to be in the store to circulate that file. 'private' as defined depends on you. Email that file if possible and/or put it on your own server/dropbox and share the link to trusted individuals.
    If you're sending the .iba file to someone that then uses it in iBA, they need to use the 'Shared' menu to generate an .ibooks file, then drop that into iTunes and sync to their device.
    See iBooks Author: Publishing and distribution FAQ - Support

  • Create View without inbound, outbound and navigation link

    Please look at this picture:
    There are:
    + PanelView
    + View 01
    + View 02
    + EmptyView
    In the PanelView, there are two buttons,  button01 and button02. When press on button01, it shows View01; when press on button02, it shows View02.
    Problem is:
    How to do above things without creating inbound, outbound and navigation link.
    Thank u a lot.

    Dear Mr.         Raghunandan Madarikuruva ,
    Everything is very easy if there are inbound, outbound, and navigation link.
    What happen if there isn't inbound, outbound, and navigation link.
    My problem is how to open each childview without  inbound, outbound, and navigation link.
    How can I do that
    Thank you for answer my question.
    Thank you again
    This is yahoo ID: [email protected]
    and Skype ID: doleminhtriet
    May I talk to you?
    Edited by: krisscage krisscage on Sep 26, 2008 10:53 AM

  • Appearance & navigation problem in mail (mailboxes doubled)

    After synchronizing my Apple Mail and importing my Mailboxes I have noticed some problems. In the navigation column the folder "ON MY MAC" (including all my personal mailboxes) appears twice. Navigation doesn't work properly anymore. On of the two "ON MY MAC"-folder cannot be navigated (fold out and fold in doesn't work) anymore. All my personal Mailboxes have been duplicated, too. I cannot get rid of them and navigation has become awkward ... anyone anything similar?
    Message was edited by: Dan Nessler

    I just reported the same problem of doubled emails under the "ON MY MAC" folder. Only one of the folders work properly, but sometimes it is one, then the other.
    Perhaps unrelated is the reappearance of deleted "Draft" email. They reappear at the next Mail execution.

  • RoadMap UI Navigation Problem

    I'm facing a navigation problem using the roadmap UI in WD4A.
    Let's say we have 5 views. The roadmap view is the default view, the other views will be embedded into a view container UI element on the roadmap view. The roadmap UI has 4 steps, one for each view.
    V_ROADMAP
    V_STEP_1
    V_STEP_2
    V_STEP_3
    V_STEP_4
    Now, I need to add navigation buttons (previous & next) to navigate between the roadmap steps.
    My question is where should I placed these navigation buttons? On each view or only on the roadmap view.
    Personnaly and it think it would make more sense to place them only on the roadmap view.
    My problem using this approach is has follow: When you are on v_roadmap on step 1 (V_STEP_1), you click on Next to go to the next view (V_STEP_2), actually the action is trigger in V_ROADMAP so I am not able to validate user input field or obligatory field in V_STEP_1. I would have to call an action from V_STEP_1 in V_ROADMAP so the event handler method WDDOBEFOREACTION will be called. I don't think it's possible. The problem here, is you can click on next and you can go to the next view without filling the obligatory fields.
    If I placed my navigation buttons on each view. The advantage is that before triggering an action, I can validate user input field, obligatory field in the method WDDOBEFOREACTION before going to the next step.
    The desadvantage is that I have to recreate them on each of my view.
    thanks
    Alex

    Just to close this thread, I will summarize the different possible options:
    Navigation buttons on each view: This is the easiest way to validate obligatory fields but for component reuse it's not good idea to have navigation buttons on individual views.
    Navigation buttons on main views: If we placed the navigation buttons on our main view, the validation is kind of painful, before firing an outbound plug from the main view and a corresponding inbound plug on the individual view, we will have to manually verify our obligatory fields from the context of the componenent controller or using cross-component data sharing.
    Navigation using GAF (Guided Activity Floorplan): I think this option is the way to go! The problem here is that's very difficult to find documentation on that subject, also, the tools from SP 15 is not as user friendly then the one that's coming in NW EhP1.
    Alex

  • Pages and Navigation Pages

    What's the difference between Pages and Navigation Pages? Can I change a Page to Navigation Page? If yes, how?
    Thanks a lot.

    The basic problem is that the default page only applies when you haven't yet accessed the book. Once you have accessed it , the last accessed page within the book is what gets displayed. (if the page label specified is the books).
    as before, you either must implement your logic in a backing file or you must generate the url to the book correctly (by having the page label of the page you want active) i.e. if your book has a pagelabel b1 and your pages have labels p1 and p2 and you always want b1 to goto p2 (the default) , then whenever you want to generate a URL to the book you must use P2 as the label (whether it is custom menu or anywhere else in your site).
    The reason the first option is preferable because the logic lives with your book's backing file, in the second case it is spread out (even if you use a helper)
    regards
    deepak

  • ActionListener and Inner Class Issue

    When I add ".addActionListener()" to buttons and create an inner class to listen/handle the action, my main class does not display the GUI. If I remove the ".addActionListener()" from the buttons and the inner class, the GUI displays. Below is my code. Anyone know what is wrong with my code?
    package projects.web;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    public class AppletGUI{
         // JButtons
         JButton addButton = new JButton("Add");
         JButton removeButton = new JButton("Remove");
         JButton saveButton = new JButton("Save");
         JButton cancelButton = new JButton("Cancel");
         // JPanels
         JPanel containerPanel = new JPanel();
         JPanel optionsPanel = new JPanel();
         JPanel thumbnailPanel = new JPanel();
         JPanel selectionPanel = new JPanel();
         // JScrollPane
         JScrollPane thumbnailScroll;
         public AppletGUI(JRootPane topContainer){
              // Add actionListener
              addButton.addActionListener(new ButtonHandler());
              removeButton.addActionListener(new ButtonHandler());
              saveButton.addActionListener(new ButtonHandler());
              cancelButton.addActionListener(new ButtonHandler());
              // Set border layout
              containerPanel.setLayout(new BorderLayout());
              // Add buttons to target panels
              optionsPanel.add(addButton);
              optionsPanel.add(removeButton);
              selectionPanel.add(saveButton);
              selectionPanel.add(cancelButton);
              // Set size and color of thumbnail panel
              thumbnailPanel.setPreferredSize(new Dimension (600,500));
              thumbnailPanel.setBackground(Color.white);
              thumbnailPanel.setBorder(new LineBorder(Color.black));
              // Add thumbnail panel to scrollpane
              thumbnailScroll = new JScrollPane(thumbnailPanel);
              // Set background color of scrollPane
              thumbnailScroll.setBackground(Color.white);
              // Add subpanels to containerPanel
              containerPanel.add(optionsPanel, BorderLayout.NORTH);
              containerPanel.add(thumbnailScroll, BorderLayout.CENTER);
              containerPanel.add(selectionPanel, BorderLayout.SOUTH);
              // Add containerPanel to rootPane's contentPane
              topContainer.getContentPane().add(containerPanel);
         } // end constructor
         class ButtonHandler implements ActionListener{
              public void actionPerformed(ActionEvent event){
                   new FileBrowser();
              } // end actionPerformed method
         } // end inner class ActionHandler
    } // end AppletGUI class package projects.web;
    import java.awt.*;
    import java.io.*;
    import javax.swing.*;
    import javax.swing.filechooser.*;
    public class FileBrowser{
         JFileChooser fileChooser = new JFileChooser();
         public FileBrowser(){
              int fileChooserOption = fileChooser.showOpenDialog(null);
         } // end constructor
    } // end class fileBrowser

    Encephalopathic wrote:
    Dan: When it doesn't display, what happens? Do you see any error messages? Also, please take a look at your other thread in this same forum as it has relevance to our conversations in the java-forums.org about whether to add GUIs to root containers or the other way around. /PeteI fiddled with the code some more and it seems that the problem is the inner code. When I changed from the inner class to the main class implementing ActionListener and had the main class implement the actionPerformed method, the GUI displayed and JFileChooser worked as well. I've add this version of the code at the bottom of this message.
    To answer your question: When it doesn't display, what happens? -- The web page loads and is blank. And there are no error messages.
    I took a look at the other thread is this forum (the one relates to our conversation in the other forum); the problem may be the way I've add the GUI. I'll try it the other way and see what happens.
    Thanks,
    Dan
    package projects.web;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    public class AppletGUI implements ActionListener{
         // JButtons
         JButton addButton = new JButton("Add");
         JButton removeButton = new JButton("Remove");
         JButton saveButton = new JButton("Save");
         JButton cancelButton = new JButton("Cancel");
         // JPanels
         JPanel containerPanel = new JPanel();
         JPanel optionsPanel = new JPanel();
         JPanel thumbnailPanel = new JPanel();
         JPanel selectionPanel = new JPanel();
         // JScrollPane
         JScrollPane thumbnailScroll;
         public AppletGUI(JRootPane topContainer){
              // Add actionListener
              addButton.addActionListener(this);
              removeButton.addActionListener(new ButtonHandler());
              saveButton.addActionListener(new ButtonHandler());
              cancelButton.addActionListener(new ButtonHandler());
              // Set border layout
              containerPanel.setLayout(new BorderLayout());
              // Add buttons to target panels
              optionsPanel.add(addButton);
              optionsPanel.add(removeButton);
              selectionPanel.add(saveButton);
              selectionPanel.add(cancelButton);
              // Set size and color of thumbnail panel
              thumbnailPanel.setPreferredSize(new Dimension (600,500));
              thumbnailPanel.setBackground(Color.white);
              thumbnailPanel.setBorder(new LineBorder(Color.black));
              // Add thumbnail panel to scrollpane
              thumbnailScroll = new JScrollPane(thumbnailPanel);
              // Set background color of scrollPane
              thumbnailScroll.setBackground(Color.white);
              // Add subpanels to containerPanel
              containerPanel.add(optionsPanel, BorderLayout.NORTH);
              containerPanel.add(thumbnailScroll, BorderLayout.CENTER);
              containerPanel.add(selectionPanel, BorderLayout.SOUTH);
              // Add containerPanel to rootPane's contentPane
              topContainer.getContentPane().add(containerPanel);
         } // end constructor
         public void actionPerformed(ActionEvent event){
                   new FileBrowser();
              } // end actionPerformed method
         class ButtonHandler implements ActionListener{
              public void actionPerformed(ActionEvent event){
                   new FileBrowser();
              } // end actionPerformed method
         } // end inner class ActionHandler
    } // end AppletGUI class

  • Mandatory Fields and Navigation Buttons

    Hi
    I have a search form where I search by number, then I have the choice to update and submit the request. All fields are required for submission. The problems is that when I have empty fields I cannot use the search and navigation buttons, I tried to set Immediate to true but then the buttons would not perform their action. How can I solve this?
    Your help would be appreciated

    Hi,
    immediate works in the combination with response complete. However, because you are omitting the model update you will have to do this manually in an action method or action listener
    Frank

  • Date Navigator problems

    Hi all,
    I have 2 issues to solve about BSP date navigator added using the showHelp attribute of InputField.
    1 - The header with the days abbreviations shows a mix of values in different languages, how can I change them?
    2 - The popup of Date Navigator is shown in a Development environment but not in a Quality one. Does it need any particular setting?
    Thanks in advance.
    Angelo

    Hi Angelo,
    we are also on 640 SP 13 and were facing the same problem. So we opened a SAP call and the problem should be solved with the last SAP_BASIS support package.
    Unfortunately no sap hint exists for that topic.
    Now we're trying to find out which the last one is, expecting no errors anymore
    Regards,
    Sebastian

  • Java Audio Metronome | Timing and Speed Problems

    Hi all,
    I’m starting to work on a music/metronome application in Java and I’m running into some problems with the timing and speed.
    For testing purposes I’m trying to play two sine wave tones at the same time at regular intervals, but instead they play in sync for a few beats and then slightly out of sync for a few beats and then back in sync again for a few beats.
    From researching good metronome programming, I found that Thread.sleep() is horrible for timing, so I completely avoided that and went with checking System.nanoTime() to determine when the sounds should play.
    I’m using AudioSystem’s SourceDataLine for my audio player and I’m using a thread for each tone that constantly polls System.nanoTime() in order to determine when the sound should play. I create a new SourceDataLine and delete the previous one each time a sound plays, because the volume fluctuates if I leave the line open and keep playing sounds on the same line. I create the player before polling nanoTime() so that the player is already created and all it has to do is play the sound when it is time.
    In theory this seemed like a good method for getting each sound to play on time, but it’s not working correctly.
    At the moment this is just a simple test in Java, but my goal is to create my app on mobile devices (Android, iOS, Windows Phone, etc)...however my current method isn’t even keeping perfect time on a PC, so I’m worried that certain mobile devices with limited resources will have even more timing problems. I will also be adding more sounds to it to create more complex rhythms, so it needs to be able to handle multiple sounds going simultaneously without sounds lagging.
    Another problem I’m having is that the max tempo is controlled by the length of the tone since the tones don’t overlap each other. I tried adding additional threads so that every tone that played would get its own thread...but that really screwed up the timing, so I took it out. I would like to have a way to overlap the previous sound to allow for much higher tempos.
    I posted this question on StackOverflow where I got one reply and my response back explains why I went this direction instead of preloading a larger buffer (which is what they recommended). In short, I did try the buffer method first, but I want to also update a “beat counter” visual display and there was no way to know when the hardware was actually playing the sounds from the buffer. I mentioned that on StackOverflow and I also asked a couple more questions regarding the buffer method, but I haven’t received any more responses.
    http://stackoverflow.com/questions/24110247/java-audio-metronome-timing-and-speed-problems
    Any help getting these timing and speed issues straightened out would be greatly appreciated! Thanks.
    Here is my code...
    SoundTest.java
    import java.awt.*; 
    import java.awt.event.*; 
    import javax.swing.*; 
    import javax.swing.event.*; 
    import java.io.*; 
    import javax.sound.sampled.*; 
    public class SoundTest implements ActionListener { 
        static SoundTest soundTest; 
        // ENABLE/DISABLE SOUNDS 
        boolean playSound1  = true; 
        boolean playSound2  = true; 
        JFrame mainFrame; 
        JPanel mainContent; 
        JPanel center; 
        JButton buttonPlay; 
        int sampleRate = 44100; 
        long startTime;  
        SourceDataLine line = null;  
        int tickLength; 
        boolean playing = false; 
        SoundElement sound01; 
        SoundElement sound02; 
        public static void main (String[] args) {        
            soundTest = new SoundTest(); 
            SwingUtilities.invokeLater(new Runnable() { public void run() { 
                soundTest.gui_CreateAndShow(); 
        public void gui_CreateAndShow() { 
            gui_FrameAndContentPanel(); 
            gui_AddContent(); 
        public void gui_FrameAndContentPanel() { 
            mainContent = new JPanel(); 
            mainContent.setLayout(new BorderLayout()); 
            mainContent.setPreferredSize(new Dimension(500,500)); 
            mainContent.setOpaque(true); 
            mainFrame = new JFrame("Sound Test");                
            mainFrame.setContentPane(mainContent);               
            mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
            mainFrame.pack(); 
            mainFrame.setVisible(true); 
        public void gui_AddContent() { 
            JPanel center = new JPanel(); 
            center.setOpaque(true); 
            buttonPlay = new JButton("PLAY / STOP"); 
            buttonPlay.setActionCommand("play"); 
            buttonPlay.addActionListener(this); 
            buttonPlay.setPreferredSize(new Dimension(200, 50)); 
            center.add(buttonPlay); 
            mainContent.add(center, BorderLayout.CENTER); 
        public void actionPerformed(ActionEvent e) { 
            if (!playing) { 
                playing = true; 
                if (playSound1) 
                    sound01 = new SoundElement(this, "Sound1", 800, 1); 
                if (playSound2) 
                    sound02 = new SoundElement(this, "Sound2", 1200, 1); 
                startTime = System.nanoTime(); 
                if (playSound1) 
                    new Thread(sound01).start(); 
                if (playSound2) 
                    new Thread(sound02).start(); 
            else { 
                playing = false; 
    SoundElement.java
    import java.io.*; 
    import javax.sound.sampled.*; 
    public class SoundElement implements Runnable { 
        SoundTest soundTest; 
        // TEMPO CHANGE 
        // 750000000=80bpm | 300000000=200bpm | 200000000=300bpm 
        long nsDelay = 750000000; 
        long before; 
        long after; 
        long diff; 
        String name=""; 
        int clickLength = 4100;  
        byte[] audioFile; 
        double clickFrequency; 
        double subdivision; 
        SourceDataLine line = null; 
        long audioFilePlay; 
        public SoundElement(SoundTest soundTestIn, String nameIn, double clickFrequencyIn, double subdivisionIn){ 
            soundTest = soundTestIn; 
            name = nameIn; 
            clickFrequency = clickFrequencyIn; 
            subdivision = subdivisionIn; 
            generateAudioFile(); 
        public void generateAudioFile(){ 
            audioFile = new byte[clickLength * 2]; 
            double temp; 
            short maxSample; 
            int p=0; 
            for (int i = 0; i < audioFile.length;){ 
                temp = Math.sin(2 * Math.PI * p++ / (soundTest.sampleRate/clickFrequency)); 
                maxSample = (short) (temp * Short.MAX_VALUE); 
                audioFile[i++] = (byte) (maxSample & 0x00ff);            
                audioFile[i++] = (byte) ((maxSample & 0xff00) >>> 8); 
        public void run() { 
            createPlayer(); 
            audioFilePlay = soundTest.startTime + nsDelay; 
            while (soundTest.playing){ 
                if (System.nanoTime() >= audioFilePlay){ 
                    play(); 
                    destroyPlayer(); 
                    createPlayer();              
                    audioFilePlay += nsDelay; 
            try { destroyPlayer(); } catch (Exception e) { } 
        public void createPlayer(){ 
            AudioFormat af = new AudioFormat(soundTest.sampleRate, 16, 1, true, false); 
            try { 
                line = AudioSystem.getSourceDataLine(af); 
                line.open(af); 
                line.start(); 
            catch (Exception ex) { ex.printStackTrace(); } 
        public void play(){ 
            line.write(audioFile, 0, audioFile.length); 
        public void destroyPlayer(){ 
            line.drain(); 
            line.close(); 

    Thanks but you have never posted reply s0lutions before ?? And F 4 is definitely not 10 times faster as stated before I upgraded !!

  • Mouse navigations problem with Sun Java 1.5.0_*

    Hello gurus,
    We need to move from JInitiator to Sun Java Plugin; according to the Forms10g Client Platform Support (http://www.oracle.com/technology/products/forms/htdocs/10gR2/clientsod_forms10gR2.html) one of the certified version for Forms 10.1.2.0.2 of the the Sun Java Plugin is 1.5.0_06 and Internet Explorer 6.0, we have tested also SJPI 1.5.0_09 and we get the same mouse navigation problem reported in the following Oracle Forum threads.
    Mouse navigation don't work with Java Plugin.
    Mouse navigation don't work with Java Plugin.
    Forms 10gR2, Sun Java 1.5.0_06 gives mouse problems
    Forms 10gR2, Sun Java 1.5.0_06 gives mouse problems
    Does anybody know a solution to this problem?
    Any help will be really appreciated.
    Regards,
    Victor.

    You need to use 1.5.0_12 or newer. The client SOD is not up-to-date on this specific point. A lot of navigation problems was fixed in this very release.
    The Management team should change this in the client SOD, wonder why they still refer to 1.5.0_06. For Applications, the first 1.5.0 to be certified was _12.
    Also make sure, that you are using the latest Patch 3 for 10.1.2 (10.1.2.3). This patch also contains fixes for a lot of these wellknown issues.
    Hope this helps,
    Jacob

Maybe you are looking for

  • Premiere Pro CS3 won't import audio on an avi file

    I just recently borrowed a friend's HD camera to film some scenes for a video. I had to import them onto my computer using a converter because my computer is a windows vista (  >:(  )  and the files on the camera are MTS files (they aren't compatible

  • Refrential integrity between 2 oracle DB

    I have to create a foreign key constraint with the table in diffrent oracle DB. I tried creating a synonym through DBlink but mentioning that synonym as the refrence throws error: ORA-02444: Cannot resolve referenced object in referential constraints

  • Portal Theme Error

    Hi, I've copied the standart "sap tradeshow" theme to TEST and set is as default for everyone by changing the default main rule settings. But someting looks wrong and when i call portal URL, it appears but when i logged in it displays an empty page.

  • After Effects 12.2 Cache won't empty

    Hello, just updated to the new AE version and really soon i run in a problem. The Purge - All memory and disc cache doesn't work anymore. I can't delete the cache even in the preference window. Nothing happens. It recognize the exact space occupied b

  • Out of the blue my cpu started heating...

    out of the blue my cpu started getting hot. i noticed the wine of the fans picking up speed. and then theyd die down. so i watched my temp stat widget and sure enough the cpu keep getting hot then the fans cool it down then like three min later they