Results 1 to 4 of 4
  1. #1
    Thalvik is offline Member
    Join Date
    Apr 2011
    Posts
    2
    Rep Power
    0

    Question Method value not refreshing

    Hi to all.I am new to Java, and i've been so far developing in VB.NET.The syntax is very different, and that is a little problem to me.I am writing a program on JavaME in NetBeans and i have the method:

    Java Code:
    private void pokazi(String link){
         String url = link;
            if (zavrsna == null) {
                // write pre-init user code here
                zavrsna = new Form("form1");
                zavrsna.addCommand(getBackCommand9());
                zavrsna.setCommandListener(this);
    
                StringBuffer buffer = null;
                try{
                StreamConnection conn = (StreamConnection) Connector.open(url);
                InputStream in = conn.openInputStream();
    
    buffer = new StringBuffer();
    int ch;
    
    while ( (ch = in.read())!= -1){
    buffer.append( (char) ch);
    
    }
    }
    catch(Exception o){
    o.printStackTrace();
    }
    
    zavrsna.append(new StringItem(null, buffer.toString()));
    display=Display.getDisplay(this);
    display.setCurrent(zavrsna);
    url = null;
            }
        }
    It's just fetching some string from webpage and it's working fine.I have a list with listitems that is calling the method:

    Java Code:
    public void polazak1Action() {
            // enter pre-action user code here
            String __selectedString = getPolazak1().getString(getPolazak1().getSelectedIndex());
            if (__selectedString != null) {
                if (__selectedString.equals("Polazak M.Naselje")) {
                    if (dan1.equals("Workday")){
                        pokazi("http://www.orion.naissus.info/index.asp?id=4");
                        
                    } else if (dan1.equals("Satrday")){
                      pokazi("http://www.orion.naissus.info/index.asp?id=5");
                       
                    } else if (dan1.equals("Sunday")){
                        pokazi("http://www.orion.naissus.info/index.asp?id=6");
                        
                    }
           }
    }
    When it's called the first time, it works, but when I want to change to another item in list, nothing happens.I've tried to clean url in method by

    Java Code:
    url= null;
    or

    Java Code:
    url= "";
    but it didn't work.I also don't know how NetBeans handle breakpoints in IDE.

    In hope that you will help me, best regards Aleksandar.

  2. #2
    dlorde is offline Senior Member
    Join Date
    Jun 2008
    Posts
    339
    Rep Power
    7

    Default

    It's hard to make out because the code is so poorly formatted, but it looks like pokazi only does something if zavrsna is null, and zavrsna is only null the first time through...

  3. #3
    Thalvik is offline Member
    Join Date
    Apr 2011
    Posts
    2
    Rep Power
    0

    Default

    Wow,it works, i've missed that.Ty very much. 8)

  4. #4
    dlorde is offline Senior Member
    Join Date
    Jun 2008
    Posts
    339
    Rep Power
    7

Similar Threads

  1. JPanel not refreshing
    By pahiker in forum SWT / JFace
    Replies: 23
    Last Post: 07-14-2010, 02:59 PM
  2. Refreshing Jtable once again...
    By Norther in forum AWT / Swing
    Replies: 2
    Last Post: 06-29-2010, 07:46 PM
  3. Refreshing JList - need help
    By Unsub in forum New To Java
    Replies: 1
    Last Post: 04-13-2010, 06:31 AM
  4. JTableHeader not refreshing
    By aznboarder in forum AWT / Swing
    Replies: 4
    Last Post: 04-11-2009, 04:31 AM
  5. Bug in refreshing jsp
    By anki1234 in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 12-31-2007, 07:09 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •