Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 37
Registered: ‎04-27-2011
My Device: Blackberry 9800
My Carrier: AT&T
Accepted Solution

Populate TextField in a Dialog Box

I am trying to create a dialog box that will allow me to either change address of my location or just confirm the address that appears within the dialog box by clicking ok.

Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Populate TextField in a Dialog Box

Welcome to the forums!

 

What part of this task gives you trouble? Have you looked at PopupScreen and TextField (or, say, EditField) documentation?

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Contributor
Posts: 37
Registered: ‎04-27-2011
My Device: Blackberry 9800
My Carrier: AT&T

Re: Populate TextField in a Dialog Box

Arkadyz, my reason for asking the question above is because I have an app that is pushing location-based data to a map. I would like for the users to be able to change the address of the location if needed via a dialog box before proceeding(please advise if a popup screen would be better). I have tried creating a CustomDialog that extends the Dialog but I am not sure how to call it from the class where the button is located and analyzed.
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Populate TextField in a Dialog Box

Then take a look at the Dialog class documentation - especially add and doModal methods. You add a variation of a TextField, of course. Create a public method in your CustomDialog which extracts the text from that TextField and returns it to the caller and call it after the dialog is dismissed (doModal returns).

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Contributor
Posts: 37
Registered: ‎04-27-2011
My Device: Blackberry 9800
My Carrier: AT&T

Re: Populate TextField in a Dialog Box

arkadyz, do you know where I can find an example of what you mention to do
Highlighted
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Populate TextField in a Dialog Box

This is a very basic task so I don't think you will have many code examples in the knowledge book or anywhere in this forum. Try BlackBerry Manuals and Guides for Developers - especially UI Guidelines for BlackBerry Smartphones and BlackBerry Java development guides for starters.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Contributor
Posts: 37
Registered: ‎04-27-2011
My Device: Blackberry 9800
My Carrier: AT&T

Re: Populate TextField in a Dialog Box

Is this similar to what you were saying:

public final class TestDialog extends Dialog
xxx123;
private EditField userNameField;
private EditField passwordField;

public TestDialogxxx40;String choicesxxx91;xxx93;, int valuesxxx91;xxx93;xxx41;
xxx123;
superxxx40;"Login Information", choices, values, Dialog.OK, Bitmap.getPredefinedBitmapxxx40;Bitmap.INFORMATIONxxx41;, Dialog.GLOBAL_STATUSxxx41;;

userNameField = new EditFieldxxx40;"User Namexxx58; ", "", 50, EditField.EDITABLExxx41;;
passwordField = new EditFieldxxx40;"Passwordxxx58; ", "", 50, EditField.EDITABLExxx41;;

Manager delegate = getDelegatexxx40;xxx41;;
ifxxx40; delegate instanceof DialogFieldManager xxx41;
xxx123;
DialogFieldManager dfm = xxx40;DialogFieldManagerxxx41;delegate;
Manager manager = dfm.getCustomManagerxxx40;xxx41;;
ifxxx40; manager != null xxx41;
xxx123;
manager.insertxxx40;userNameField, 0xxx41;;
manager.insertxxx40;passwordField, 1xxx41;;
xxx125;
xxx125;

xxx125;
xxx125;
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Populate TextField in a Dialog Box

Your post is very strangely formatted, but I can guess the approach. I'd say you are doing it the hard way, but the overall idea is correct. I suggest you add two public methods which extract username and password:

public String getUserName() {
  if (userName != null) {
    return userName.getText();
  }
  return null;
}

public String getPassword() {
  if (password != null) {
    return password.getText();
  }
  return null;
}

 Call these methods once the dialog closes. Check whether the user pressed 'OK' or 'Cancel' before doing so.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Contributor
Posts: 37
Registered: ‎04-27-2011
My Device: Blackberry 9800
My Carrier: AT&T

Re: Populate TextField in a Dialog Box

[ Edited ]
 
Contributor
Posts: 37
Registered: ‎04-27-2011
My Device: Blackberry 9800
My Carrier: AT&T

Re: Populate TextField in a Dialog Box

Arkadyz, I created the methods you stated and I am trying to display the screen with the following:

screen = new CustomPopup();
UiApplication.getApplication().pushModalScreen(screen);
String newEndPoint = screen.getEndPoint();

but I get an error saying cannot find symbol method pushModalScreen. Do you have any clue as to why this is happening.