Class PValidatingWizard

All Implemented Interfaces:
PValidatingWizardContext, WizardValidationManager, SharedDataManager, PAppContext, ImageObserver, MenuContainer, PropertyChangeListener, VetoableChangeListener, Serializable, EventListener, Accessible
Direct Known Subclasses:
PAccountCreationWizard, PPurchaseOfferingWizard

A framework for use in creating Customer Center validating wizards.

When a page switch occurs, validateWizardPage is called on each page (each wizard page must extend PWizardPage) to give it the opportunity to validate its data. (If a page wants to it can call convenience methods on the WizardValidationManager to have the wizard framework do default validation and related error handling. If the page wishes it can have the framework do Portal validation on its data but elect to do error handling itself. The abstract method validateData in this class will need to be overridden to provide any such Portal validation.)

If validation is successful, leavingPage is called on the page about to be left. The leavingPage method is a convenient place for the page being left to share out any data which might be of use to other pages. (To facilitate sharing of data among wizard pages, subclasses of this base class may wish to make use of SharedData.)

When the "Finish" button is pressed, the wizard collects data from all wizard pages and commits new data to the database by calling the commitData method. This abstract method should be overridden in a derived class to carry out the appropriate storing of data. If the account is successfully created, finished is called. This method may be overridden in a derived class to carry out additional processing. If a commit-time error occurs, handleWizardCommitError is called on each page until one is encoutered which claims ownership of the error. (Again, the page claiming the error can call commit-time convenience methods on WizardValidationManager to have the wizard framework do default error handling.)

If the "Cancel" button is pressed and the user confirms the request, cancelled is called. This method may be overridden in a derived class to carry out additional processing.

During recycling (after the wizard is cancelled or after successfuly creating the account) data sharing is disabled, recycle is called on each wizard page so that it may reinitialize itself, and then any data that may have been placed in the shared data area is discarded.

