Cftextarea problem

I have a page main.cfm which contains a cflayout using tabs.
One of the tabs displays a page details.cfm, which contains a
cfform with a cftextarea with richtext set to yes.
The submit button runs an update.cfm page, which doesn't
display anything, but instead redirects back to details.cfm after
updating a record in a database.
After you click the submit button the application does its
thing, but displays the following message:
Error: The TEXTAREA with id or name set to
"cf_textarea1233196607205" was not found.
When you click OK the details.cfm page displays in the tab,
with the updated information from the database, but the rich text
editor has gone and been replaced with a default size HTML textarea
control.
I'm new to all this so haven't a clue as to where to look to
fix this, as everything seems to be working right apart from this
particular error.
Any ideas?

in your case that is probably not the way to do a redirect,
since your
page doing the redirect is inside an ajax container.
have you tried using ColdFusion.navigate() function instead?
you may have to write a js function (in your MAIN page - the
one that
has cflayout tags in it) that uses ColdFusion.navigate() to
do the
redirect, and then call that function using <cfset
ajaxonload('name_of_your_js_function')> at the bottom of
your update.cfm
page.
more details on both ColdFusion.navigate() and ajaxonload()
are in the
cfml reference.
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

Similar Messages

  • Problem with cfdocumentsection cftextarea

    Hi,
    I am using <cfdocument format="PDF">,
    within my <cfdocumentsection> I call another .cfm file which contains
      <cftextarea label="example" disabled="disabled" name="somename" wrap="virtual" message="Your qualifications are restricted to 500 characters" value="#getdata.stuff#" required="no" rows="3" cols="80" maxlength="500" validate="maxlength" validateAt="onBlur"  />
    If this textarea contains more then about 50 characters the text dosen't appeare on the pdf.
    If the textarea contains just a few words it works fine.
    Would you have any idea what this problem could be?
    Thanks,Suzanne

    Because all of the form pages that are used in this application are just displayed in this PDF as 1 option for the Administrator at the end of the process. Any other ideas that don’t require me re-writing pages and pages of code?
    Suzanne Jarrett
    Web Programmer for CalHR
    [email protected]
    916-323-4491

  • Cftextarea rich editor not displaying with non-english browsers.

    Hello people, a client of mine is experiencing the following problem: When she needs to modify text that is in a rich editor (using cftextarea), the administrator returns an error only if the browser is a Non-English browser. She is in Quebec and speaks French. I've tried in spanish and I got the error. However, it works perfect in English.
    Here is the error:
    The web site you are accessing has experienced an unexpected error.
    Please contact the website administrator.
    The following information is meant for the website developer for debugging purposes.
    Error Occurred While Processing Request
    Security: The requested template has been denied access to C:\Inetpub\wwwroot\CFIDE\scripts\ajax\messages\cfmessage_fr__.js.
    The following is the internal exception message: access denied (java.io.FilePermission C:\Inetpub\wwwroot\CFIDE\scripts\ajax\messages\cfmessage_fr__.js read)
    ColdFusion cannot determine the line of the template that caused this error. This is often caused by an error in the exception handling subsystem.
    Resources:
    * Check the ColdFusion documentation to verify that you are using the correct syntax.
    * Search the Knowledge Base to find a solution to your problem.
    Browser        Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.0.15) Gecko/2009101601 Firefox/3.0.15 (.NET CLR 3.5.30729)
    Remote Address        173.179.212.104
    Referrer        http://www.carbonnel.ca/admin/admin.cfm
    Date/Time        30-Oct-09 06:17 PM
    Stack Trace
    java.security.AccessControlException: access denied (java.io.FilePermission C:\Inetpub\wwwroot\CFIDE\scripts\ajax\messages\cfmessage_fr__.js read) at cfaddBio2ecfm1752062533.runPage(D:\home\carbonnel.ca\wwwroot\admin\addBio.cfm:53)
    java.security.AccessControlException: access denied (java.io.FilePermission C:\Inetpub\wwwroot\CFIDE\scripts\ajax\messages\cfmessage_fr__.js read)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
    at java.security.AccessController.checkPermission(AccessController.java:546)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
    at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
    at java.io.File.exists(File.java:731)
    at coldfusion.tagext.html.ajax.AjaxRBFileMap.fileExists(AjaxRBFileMap.java:114)
    at coldfusion.tagext.html.ajax.AjaxRBFileMap.getRBFileName(AjaxRBFileMap.java:81)
    at coldfusion.tagext.html.ajax.AjaxRBFileMap.importResourceBundleJS(AjaxRBFileMap.java:52)
    at coldfusion.tagext.html.ajax.HtmlAssembler.importJS(HtmlAssembler.java:916)
    at coldfusion.tagext.html.ajax.HtmlAssembler.importJS(HtmlAssembler.java:826)
    at coldfusion.tagext.html.ajax.HtmlAssembler.importJS(HtmlAssembler.java:792)
    at coldfusion.tagext.html.ajax.RichTextEditorHelper.generateImports(RichTextEditorHelper.jav a:41)
    at coldfusion.tagext.html.ajax.AjaxImportTag.generateImports(AjaxImportTag.java:266)
    at coldfusion.tagext.html.ajax.RichTextEditorHelper.setUpRichTextEditor(RichTextEditorHelper .java:51)
    at coldfusion.tagext.html.form.TextareaTag.doEndTag(TextareaTag.java:710)
    at cfaddBio2ecfm1752062533.runPage(D:\home\carbonnel.ca\wwwroot\admin\addBio.cfm:53)
    at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:231)
    at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:416)
    at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
    at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:363)
    at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
    at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
    at coldfusion.filter.PathFilter.invoke(PathFilter.java:87)
    at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)
    at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:2 8)
    at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
    at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
    at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
    at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
    at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:53)
    at coldfusion.CfmServlet.service(CfmServlet.java:200)
    at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
    at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
    at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42 )
    at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
    at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
    at jrun.servlet.FilterChain.service(FilterChain.java:101)
    at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
    at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
    at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)
    at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
    at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)
    at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)
    at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
    at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)
    at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
    Any idea?
    Thiez Multimedia
    [email protected]

    Solved.  Turns out i needed to add /CFIDE into my "exclusions" from ISAPI Rewrite's .htaccess file.

  • Submit button in cftextarea value

    Hello~
    I have a cftextarea whose value is being populated from a database. The problem is, some of the values contain form code, including submit buttons. Most of the form displays correctly inside the richtext cftextarea, but the Submit button is always displayed outside of the text box, rather than as part of the textbox value. I have html set to yes, and I am using the richtext option. Any ideas? Thanks!

    Esacpabe the HTML with either htmlCodeFormat() or htmlEditFormat().  One ads a set of ,<pre></pre> tags, but I can never keep them straight without looking at the documentation.
    Otherwise the Browser is going to see the HTML tags and parse them in order they find them.  Browsers are not strict about tags being closed before other tags opening so you can't put unescaped tag code inside something like another <textarea></textarea> HTML tag block.

  • ColdFusion.RichText.setValue not working if cftextarea in a cfwindow

    Title describes the issue.  If I place the cftextarea control outside of the cfwindow, then the ColdFusion.RichText.setValue works fine.  Has anyone else had this issue, and how did you solve it?
    Javascript:
    function  
    showEditTextWindow() {l_sectHeading= document.getElementById('hiddenSectHeading').value;
     var msgbox = document.forms['editTextSectionForm'].textSectionHeading.id;
     var edObj = ColdFusion.RichText.getEditorObject(msgbox);
     var jtext = edObj.GetXHTML(true);
     var msgboxValue = jtext += msgbox;
    ColdFusion.RichText.setValue(msgbox, decodeURIComponent(l_sectHeading));  
    ColdFusion
    .Window.show('editTextSectionWindow');}
    Cfwindow/cftextarea:
    <cfwindow   
    name="editTextSectionWindow"
     headerStyle = "FONT-WEIGHT: normal; FONT-SIZE: 10pt; font-style: normal; COLOR: white; FONT-FAMILY: Arial, Helvetica, sans-serif; TEXT-ALIGN: center; background-color: ##0000a0;"
     bodyStyle = "FONT-WEIGHT: normal; FONT-SIZE: 8pt; font-style: normal; COLOR: black; FONT-FAMILY: Arial, Helvetica, sans-serif; TEXT-ALIGN: center; background-color: white;"
     center="true"  
    closable="true"  
    destroyOnClose ="true"  
    draggable="true"  
    initShow="false"  
    resizable="false"  
    modal="true"
     width="600"  
    height="450"  
    title="Edit Heading Text"<!---minHeight="number of pixels"
    minWidth="number of pixels"
    onBindError = "JavaScript function name"
    refreshOnShow = "false|true"
    source="member/office/dsp_zipCodeRequest.cfm"
    x="numeric pixel coordinate"
    y="numeric pixel coordinate"--->
    >
    <cfform  name="editTextSectionForm">
     < div class="centered">
     <cfparam  name="attributes.sectHeading" default=""><cfparam 
    name="attributes.sectText" default="">
      <cfoutput>
    < div style="text-align: center;">
      < table>
     < tr><td> </td></tr>< 
    tr>
     <td style="vertical-align: top;">Heading:</td>
     <td><cftextarea name="textSectionHeading"
     richtext="true"
     height="60"
     width="500"
     toolbar="Basic"
     bind="hiddenSectHeading"
     value="#attributes.sectHeading#"/>
     </td></ 
    tr>< 
    tr><td> </td></tr>< 
    div id="editTextBodyDiv">< 
    tr>
     <td style="vertical-align: top;">Text:</td>
     <td>
     <cftextarea name="textSectionText" id="textSectionText"
     richtext="true"
     height="250"
     width="500"
     toolbar="Basic"
     value="#attributes.sectText#"/>
     </td></ 
    tr></ 
    div></ 
    table>
     </ div></cfoutput>input type="button" name="updateTextSectionButton" value="Update" onclick="updateTextSection();">
      < input type="button" name="CancelTextSectionButton" value="Cancel" onclick="cancelShowWindow('editTextSectionWindow');"></ 
    div></cfform>
    </cfwindow>

    Why is it that you can't ask a proper question?
    I took the time to answer you question and stated that we can't help you based on the information provided.
    I gave you a couple of pieces of information that we would need to help answer your question.
    I gave you a link that showed you how to write a simple program, incorporating the information that we would need to help solve the problem.
    I suggested that the problem was related to the fact that the value of the scrollbar was not in its final state. I tried to help but I am not a mind reader.
    Why did you bother to repsond to the question without providing any more information? Why is it that when you ask for help you don't listen to the suggestions given in order to help solve your problem?
    If you've read my postings previously, then why do I have to repeat the basics of asking a simple question?
    I don't deny that some of my postings have a bit of an attitude. Its because I get tired of trying to be a mind reader and guessing how one line of code interacts with the rest of your program or guessing what the intent of your code is.
    But at least I made the effort to tell you what was wrong with the question and why we can't provide an definite answer. The least you code have done is provide your demo code.

  • Cftextarea pdf copy/paste line breaks

    When I copy and paste from a pdf into cftextarea using the Paste as Word or Paste as Plain Text features, it adds line breaks to each line.  Has anyone had experience with this and know how to remove those extra line breaks at the time of pasting the text?
    ColdFusion 8

    Thanks, CtDave for the response. To follow up on your comment I've discovered a few things from this thread:copying from pdf comes out in single column
    This problem primarily happens when exporting/saving a PDF using Apple's native PDF processor, "Quartz," meaning whenever you use iWorks Pages, MS Word for Mac, or save a PDF via the Print dialogue, it will result in a PDF that doesn't comply to the standards CtDave outlined (presumably). One can mitigate this problem by opening the PDF in Preview vs. Adobe Reader or Acrobat—copy and pasting should work if its all in the Apple universe.
    Obviously thats not practical if one intends on producing documents for the masses. Alternatively, creating documents in Indesign would mitigate that problem but that involves expertise outside of traditional word processing.
    Thats all I got for now.
    Thanks,

  • Strange margin around CFTEXTAREA

    Hello,
    I was trying the richtext editor with CFTEXTAREA. Locally
    everything works perfect, but when I try it online on a dutch
    provider (www.webstekker.nl) I get a strange problem:
    There is a margin visible around the editor. To make it extra
    visible I put a red backgroundcolor color around it, and you see
    that there is a margin in the Iframe of the editor. when I load the
    testpage in Firefox, it is even worse. There the entire background
    is shining thru the editor. Locally, I have no problem with a
    standard installation.
    It looks like every script is accessable in the CFIDE folder,
    so I'm really puzzled. Does anyone have an idea?
    example:
    http://www.beau-anne.nl/test.cfm
    Src:
    <!--- ---------------------------- --->
    <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
    <!--
    function FCKeditor_OnComplete(editorInstance)
    editorInstance.Config["ToolbarSets"]["BasicMin"] = [
    ['Bold','Italic','Underline'],
    ['OrderedList','UnorderedList'],
    ['TextColor','BGColor']
    editorInstance.EditorWindow.parent.FCK.ToolbarSet.Load('BasicMin'
    //-->
    </SCRIPT>
    <table>
    <tr>
    <td style="background-color:red;">
    <cfform method="POST" action="" name="testform">
    <cftextarea name="content" richtext="true" toolbar="Basic"
    width="500"></cftextarea>
    </cfform>
    </td>
    </tr>
    </table>
    <!--- ---------------------------- --->

    Tijsje wrote:
    >
    > It looks like every script is accessable in the CFIDE
    folder, so I'm really
    > puzzled. Does anyone have an idea?
    >
    Clashing styles from any one of these style sheets associated
    with that
    page?
    http://www.beau-anne.nl/CFIDE/scripts/ajax/FCKeditor/editor/skins/default/fck_editor.css
    http://www.beau-anne.nl/CFIDE/scripts/ajax/FCKeditor/editor/css/fck_editorarea.css
    http://www.beau-anne.nl/CFIDE/scripts/ajax/FCKeditor/editor/css/fck_internal.css
    http://www.beau-anne.nl/CFIDE/scripts/ajax/FCKeditor/editor/css/fck_showtableborders_gecko .css
    http://www.beau-anne.nl/CFIDE/scripts/ajax/FCKeditor/editor/skins/default/fck_editor.css
    http://www.beau-anne.nl/CFIDE/scripts/ajax/FCKeditor/editor/skins/default/fck_editor.css
    http://www.beau-anne.nl/CFIDE/scripts/ajax/FCKeditor/editor/skins/default/fck_editor.css
    I'm not sure why the last one is listed three times in my
    FireFox View
    CSS tool.

  • Cftextarea -maxlength validation

    I have a form field that is a <cftextarea> field that I
    would like to limit end users to only be able to enter 255
    characters. I have tried the following:
    <cftextarea name="lDescription" required="no" tabindex=5
    class="boxbig"
    style="height: 160px;" validate="maxlength"
    validateAt="onBlur" maxlength="255" message="The listing you have
    entered has exceeded 255 characters! The administrator may choose
    to condense the listing before making it
    available"><cfoutput>#Trim(Detail.lDescription)#</cfoutput></cftextarea>
    But this only shows the warning when the user submits the
    form and saves the entire text to the db. Is there a way that I can
    limit the text that they type into the field so that it only allows
    the intended maximum characters or is this not possible with a
    textarea form field or a cftextarea form field? Thanks in advance
    and sorry if this is a simple problem.

    I want to be able to limit the text on the field so that the
    end user knows when they have reached the 255 character limit so
    that they do not have to count the characters on their own to see
    if they are within in the limit. I would be satisfied if when they
    exceeded the character limit that instead of proceeding to the
    action page when clicking OK on the warning message instead they
    would be taken back to the original form so that they could reduce
    the number of characters in the field. Is there a different type of
    form field that I should be using or different validation?

  • CF8.0.1 cftextarea richtext not loading - Please help!!!

    code....
    <cfform name="form01" >
       <cftextarea enabled="yes" richtext=true name="text01"
         <cfinput type="submit" value="Enter" name="submit01"/>
    </cfform>
    what i get

    1. Do you have /CFIDE as a directory or virtual directory in all of your IIS sites?
    YES, i can access the cfide/administrator on all domains.
    2. Can the browser access all required javascript files?  Check what files are references in the HTML page your code generates and verify they all exist and are accessable.
    YES, all good.
    3. Does the browser have allow javascript to be run?
    YES
    4. Is the problem consistant across browsers?
    Mostly, but safari is able to display the toolbar but gives javascript errors everywhere.
    PS. The component loads and works fine for one of the domains.

  • Multiple cftextarea tags keeping form from submitting?

    Hello~
    I am having trouble with an otherwise simple form, because it has two <cftextarea> tags. If I comment out one or the other, everything works like it should - and it doesn't matter which is used and which isn't. If both of them are used in the form, the form object is submitted as am empty structure, and the submit button isn't recognized through isDefined(), once the form is submitted. Has anyone ever run across this problem before?
    Kelly

    No, the names are different, and I have tried changing them, in case either was using any kind of reserved word.
    <cftextarea name="intDescription" validate="maxlength" maxlength="300" class="inputArea" cols="100" rows="4" required="yes" message="A content layout description is required, and must be under 300 characters." /><cftextarea name="browserCSS" class="inputArea" cols="120" rows="8" />

  • Cftextarea with script tags

    I posted this question on the FCKeditor forum and got no reply. Hoping someone here in the CFusion forum may have insight!
    We have used the FCKeditor in our CMS for years and now that CF 8 includes this as its rich text editor, we are using the version that came with CF 8 (v2.5 build 17352) instead of a separate instance.
    We are having problems when including any script tags within the text area.
    After content is saved to the dbase and the page reloads, the editor is no longer visible and the content that *should* display within the editor area displays at the top of the page.
    Also, when content is saved, all special character encoding (e.g., ™) is lost and is replaced with question marks.
    We did not have this same problem using previous versions of FCKeditor.
    Is there a setting we have incorrect? Or does FCKeditor not support script tags within the cftextarea?
    Thanks in advance for insight!
    jLynn

    Thanks for the reply Craig!
    Of note: Firebug tells me the error is an 'unterminated string literal'
    Following is what ColdFusion automatically generates in the head portion of the document when rendering the page. Looks like the error is in the intialization but I can't see what the error is.
    <script type="text/javascript">
    _cf_richtext_init_1245775594721=function()
    ColdFusion.RichText.initialize('cf_textarea1245775594720', 'body', '<script type="text/javascript"><br> alert("hello world");<br></script>
    ', '/CFIDE/scripts/ajax/FCKeditor/', null, 400, null, null, null, null, false, 'articleBody', null, null, 'en');
    };ColdFusion.Event.registerOnLoad(_cf_richtext_init_1245775594721);
    </script>
    ===================
    And this is the form generated:
    <form name="articleEdit" id="articleEdit" action="index.cfm?" method="post" onsubmit="return _CF_checkarticleEdit(this)">
    <textarea name="body"  id="cf_textarea1245775594720" cols="100" rows="5" ><script type="text/javascript">
    alert("hello world");
    </script>
    </textarea>
    </form>
    ===============

  • CF8.0.1 cftextarea richtext not loading help!!!

    It seams the browser does not parse the result of the cftextarea richtext.
    code....
    <cfform name="form01" >
       <cftextarea enabled="yes" richtext=true name="text01"
         <cfinput type="submit" value="Enter" name="submit01"/>
    </cfform>
    what i get
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <!--
    * FCKeditor - The text editor for Internet - http://www.fckeditor.net
    * Copyright (C) 2003-2007 Frederico Caldeira Knabben
    * == BEGIN LICENSE ==
    * Licensed under the terms of any of the following licenses at your
    * choice:
    *  - GNU General Public License Version 2 or later (the "GPL")
    *    http://www.gnu.org/licenses/gpl.html
    *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
    *    http://www.gnu.org/licenses/lgpl.html
    *  - Mozilla Public License Version 1.1 or later (the "MPL")
    *    http://www.mozilla.org/MPL/MPL-1.1.html
    * == END LICENSE ==
    * Main page that holds the editor.
    -->
    <html>
    <head>
    <title>FCKeditor</title>
    <meta name="robots" content="noindex

    1. Do you have /CFIDE as a directory or virtual directory in all of your IIS sites?
    YES, i can access the cfide/administrator on all domains.
    2. Can the browser access all required javascript files?  Check what files are references in the HTML page your code generates and verify they all exist and are accessable.
    YES, all good.
    3. Does the browser have allow javascript to be run?
    YES
    4. Is the problem consistant across browsers?
    Mostly, but safari is able to display the toolbar but gives javascript errors everywhere.
    PS. The component loads and works fine for one of the domains.

  • A problem with threads

    I am trying to implement some kind of a server listening for requests. The listener part of the app, is a daemon thread that listens for connections and instantiates a handling daemon thread once it gets some. However, my problem is that i must be able to kill the listening thread at the user's will (say via a sto button). I have done this via the Sun's proposed way, by testing a boolean flag in the loop, which is set to false when i wish to kill the thread. The problem with this thing is the following...
    Once the thread starts excecuting, it will test the flag, find it true and enter the loop. At some point it will LOCK on the server socket waiting for connection. Unless some client actually connects, it will keep on listening indefinatelly whithought ever bothering to check for the flag again (no matter how many times you set the damn thing to false).
    My question is this: Is there any real, non-theoretical, applied way to stop thread in java safely?
    Thank you in advance,
    Lefty

    This was one solution from the socket programming forum, have you tried this??
    public Thread MyThread extends Thread{
         boolean active = true;          
         public void run(){
              ss.setSoTimeout(90);               
              while (active){                   
                   try{                       
                        serverSocket = ss.accept();
                   catch (SocketTimeoutException ste){
                   // do nothing                   
         // interrupt thread           
         public void deactivate(){               
              active = false;
              // you gotta sleep for a time longer than the               
              // accept() timeout to make sure that timeout is finished.               
              try{
                   sleep(91);               
              }catch (InterruptedException ie){            
              interrupt();
    }

  • A problem with Threads and MMapi

    I am tring to execute a class based on Game canvas.
    The problem begin when I try to Play both a MIDI tone and to run an infinit Thread loop.
    The MIDI tone "Stammers".
    How to over come the problem?
    Thanks in advance
    Kobi
    See Code example below:
    import java.io.IOException;
    import java.io.InputStream;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Image;
    import javax.microedition.lcdui.game.GameCanvas;
    import javax.microedition.media.Manager;
    import javax.microedition.media.MediaException;
    import javax.microedition.media.Player;
    public class MainScreenCanvas extends GameCanvas implements Runnable {
         private MainMIDlet parent;
         private boolean mTrucking = false;
         Image imgBackgound = null;
         int imgBackgoundX = 0, imgBackgoundY = 0;
         Player player;
         public MainScreenCanvas(MainMIDlet parent)
              super(true);
              this.parent = parent;
              try
                   imgBackgound = Image.createImage("/images/area03_bkg0.png");
                   imgBackgoundX = this.getWidth() - imgBackgound.getWidth();
                   imgBackgoundY = this.getHeight() - imgBackgound.getHeight();
              catch(Exception e)
                   System.out.println(e.getMessage());
          * starts thread
         public void start()
              mTrucking = true;
              Thread t = new Thread(this);
              t.start();
          * stops thread
         public void stop()
              mTrucking = false;
         public void play()
              try
                   InputStream is = getClass().getResourceAsStream("/sounds/scale.mid");
                   player = Manager.createPlayer(is, "audio/midi");
                   player.setLoopCount(-1);
                   player.prefetch();
                   player.start();
              catch(Exception e)
                   System.out.println(e.getMessage());
         public void run()
              Graphics g = getGraphics();
              play();
              while (true)
                   tick();
                   input();
                   render(g);
          * responsible for object movements
         private void tick()
          * response to key input
         private void input()
              int keyStates = getKeyStates();
              if ((keyStates & LEFT_PRESSED) != 0)
                   imgBackgoundX++;
                   if (imgBackgoundX > 0)
                        imgBackgoundX = 0;
              if ((keyStates & RIGHT_PRESSED) != 0)
                   imgBackgoundX--;
                   if (imgBackgoundX < this.getWidth() - imgBackgound.getWidth())
                        imgBackgoundX = this.getWidth() - imgBackgound.getWidth();
          * Responsible for the drawing
          * @param g
         private void render(Graphics g)
              g.drawImage(imgBackgound, imgBackgoundX, imgBackgoundY, Graphics.TOP | Graphics.LEFT);
              this.flushGraphics();
    }

    You can also try to provide a greater Priority to your player thread so that it gains the CPU time when ever it needs it and don't harm the playback.
    However a loop in a Thread and that to an infinite loop is one kind of very bad programming, 'cuz the loop eats up most of your CPU time which in turn adds up more delays of the execution of other tasks (just as in your case it is the playback). By witting codes bit efficiently and planning out the architectural execution flow of the app before start writing the code helps solve these kind of issues.
    You can go through [this simple tutorial|http://oreilly.com/catalog/expjava/excerpt/index.html] about Basics of Java and Threads to know more about threads.
    Regds,
    SD
    N.B. And yes there are more articles and tutorials available but much of them targets the Java SE / EE, but if you want to read them here is [another great one straight from SUN|http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html] .
    Edited by: find_suvro@SDN on 7 Nov, 2008 12:00 PM

  • J2ME problem with threads

    Hi all,
    I would like to ask you for a help. I need to write a small program at my university. I started to write a midlet which function would be to countdown time for sports activities. I woul like to start a new thread - the one that counts down - and at the same time make the main thread sleep. After the "countdown" thread finishes, the main thread wakes up and waits for user input. The problem is that when the "countdown" thread finishes his work, I've got Uncaught exception java/lang/NullPointerException. error and the midlet halts.
    Below you can find the code
    import java.lang.*;
    import java.util.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    public class intervals extends MIDlet implements CommandListener
    public Display ekran;
    private SweepCanvas sweeper;
    private Form rundy;
    private TextField round0, round1, round2, round3, round4, round5, round6, round7, round8;
    private long czas,x;
    private Command exitCommand;
    private Command addRound;
    private Command delRound;
    private Command start;
    private TextField repeat;
    private Form odliczanie;
    private Alert ostrz;
    Licznik thread;
    String test;
    StringItem test1;
    int parz,i,j,k;
    static int l;
    int ilrund;
    int ilpowt;
    Item sec;
    long sec1;
    public intervals()
        rundy = new Form("Interwa&#322;y sportowe");
        exitCommand = new Command("Wyj&#347;cie", Command.EXIT, 2);
        addRound = new Command("Dodaj","Dodaj rund&#281;", Command.ITEM,1);
        delRound = new Command("Usu&#324;","Usu&#324; ostatni&#261; rund&#281;", Command.ITEM,1);
        start = new Command("Start", Command.ITEM,1);
        odliczanie = new Form("Odliczanie");
        TextField dodaj(TextField kolej)
            kolej=new TextField("Podaj czas (s) rundy "+parz,null, 4, TextField.NUMERIC);//stworzenie nowej instancji do wybierania czasu trwania rundy
            if(rundy.size()==0)
                rundy.insert(rundy.size(),kolej);
                else
                    rundy.insert(rundy.size()-1, kolej);
            return kolej;
        void odliczanie(TextField round)
            monitor m=new monitor();
            k=Integer.parseInt(round.getString());
            ekran.setCurrent(odliczanie);
            thread=new Licznik(k,odliczanie);
            thread.start();
            ekran.setCurrent(rundy);
    public void startApp()// throws MIDletStateChangeException
        rundy.deleteAll();
        repeat = new TextField("Podaj ilo&#347;&#263; powtórze&#324;",null,1,TextField.NUMERIC);
        rundy.addCommand(addRound);
        rundy.addCommand(exitCommand);
        rundy.setCommandListener(this);
        Canvas obrazek = new MyCanvas();
        ekran = Display.getDisplay(this);
        ekran.setCurrent(obrazek);
        czas=System.currentTimeMillis();
        while (System.currentTimeMillis()<czas+1000)
            continue;
        ekran.setCurrent(rundy);
    public void pauseApp()
    public void destroyApp(boolean unconditional)
        notifyDestroyed();
    public void commandAction(Command c, Displayable s)
        if (c == exitCommand)
            destroyApp(false);
            notifyDestroyed();
        else if(c==addRound)
            if(rundy.size()==0)//Sprawdzenie ilo&#347;ci elementów w celu poprawnego wy&#347;wietlania liczby rund w formie
                parz=1;
                else
                parz=rundy.size();
            switch(parz)
                case 1:
                    round0=dodaj(round0);break;
                case 2:
                    round1=dodaj(round1);break;
                case 3:
                   round2= dodaj(round2);break;
                case 4:
                    round3=dodaj(round3);break;
                case 5:
                    round4=dodaj(round4);break;
                default:
                    ostrz=new Alert("Uwaga","Maksymalna liczba rund wynosi 9", null, AlertType.INFO);
                    ostrz.setTimeout(3000);
                    ekran.setCurrent(ostrz);
            if(rundy.size()==1)
                rundy.append(repeat);
                rundy.addCommand(start);
            rundy.addCommand(delRound);
        else if(c==delRound)
            if(rundy.size()!=0)
                rundy.delete(rundy.size()-2);
                if (rundy.size()==1)
                    rundy.deleteAll();
                if(rundy.size()==0)
                    rundy.removeCommand(delRound);
                    rundy.removeCommand(start);
        else if(c==start)
            ilrund=rundy.size()-1;
            if(this.repeat.size()>0)
                ilpowt=Integer.parseInt(this.repeat.getString());
            ekran = Display.getDisplay(this);
            for (i=1; i<=ilpowt;i++)
                odliczanie= new Form("Odliczanie");
                 for (j=0;j<ilrund;j++)
                    switch(j)
                         case 0:
                             odliczanie(round0);
                             break;
                         case 1:
                             odliczanie(round1);
                             break;
                         case 2:
                             odliczanie(round2);
                             break;
                         case 3:
                             odliczanie(round3);
                             break;
                         case 4:
                             odliczanie(round4);
                             break;
                         case 5:
                             odliczanie(round5);
                             break;
                         case 6:
                             odliczanie(round6);
                             break;
                         case 7:
                             odliczanie(round7);
                             break;
                         case 8:
                             odliczanie(round8);
                             break;
    class Licznik extends Thread
        int czas1,k;
        Form forma;
        monitor m;
        public Licznik(int k,Form formap)
            czas1=k;
            forma=formap;
        public synchronized void run()
            while(czas1>0)
                forma.deleteAll();
                forma.append("Czas pozosta&#322;y (s): "+czas1);
                try{Thread.sleep(1000);} catch(InterruptedException e){e.printStackTrace();}
                czas1--;
            if(czas1<=0)
                m.put();
        }and monitor class
    public class monitor
    boolean busy=false;
    synchronized void get()
        if(!busy)
            try
                wait();
            }catch(InterruptedException e){e.printStackTrace();}
        notify();
    synchronized void put()
        if(busy)
            try
            wait();
            }catch(InterruptedException e){e.printStackTrace();}
        busy=true;
        notify();
    }Can anybody help me with this?

    Groovemaker,
    Your Licznik class has a member m of type monitor, which has not been instantiated (in other words is null) hence, when calling m.put() you get NullPointerException. Please also mind, that using Thread.sleep(1000) is not an accurate way of measuring time.
    If I may, please use recommended for Java class naming conventions - some of your names use lower case, while other don't which is confusing to the reader.
    Daniel

Maybe you are looking for

  • Default Header text comes in PO at the time of creation

    Hi Friends,                my problem is that a default Header text must come on the PO based on the user or purchasing group at the time Creation (In Transaction ME21N). Is there any user exits or badi for it. I have already searched for them but i

  • Can't install OS X 10.6 on 2006 MacBook

    When I attempt to update my (early 2006) MacBook with Snow Leopard the computer reports that there is insufficient RAM to run the new running system. I took my computer in to the Apple store and they said that my RAM is fine. They gave me a new hard

  • Where can I download Boot Camp 4.0 for Windows7 64 bit?

    Hi, I'm wondering where can i get a download of Boot Camp 4.0 for Windows7 64 bit? Now, I'm using the latest Mac Air (Late2011) w/ OS X Lion. Or I can just using Boot Camp 3.3 for Windows without any conflicts with Boot Camp 4 on Mac OS X Lion? Thxq

  • Macbook air July 2012 airplay with video stutters and stalls

    I have Mountain Lion installed on my base model 13" Macbook air 2012 and airplay is stuttering and stalling when playing video in VLC and mplayerx.  I've got a belkin n600db router and the 3rd gen apple TV (latest software).  Is anyone else seeing si

  • Warehouse 001 does not exist to copy from in our ERP system

    Trying to create a new warehouse in warehouse management. Went to the class SCM630, they said to copy from warehouse 001. But we don't have warehouse 001 to copy from in our ECC 6.1. Where can we go to acquire that warehouse 001 setup?