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
onelson06
Posts: 37
Registered: ‎04-27-2011
My Device: Blackberry 9800
Accepted Solution

How to retrieve data from an editable field on a Popup Screen

[ Edited ]

I have a popup screen that consist of two edit fields that contain the end and start point address. It appears that I am unable to retrieve the data that is populated within those edit fields. I would like to use the address to look up the latitude and longitude in an effort to to invoke the map.

CustomPopup screen = new CustomPopup(myAddress, data.getAddress());
     _controller.getUiApplication().pushModalScreen(screen);
String newEndPoint = screen.getEndPoint();
String newStartingPoint = screen.getStartingPoint();


 

 public CustomPopup(String sPoint, String ePoint) 
    {   
       super(new VerticalFieldManager());
       
       XYEdges thickPadding = new XYEdges(1,1,1,1);
       
       LabelField endDirection = new LabelField("End Point:");
         add(endDirection);
         
       EditField endPoint = new EditField("",ePoint.toString());
       Border eBorder = BorderFactory.createRoundedBorder(thickPadding, Border.STYLE_SOLID);
       endPoint.setBorder(eBorder);
       add(endPoint);
       add(new EditField(Field.NON_FOCUSABLE));
       
       LabelField startDirection = new LabelField("Start Point:");
         add(startDirection);
          
       EditField startingPoint = new EditField("",sPoint.toString());
       Border sBorder = BorderFactory.createRoundedBorder(thickPadding, Border.STYLE_SOLID);
       startingPoint.setBorder(sBorder);
       add(startingPoint);
       add(new EditField(Field.NON_FOCUSABLE));
           
       okButton = new ButtonField("OK", ButtonField.CONSUME_CLICK | Field.FIELD_HCENTER);
         okButton.setChangeListener(this);
         add(okButton);
       
    } 
     public String getEndPoint() 
     {  
          if (endPoint == null) {
              Dialog.alert("You must enter an Address!");
        }
        else
        {
              return endPoint.getText();                   
        }
           return null;
     }

      public String getStartingPoint() 
       {      
           if (startingPoint != null) {
               return startingPoint.getText();
                        
          }
           return null;
       }
       
       public void fieldChanged(Field field, int context) {
           if (field == okButton) {
               close();
          }
       }
       

 

Please use plain text.
Contributor
Roshni
Posts: 45
Registered: ‎12-20-2010
My Device: Not Specified

Re: How to retrieve data from an editable field on a Popup Screen

Hi,

 

Add the statement as startingPoint.setText(startingPoint.getText()) and endPoint.setText(endPoint.getText()) after creating instance of startingPoint and endPoint.  I think this will solve your problem.

 

-Roshni

 

Press Kudos button if solved.

Please use plain text.
Contributor
onelson06
Posts: 37
Registered: ‎04-27-2011
My Device: Blackberry 9800

Re: How to retrieve data from an editable field on a Popup Screen

Roshni, so that I am understanding you right you are saying to add the statement after i.e. EditField endPoint = new EditField("",ePoint.toString());
Please use plain text.
Contributor
Roshni
Posts: 45
Registered: ‎12-20-2010
My Device: Not Specified

Re: How to retrieve data from an editable field on a Popup Screen

Yes u r understanding it right. to add the statement after EditField endPoint = new EditField("",ePointtoString());

Please use plain text.