See Also:
  • Constructor Details

    • PValidatingWizard

      public PValidatingWizard(JFrame owner, String wizardName, String wizardType, boolean useNavigator)
      Builds a wizard based upon wizard name and wizard type tags. The name tag identifies the constituting page classes and the type identifies the shared data class used for data communication among the wizard pages and for locating resource strings for wizard messages.
      Parameters:
      wizardName - The properties tag identifying the wizard to be created.
      wizardType - The properties tag identifying the type of the the wizard. Used to specify the shared data class and to locate resource strings for wizard messages.
      useNavigator - true for the wizard to include a navigator allowing for random page selection. false to omit the navigator.
      frame - The frame to be used to host the wizard
  • Method Details

    • loadPages

      protected void loadPages(String wizardPages)
      Adds pages to the wizard based upon the passed-in tag. The format of the entries associated with the tag in the properties file should be as follows:
         <wizardPages>.pages=<pageName1> <pageName2> ...
         <pageName1>.class=<class name (including package)>
         <pageName2>.class=<class name (including package)>
         ... 
      The format of the related entries in the resource bundle should be as follows:
         <pageName1>.label=<label for page page>
         <pageName2>.label=<label for page page>
         ... 

      The individual pages to be added to the wizard need to be implementations of PWizardPage.

      Parameters:
      wizardPages - The tag identifying the pages to be added
    • addNotify

      public void addNotify()
      Overrides:
      addNotify in class PWizard
    • setVisible

      public void setVisible(boolean b)
      Shows or hides the wizard dialog.
      Overrides:
      setVisible in class PWizard
      Parameters:
      b - If true, shows the dialog; otherwise, hides it.
    • propertyChange

      public void propertyChange(PropertyChangeEvent e)
      Page switch, cancel, and finish processing.
      Specified by:
      propertyChange in interface PropertyChangeListener
      Parameters:
      e - The property change event.
    • finished

      protected void finished(PModelHandle model)
      Reports that the wizard finished successfully (the commit attempt was successful). The following processing is carried out:
      • A message box informing of the successful commit is displayed.
      • The wizard is hidden.
      Parameters:
      model - The model handle returned from a successful commit attempt.
    • recycle

      protected void recycle()
      Performs any needed cleanup before this wizard is reused.
    • cancelled

      protected boolean cancelled()
      Displays a cancel wizard confirmation box and if the response is Yes, hides the wizard.
      Returns:
      true if cancellation was approved; otherwise false.
    • validateData

      protected abstract Object validateData(PModelHandle model) throws RemoteException
      Validates the data in the passed-in model handle
      Parameters:
      model - The model handle for the data to be validated
      Returns:
      null if the validation succeeds, otherwise a CustomerError.
      Throws:
      RemoteException
    • commitData

      protected abstract Object commitData(PModelHandle model) throws RemoteException
      Commits the data in the passed-in model handle
      Parameters:
      model - The model for the data to be committed
      Returns:
      A model handle if the commit succeeds, otherwise a CustomerError
      Throws:
      RemoteException
    • vetoableChange

      public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException
      Does page validation when a page switch is about to occur in the wizard. If validation fails, a PropertyVetoException is thrown. If it succeeds, leavingPage is called on the page being left. (In leavingPage, a wizard page could elect to share data out that other pages might want to make use of.)
      Specified by:
      vetoableChange in interface VetoableChangeListener
      Parameters:
      e - The property change event
      Throws:
      PropertyVetoException
    • validateModel

      public Object validateModel(PModelHandle model) throws RemoteException
      Validates the model handle passed in.
      Specified by:
      validateModel in interface WizardValidationManager
      Parameters:
      model - Model handle to be validated.
      Returns:
      CustomerError if the validation fails, otherwise null.
      Throws:
      RemoteException
      See Also:
    • validatePage

      public void validatePage() throws PValidationException
      Collects data from the currently visible page (by calling collectData on the page) and validates it using default validation. If an error is encountered, then if it contains enough information to auto-locate the field associated with the error, the field is marked. If there is error text associated with the error, it is displayed in a message box. If there is no error text associated with the error, a generic validation error message is displayed. If the user elects to fix the error then this method throws a PValidationException.
      Specified by:
      validatePage in interface WizardValidationManager
      Throws:
      PValidationException
      See Also:
      • invalid reference
        PWizardPage.validateWizardPage
    • handleValidateError

      public int handleValidateError(com.portal.app.util.CustomerError customerError, Component comp, boolean alertOnlyIfMatch)
      Handles a validate-time error on the current page and returns information about the user's response. If the error passed in has sufficient information to auto-locate the field associated with the error, the field is marked. If there is error text associated with the error passed in, it is displayed in a message box. If there isn't any error information passed in, a generic validation error message is displayed.
      If the alertOnlyIfMatch flag is set, then only if a field matching the error is found will an error message be displayed.
      This method calls displayYesNoValidateError to display the error message.
      Specified by:
      handleValidateError in interface WizardValidationManager
      Parameters:
      customerError - A customer error object describing the error.
      comp - The Component in which to start the search for the error.
      alertOnlyIfMatch - See return description.
      Returns:
      VALIDATION_IGNOREERROR if the user chooses to ignore the validation error or VALIDATION_FIXERROR if the user chooses to fix the error. If the alertOnlyIfMatch flag is set, then if no matching error field is found VALIDATION_NOMATCH is returned.
      See Also:
    • displayYesNoValidateError

      public int displayYesNoValidateError(String str)
      Puts up a Yes/No validate-time error message and returns a JOptionPane value corresponding to the way the dialog was dismissed.
      Specified by:
      displayYesNoValidateError in interface WizardValidationManager
      Parameters:
      str - Error message to display. If null, then a default error message is used.
      Returns:
      JOptionPane.YES_OPTION, JOptionPane.NO_OPTION, or JOptionPane.CLOSED_OPTION depending on the user action.
    • displayMessage

      public void displayMessage(String str, String title, int messageType, String property)
      Puts up a simple message with a dismiss button unless the message has been flagged as wanting to be ingnored. (The dialog can be made to contain a "Don't remind me again" checkbox. property is used to track whether the user wishes to see the message box again.)
      Specified by:
      displayMessage in interface WizardValidationManager
      Parameters:
      str - The message to display. If the string is null, a default validation failure message is displayed.
      title - The title to be displayed. If the string is null, a default validation failure title is displayed.
      messageType - A JOptionPane message type.
      property - If null the message is displayed in a normal message dialog. If non-null the message is displayed in a PDisplayOnRequestOptionMsgDlg.
      See Also:
    • handleCommitError

      public boolean handleCommitError(com.portal.app.util.CustomerError customerError, Component comp)
      Alerts the user if the passed in component is capable of handling the passed-in commit-time error. If the error passed in has sufficient information to auto-locate the field associated with the error, the field is marked and if there is error text associated with the error, it is displayed in a message box or if there is no error text then a generic message is displayed.
      This method calls displayCommitError to display the error message.
      Specified by:
      handleCommitError in interface WizardValidationManager
      Parameters:
      customerError - A customer error object describing the error.
      comp - The Component in which to start the search for the error. If the auto-locate search attempt is successful, the (top-level) wizard page containing comp is switched to before the error message is displayed.
      Returns:
      true if a message has been displayed indicating that the page is capable of handling the error; otherwise false.
      See Also:
      • invalid reference
        PWizardPage.handleWizardCommitError
    • displayCommitError

      public void displayCommitError(String str, Component comp)
      Puts up a commit-time error message.
      Specified by:
      displayCommitError in interface WizardValidationManager
      Parameters:
      str - The error string to be displayed. If the string is null, a default commit failure message is displayed.
      comp - The (top-level) wizard page containing comp will be switched to before the error is displayed. If null, no page switch will occur.
    • displayYesNoMessage

      public int displayYesNoMessage(String str, String title, int messageType, String property)
      Puts up a Yes/No message and returns a value corresponding to the way the message is dismissed unless the message has been flagged as wanting to be ingnored. (The dialog can be made to contain a "Don't remind me again" checkbox. property is used to track whether the user wishes to see the message box again.)
      Specified by:
      displayYesNoMessage in interface WizardValidationManager
      Parameters:
      str - Message to display.
      title - Message box title.
      messageType - A JOptionPane message type.
      property - If null the message is displayed in a normal message dialog. If non-null the message is displayed in a PDisplayOnRequestOptionMsgDlg.
      Returns:
      If property is null, JOptionPane.YES_OPTION, JOptionPane.NO_OPTION, or JOptionPane.CLOSED_OPTION is returned depending on the user action. If property is non-null, PDisplayOnRequestOptionMsgDlg.HIDE_DIALOG is an additional possible return value.
      See Also:
    • firstChanceHandleCommitError

      protected boolean firstChanceHandleCommitError(com.portal.app.util.CustomerError customerError)
      Called before page-wise commit-time error handling is attempted. If this method returns true the error is considered to have claimed and no further error processing will be done. This base implementation simply returns false.
      Parameters:
      customerError - A customer error object describing the error.
      Returns:
      true to signal that the error has been handled; false if the error has not been handled.
    • lastChanceHandleCommitError

      protected void lastChanceHandleCommitError(com.portal.app.util.CustomerError customerError)
      Called if page-wise commit-time error handling has completed with no page claiming the error. This base implementation visits each wizard page successively, trying to find a field that best matches the error. If a matching field is found, it is marked, the page containing it is switched to, and an error message is displayed. If a match isn't found a generic error is displayed.
      Parameters:
      customerError - A customer error object describing the error.
    • setOverlay

      public void setOverlay(Component comp)
      No op
      Specified by:
      setOverlay in interface PAppContext
      Parameters:
      comp - the component to add to the application
    • changeSize

      public void changeSize(Component comp, int spaceNeeded)
      No op
      Specified by:
      changeSize in interface PAppContext
      Parameters:
      comp - the component to change
      spaceNeeded - a constant that describes how to change the component's size
    • setStatus

      public void setStatus(String status)
      No op
      Specified by:
      setStatus in interface PAppContext
      Parameters:
      status - the new status text
    • addActions

      public void addActions(Vector tools)
      No op
      Specified by:
      addActions in interface PAppContext
      Parameters:
      tools - a Vector of PBASAction objects
    • removeActions

      public void removeActions(Vector tools)
      No op
      Specified by:
      removeActions in interface PAppContext
      Parameters:
      tools - a Vector of PBASAction objects
    • focusOn

      public void focusOn(Component comp)
      No op
      Specified by:
      focusOn in interface PAppContext
      Parameters:
      comp - the component that gets focus
    • addContextChangedListener

      public void addContextChangedListener(PContextChangedListener l)
      No op
      Specified by:
      addContextChangedListener in interface PAppContext
      Parameters:
      l - a PContextChangedListener
    • removeContextChangedListener

      public void removeContextChangedListener(PContextChangedListener l)
      No op
      Specified by:
      removeContextChangedListener in interface PAppContext
      Parameters:
      l - a PContextChangedListener
    • fireContextChangedEvent

      public boolean fireContextChangedEvent(PContextChangedEvent event)
      No op, always returns true
      Specified by:
      fireContextChangedEvent in interface PAppContext
      Parameters:
      event - a PContextChangedEvent event
      Returns:
      False for an okToExit event, true otherwise.
    • getAppName

      public String getAppName()
      Returns "ValidatingWizard"
      Specified by:
      getAppName in interface PAppContext
      Returns:
      A String that contains the application's name.
    • setEnabled

      public void setEnabled(PWizardPage page, boolean b)
      Enables or disables the specified top-level wizard page. Does nothing if page is the currently-visible page or if page is not a top-level wizard page.
      Specified by:
      setEnabled in interface PValidatingWizardContext
      Parameters:
      page - Top-level wizard page to be enabled or disabled.
      b - true to attempt to enable; false to attempt to disable.
    • getWizardName

      public String getWizardName()
      Returns the name of the wizard.
      Specified by:
      getWizardName in interface PValidatingWizardContext
      Returns:
      The name of the wizard. This is the name that was passed in to the constructor.
    • getSharedDataManager

      public SharedDataManager getSharedDataManager()
      Returns the shared data manager.
      Specified by:
      getSharedDataManager in interface PValidatingWizardContext
      Returns:
      The shared data manager.
    • getWizardValidationManager

      public WizardValidationManager getWizardValidationManager()
      Returns the wizard validation manager.
      Specified by:
      getWizardValidationManager in interface PValidatingWizardContext
      Returns:
      The wizard validation manager.
    • getSharedData

      public SharedData getSharedData()
      Returns the shared data.
      Specified by:
      getSharedData in interface SharedDataManager
      Returns:
      Shared data.
    • addSharedDataListener

      public void addSharedDataListener(String propertyName, PropertyChangeListener listener)
      Adds a shared data listener (a PropertyChangeListener) for a specific property. The listener will be invoked only when a call on fireSharedDataChangedNotification names that specific property.
      Specified by:
      addSharedDataListener in interface SharedDataManager
      Parameters:
      propertyName - The name of the property to listen on.
      listener - The PropertyChangeListener to be added.
    • hasListeners

      public boolean hasListeners(String propertyName)
      Checks if there are any listeners for a specific property.
      Specified by:
      hasListeners in interface SharedDataManager
      Parameters:
      propertyName - the property name.
      Returns:
      true if there are one or more listeners for the given property.
    • removeSharedDataListener

      public void removeSharedDataListener(String propertyName, PropertyChangeListener listener)
      Removes a shared data listener (a PropertyChangeListener) for a specific property.
      Specified by:
      removeSharedDataListener in interface SharedDataManager
      Parameters:
      propertyName - The name of the property that was listened on.
      listener - The PropertyChangeListener to be removed.
    • fireSharedDataChangedNotification

      public void fireSharedDataChangedNotification(String propertyName, Object oldValue, Object newValue)
      Reports a bound property update to any registered listeners. No event is fired if old and new are equal and non-null.
      Specified by:
      fireSharedDataChangedNotification in interface SharedDataManager
      Parameters:
      propertyName - The programmatic name of the property that was changed.
      oldValue - The old value of the property.
      newValue - The new value of the property.
    • addSharedDataVetoableListener

      public void addSharedDataVetoableListener(String propertyName, VetoableChangeListener listener)
      Adds a shared data listener (a VetoableChangeListener) for a specific property. The listener will be invoked only when a call on fireSharedDataVetoabledNotification names that specific property.
      Specified by:
      addSharedDataVetoableListener in interface SharedDataManager
      Parameters:
      propertyName - The name of the property to listen on.
      listener - The VetoableChangeListener to be added.
    • removeSharedDataVetoableListener

      public void removeSharedDataVetoableListener(String propertyName, VetoableChangeListener listener)
      Removes the vetoable listener.
      Specified by:
      removeSharedDataVetoableListener in interface SharedDataManager
      Parameters:
      propertyName - The name of the property to listen on.
      listener - The VetoableChangeListener to be added.
    • hasVetoListeners

      public boolean hasVetoListeners(String propertyName)
      Checks if there are any veto listeners for a specific property.
      Specified by:
      hasVetoListeners in interface SharedDataManager
      Parameters:
      propertyName - the property name.
      Returns:
      true if there are ore or more listeners for the given property
    • fireSharedDataVetoableNotification

      public void fireSharedDataVetoableNotification(String propertyName, Object oldValue, Object newValue) throws PropertyVetoException
      Fires pre-notification for a bound property change to any registered listeners. This provides an opportunity for listeners to reject the change. No event is fired if old and new are equal and non-null.
      Specified by:
      fireSharedDataVetoableNotification in interface SharedDataManager
      Parameters:
      propertyName - The programmatic name of the property that was changed.
      oldValue - The old value of the property.
      newValue - The new value of the property.
      Throws:
      PropertyVetoException
    • addFinishVetoListener

      public void addFinishVetoListener(VetoableChangeListener veto)
      To Add FinishVetoListners from various pages in the Wizard. This provides an opportunity for listeners to reject the finish action if they decide to do so.
      Parameters:
      veto - The VetoableChangeListener