public void initSubPages(Page page, SeleniumActions a) {
    Preconditions.checkNotNull(a);
    Preconditions.checkNotNull(page);
    List<Field> fields = getAllSubpageFields(page.getClass());
    for (Field field : fields) {
      Class type = field.getType();
      if (!SubPage.class.isAssignableFrom(type)) {
        logger.warn("Invalid @SubPageField in class '%s'. Must be a subclass of SubPage.");
        continue;
      }

      SubPage subPage =
          PageFactory.initElements(
              a.getBrowser().getWebDriver(), (Class<? extends SubPage>) field.getType());
      subPage.setActions(a);
      subPage.setParent(page);
      subPage.pageLoadHook();
      subPage.initSubPages();

      // Set the subpage field
      try {
        field.setAccessible(true);
        field.set(page, subPage);
      } catch (IllegalAccessException ex) {
        logger.error("Error instantiating SubPage field: " + field, ex);
        throw new RuntimeException(ex);
      }
    }
  }
 /**
  * Default implementation of pageLoadHook().
  *
  * <p>Just verify the page identifier Locator is present on the DOM.
  *
  * @param page
  * @param a
  */
 public void defaultPageLoadHook(Page page, SeleniumActions a) {
   By pageIdentifier = page.getPageIdentifier();
   if (pageIdentifier != null) {
     a.verifyElementPresented(pageIdentifier, TimeoutType.PAGE_LOAD_TIMEOUT);
   }
 }