Is it possible to postpone the execution of try-catch that is triggered on button click. I am tired of trying out various ways in doing this.None successful.
Lets say i have a button.On button click field change listener,these try catch statements are executed.
ButtonField showInputButton = new ButtonField(" Search ",ButtonField.FIELD_HCENTER | ButtonField.CONSUME_CLICK);
showInputButton.setChangeListener(new FieldChangeListener()
{
public void fieldChanged(Field field,int context)
{
Dialog.alert(TextField1.getText());
//Here there are some code snippets for jumping to another form
try
{
//Some statements that filter data from database
}
catch( Exception e )
{
System.out.println( e.getMessage() );
e.printStackTrace();
}
}
}
);
add(showInputButton);
Its not that i do not want these statements to be executed at all.But i rather want them to be executed after some actions previous to that try-catch block are encountered.
Is something of this sort possible.Please guide.
I firstly want to thank all of you who have responded their suggestions.I apologize for my inability to explain my question clearly regarding what exactly i was doing within those try catch statements and what makes me do a postpone of try-catch block. Please find the attached image to my exact requirement.
REEDITED
I have added the below image after enhancing the code recommended through suggestions and also to showcase what i have tried programmatically.Please communicate if the image is not clear.