×

Discussion Board

Results 1 to 14 of 14

Thread: Reusing Form

  1. #1
    Super Contributor
    Join Date
    Jan 2008
    Location
    Amravati, India
    Posts
    546

    Reusing Form

    I often have to display message to user or ask something (Yes / No). So I use a Form with OK and Cancel Commands. I just do following:
    Code:
    FormObject.deleteAll();
    FormObject.append(Message);
    I am facing this problem on Nokia E61i:
    Step 1: I display a long message which cannot fit in the phone screen.
    Step 2: For reading this message, user scrolls to the bottom of the screen and press OK.
    Step 3: Now I display second small message which can fit in the screen. The message is wraped into 3 lines. But only last 2 (or sometimes last 1) lines are displayed on the screen and only when user press UP arrow button then entire message is displayed. But nobody will tell the user to press UP arrow button and user will read a part of the message and press OK.
    Whats the solution?

    Thanks in advance

  2. #2
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: Reusing Form

    Quote Originally Posted by arpit2agrawal View Post
    I often have to display message to user or ask something (Yes / No). So I use a Form with OK and Cancel Commands. I just do following:
    Code:
    FormObject.deleteAll();
    FormObject.append(Message);
    I am facing this problem on Nokia E61i:
    Step 1: I display a long message which cannot fit in the phone screen.
    Step 2: For reading this message, user scrolls to the bottom of the screen and press OK.
    Step 3: Now I display second small message which can fit in the screen. The message is wraped into 3 lines. But only last 2 (or sometimes last 1) lines are displayed on the screen and only when user press UP arrow button then entire message is displayed. But nobody will tell the user to press UP arrow button and user will read a part of the message and press OK.
    Whats the solution?

    Thanks in advance
    hi arpit,
    the problem seems quite surprising. Is the same problem is occurs with other devices too or E61 is the special case.
    thanks,
    jitu_goldie..

    KEEP TRYING..

  3. #3
    Super Contributor
    Join Date
    Jan 2008
    Location
    Amravati, India
    Posts
    546

    Re: Reusing Form

    No problem with Nokia 3110 classic.
    I think Series 40 have no problem with this. But S60 does.
    I am looking for a good solution... I cannot afford to destroy and create a new Form every time I want to display a message to user or ask something... and I don't want to use Alert also because of its looks.

  4. #4
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: Reusing Form

    Quote Originally Posted by arpit2agrawal View Post
    No problem with Nokia 3110 classic.
    I think Series 40 have no problem with this. But S60 does.
    I am looking for a good solution... I cannot afford to destroy and create a new Form every time I want to display a message to user or ask something... and I don't want to use Alert also because of its looks.
    Ohh so this problem arises only then when u reuses the form not with the fresh form..
    but in most of the high level applications im doing same and no problem arises ever neither with s40 nor with s60. r u tried it with n95,n70 or some 6220c or some other s60 phone ?
    still unbeleivable..
    I had also tried with 95 by append around 50 strings on a form and delete and reappend them on some command action but it will run perfectly ie no need to scroll up for to see the complete msg.
    If im wrong or misunderstand u then please make me correct.
    thanks,
    jitu_goldie..

    KEEP TRYING..

  5. #5
    Super Contributor
    Join Date
    Jan 2008
    Location
    Amravati, India
    Posts
    546

    Re: Reusing Form

    Quote Originally Posted by jitu_goldie View Post
    Ohh so this problem arises only then when u reuses the form not with the fresh form..
    I hoped that you read the title of the post at least... :P

    Quote Originally Posted by jitu_goldie View Post
    I had also tried with 95 by append around 50 strings on a form and delete and reappend them on some command action but it will run perfectly ie no need to scroll up for to see the complete msg.
    Did it scroll to top automatically after deleting and re-appending?
    In my case, user has to scroll to top manually and after deleting and re-appending...

  6. #6
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Reusing Form

    What is the problem of creating a new Form? I'd always recommend creating a new object rather than trying to re-use one. Quite a lot of things don't behave well if you empty them and re-use them (except things like StringBuffer or Vector that are built for this).

    I know of no solution. Things you could try:

    1. Rather than using deleteAll(), try deleting the Items one by one. Try deleting them from begining to end, and from end to begining.

    Code:
    while (form.size() > 0) {
        form.delete(0);
    }
    Code:
    for (int i = form.size() - 1; i >= 0; i--) {
        form.delete(i);
    }
    These might behave differently.

    2. Try calling setCurrent(form) after emptying and before appending new items. (This might have odd side-effects if the application is in the background.)

    3. Try emptying the Form in an event (like CommandAction), and filling it in a run() method called with callSerially(). Or do both in separate run() cycles triggered separately with two calls to callSerially().

    I'm thinking about how to cause the Form to repaint itself while it's empty, so that it has to lay itself out again.

    Cheers,
    Graham.

  7. #7
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: Reusing Form

    Quote Originally Posted by arpit2agrawal View Post
    I hoped that you read the title of the post at least... :P


    Did it scroll to top automatically after deleting and re-appending?
    In my case, user has to scroll to top manually and after deleting and re-appending...
    No the cursor goes to top automatically. There is no need to scroll to user.
    Here is the test code which i used for testing on n95..

    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;

    /**
    * @author jitendra
    */
    public class dummyMidlet extends MIDlet implements CommandListener
    {
    Display dis = Display.getDisplay(this);
    Form form = new Form("");
    Command ok = new Command("ok", Command.OK,1);


    public void startApp()
    {
    form.addCommand(ok);
    form.setCommandListener(this);
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");

    dis.setCurrent(form);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command command, Displayable arg1)
    {
    if (command == ok)
    {
    form.deleteAll();
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    form.append("mmmmmmmmmmdjdshfshfdsjfdhshfd");
    }
    }

    }

    check the same.
    thanks,
    jitu_goldie..

    KEEP TRYING..

  8. #8
    Super Contributor
    Join Date
    Jan 2008
    Location
    Amravati, India
    Posts
    546

    Re: Reusing Form

    Quote Originally Posted by grahamhughes View Post
    What is the problem of creating a new Form? I'd always recommend creating a new object rather than trying to re-use one.
    I have to display message to user every now and then in commandAction function. If I create a new Form every time, it takes time. So I cannot do that in commandAction. So every time I have to schedule the work of creating Form object in another thread. I don't ever create thread on demand. Instead I create one worker thread at the start of the application which I reuse every time I want to execute something in background. But its really cumbersome to tell worker thread to create Form object and do asynchronous callback when it is created. Also display some processing symbol on the screen. That's why I want to reuse Form object.

    Quote Originally Posted by grahamhughes View Post
    Rather than using deleteAll(), try deleting the Items one by one. Try deleting them from begining to end, and from end to begining.
    Form consists of only one "String" object

    Quote Originally Posted by grahamhughes View Post
    Try calling setCurrent(form) after emptying and before appending new items. (This might have odd side-effects if the application is in the background.)
    "String" class is not derived from "Item" class.

    Quote Originally Posted by grahamhughes View Post
    Try emptying the Form in an event (like CommandAction), and filling it in a run() method called with callSerially(). Or do both in separate run() cycles triggered separately with two calls to callSerially().
    I doubt that would solve the problem

    Quote Originally Posted by grahamhughes View Post
    I'm thinking about how to cause the Form to repaint itself while it's empty, so that it has to lay itself out again.
    That also might not solve the problem. Because ideally speaking, if 7 lines can be displayed on the screen and if only 3 lines are there to display then scrolling should be disabled. But Form doesn't disable scrolling. So, same might be the case with 0 lines... only God knows... that might also solve the problem...

    Anyways, I will try using Alert with timeout FOREVER

  9. #9
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: Reusing Form

    Still u was not told to me that is the problem arises only with E61 or with all s60 devices..

    can u post ur code here..
    thanks,
    jitu_goldie..

    KEEP TRYING..

  10. #10
    Super Contributor
    Join Date
    Jan 2008
    Location
    Amravati, India
    Posts
    546

    Re: Reusing Form

    Quote Originally Posted by jitu_goldie View Post
    Still u was not told to me that is the problem arises only with E61 or with all s60 devices..
    I didn't try with any other S60 phone than E61i.

    Quote Originally Posted by jitu_goldie View Post
    can u post ur code here..
    The code is very much similar to the one posted by you.

  11. #11
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: Reusing Form

    Quote Originally Posted by arpit2agrawal View Post
    I didn't try with any other S60 phone than E61i.


    The code is very much similar to the one posted by you.
    may be the issue is of device. Well the code given by me is perfectly run on n95
    cant say about E61
    thanks,
    jitu_goldie..

    KEEP TRYING..

  12. #12
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Reusing Form

    Quote Originally Posted by arpit2agrawal View Post
    "String" class is not derived from "Item" class.
    Everything in the Form derives from Item. When you append a String to a Form, the Form creates a StringItem object to contain the String, like this:

    PHP Code:
    package javax.microedition.lcdui;

    public class 
    Form extends Screen {

        
    // ...

        
    public void append(String s) {
            
    this.append(new StringItem(nulls));
        }

        
    // ...

    Quote Originally Posted by arpit2agrawal View Post
    I doubt that would solve the problem
    You might be surprised.

    Cheers,
    Graham.

  13. #13
    Super Contributor
    Join Date
    Jan 2008
    Location
    Amravati, India
    Posts
    546

    Re: Reusing Form

    Quote Originally Posted by grahamhughes View Post
    Everything in the Form derives from Item. When you append a String to a Form, the Form creates a StringItem object to contain the String
    Thanks for the information.
    I think I got cause of the problem.

    Step 1: Append a long String to Form (which would actually result in appending StringItem to the Form)
    Step 2: The Form is repainted
    Step 3: User scrolls to the bottom of the Form for reading the long String
    Step 4: Form.deleteAll()
    Step 5: Append another short String to the Form (which would actually result in appending StringItem to the Form)
    Step 6: The Form is repainted

    In case of Step 2 and Step 6, Form contains exactly one Item which is StringItem. So Nokia E61i doesn't bother to layout the Form again. But if there had been repaint between Step 4 and Step 5, then Form might have layout again which would solve the problem... as suggested by Graham in the post #6

  14. #14
    Registered User
    Join Date
    May 2010
    Posts
    17

    Re: Reusing Form

    Dear arpit2agrawal,

    so ur solution is delete all the Item in the Form one by one?

    i have the same problem on nokia 2700 (s40).
    I reuse Form. Every time i want to reuse it, i have to deleteAll() Items.
    it's fine if i scroll to the last Item, but it "Error Null" when cursor not in the last Item.

    it try this code on other nokia (c5, n71, e71), it works fine.

    thank u.

Similar Threads

  1. Replies: 10
    Last Post: 2009-03-09, 09:09
  2. second form not getting key events
    By krsunil in forum Symbian User Interface
    Replies: 3
    Last Post: 2008-12-10, 10:29
  3. Form troubles
    By matdodgson in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-12-06, 10:49
  4. Weird Form behaviour on N73
    By Damo2k in forum Mobile Java Tools & SDKs
    Replies: 2
    Last Post: 2008-02-21, 15:43
  5. problems in creating multipage form
    By A.Vogel in forum Symbian User Interface
    Replies: 0
    Last Post: 2007-10-02, 08:16

Posting Permissions

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