×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    78

    Smile Displaying selected choice to a new form

    hi,
    i have a form with a choice group,consisting of 3 options....i need to display ,one of the selected option of that choice group to a textField of another form.....

    can anyone please help me.

    With Regards
    Deva

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Displaying selected choice to a new form

    Quote Originally Posted by devalin85 View Post
    hi,
    i have a form with a choice group,consisting of 3 options....i need to display ,one of the selected option of that choice group to a textField of another form.....

    can anyone please help me.

    With Regards
    Deva
    You can get the string of the selected index of the choiceGroup and save in the string varialbe, eventually you can pass the same to the textfield on the other form or where ever you need.

    just get the string of the selected index.

    For more information read the choicegroup docs in the WTK.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    78

    Re: Displaying selected choice to a new form

    hi,
    Have done in the same way as u did....have created a string globally say String cglist .
    Code:
    cglist = cgListOffen.getString(cgListOffen.getSelectedIndex());
    System.out.println("Cg List is :" +cglist );
    till this it works fine.....am able to get the selected index from the choice field as it gets printed because of the System.out.println statement.....
    but the problem is when i want that selected field to be displayed in the textField i get a exception.
    Code :
    txtCurrentOffer.setString(cgPenalty);
    where it is in this TextField "txtCurrentOffer"i needed my selected choice group to be printed....have given in this way...can u please say me where i went wrong.

    With Regards
    Deva

  4. #4
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Displaying selected choice to a new form

    Quote Originally Posted by devalin85 View Post
    hi,

    Code:
    cglist = cgListOffen.getString(cgListOffen.getSelectedIndex());
    System.out.println("Cg List is :" +cglist );

    Code :
    txtCurrentOffer.setString(cgPenalty);
    Hello,
    Please check the two bold word. These are the two different variables, I guess inside the line
    txtCurrentOffer.setString(cgPenalty);
    you should pass the cglist rather than cgPenalty is'n it?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  5. #5
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    78

    Re: Displaying selected choice to a new form

    am sorry have nly given like this
    txtCurrentOffer.setString(cglist );

    but still i get a exception....i dont know where i went wrong

  6. #6
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Displaying selected choice to a new form

    Quote Originally Posted by devalin85 View Post
    am sorry have nly given like this
    txtCurrentOffer.setString(cglist );

    but still i get a exception....i dont know where i went wrong
    What is the exception you are getting?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  7. #7
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    78

    Re: Displaying selected choice to a new form

    hi,
    this is the exception am getting
    java.lang.IndexOutOfBoundsException

  8. #8
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Displaying selected choice to a new form

    Quote Originally Posted by devalin85 View Post
    hi,
    this is the exception am getting
    java.lang.IndexOutOfBoundsException
    When you are setting this
    txtCurrentOffer.setString(cglist );
    are you sure that cglist contains some name/string?

    Are you sure that the exception is only on the quoted line?
    Please put the code inside the try-catch block and find at which line exception is generated?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  9. #9
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    78

    Re: Displaying selected choice to a new form

    i have 3 forms...where in that
    (i) it is in the first form i have the choice group with a command button Next
    (ii) when Next is clicked it goes to the 2nd form and in that i have a command button Next
    (iii)when the 2nd forms Next command button is clicked it goes to the 3rd form..where it is in that 3rd form i have a textField and it is in that textfield i need to print the selected choice group value....
    txtCurrentOffer.setString(cglist );
    am using the above line in the command action of the 2nd form Next command button

  10. #10
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Displaying selected choice to a new form

    Quote Originally Posted by devalin85 View Post
    txtCurrentOffer.setString(cglist );
    am using the above line in the command action of the 2nd form Next command button
    Yeah you are doing the correct thing.
    Are you sure that the exception which is thrown is indexoutofbounds,
    Please read these lines carefully,
    public void setString(String text)

    Sets the contents of the TextField as a string value, replacing the previous contents.

    Parameters:
    text - the new value of the TextField, or null if the TextField is to be made empty
    Throws:
    IllegalArgumentException - if text is illegal for the current input constraints
    IllegalArgumentException - if the text would exceed the current maximum capacity
    Try to debug the code and try to find the exact exception, line inside the code. You can do this.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  11. #11
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    78

    Re: Displaying selected choice to a new form

    hi raj,
    Thanks a lot for all your replies...thanks for being very supportive and replying for all the things which i asked....got the one which i needed....!

    With Regards
    Deva

Similar Threads

  1. s40 inline choice and button form widgets
    By facildelembrar in forum Mobile Java General
    Replies: 1
    Last Post: 2010-05-17, 07:48
  2. Getting a Form selected item
    By giaviv in forum Mobile Java General
    Replies: 1
    Last Post: 2010-02-13, 22:57
  3. Choice Group Get selected value
    By kev_Makaveli in forum Mobile Java General
    Replies: 6
    Last Post: 2010-01-04, 11:08
  4. Find which item is selected on Form
    By prajapati.ajay in forum Mobile Java General
    Replies: 2
    Last Post: 2009-03-25, 15:38
  5. How to get selected index of Item in a Form ?
    By akokchai in forum Mobile Java General
    Replies: 1
    Last Post: 2004-02-23, 01:40

Posting Permissions

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