Building Mobile Enterprise Applications : webMethods Mobile Development Help : Creating Application Logic : Logic for a Dialog
Logic for a Dialog
When you add an AlertDialog object to the user interface, Mobile Development automatically adds an AlertDialogButton as a child object. When you generate sources for the Mobile Project, Mobile Development generates code to:
*Display the alert dialog with the text you specify in the AlertDialog object’s Text property.
*Close the dialog when the user selects the close AlertDialogButton object.
If you want a dialog that simply displays text with a single close button, you do not need to add any further custom code.
If you want to perform additional logic in the dialog or add additional AlertDialogButton child objects, you can customize the logic for the dialog.
When you generate sources for a Mobile Project, Mobile Development generates a Java class for the dialog where you can add your custom logic. The name of the Java class is the name you specify for the AlertDialog object’s Class Name property. Mobile Development generates the class in the src folder in the package_name.ui.dialog package. For example, if you specify “MyAlertDialog” for the Class Name property and assign the Mobile Project the package name “com.mycompany”, Mobile Development generates MyAlertDialog.java in the com.mycompany.ui.dialog package.
When a user presses a button in the dialog, the onAlertDialogButtonPressed(final AbstractAlertDialog dialog, final intbuttonID) method in the iDialogDelegate Java class is invoked. The buttonID is the value of the Id property that you specified for the AlertDialogButton object in the model. If a dialog contains multiple buttons, your logic can identify the button a user selected and take action based on the specific button the user pressed. The following shows sample logic:
public void onAlertDialogButtonPressed(AbstractAlertDialog dialog,
int buttonId) {
switch (buttonId) {
case YMNDialog.YESBUTTON:
getView().getDialogResult().setText("YES !!!");
break;
case YMNDialog.MAYBEBUTTON:
getView().getDialogResult().setText("MAYBE !!!");
break;
case YMNDialog.NOBUTTON:
getView().getDialogResult().setText("NO !!!");
break;
 
default:
break;
}
dialog.close();
}
Copyright © 2007-2017 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback