HiddenInput hiddenInputLastUsedMyId = new HiddenInput(LAST_USED_MY_ID_KEY, getMyId());
HiddenInput hiddenInputLastUsedMyId = new HiddenInput(HEADER_FORM_LAST_USED_MY_ID_KEY, getMyId()); HiddenInput hiddenAllEntitiesWereShown = new HiddenInput(REQUEST_FROM_EXTERNAL_FORM_SHOW_ALL_ENTITIES_KEY, (new Boolean(showAllEntities)).toString());
  public void main(IWContext iwc) throws Exception {     super.main(iwc);    // event model stuff    EntityBrowserPS state = (EntityBrowserPS) getPresentationState((IWUserContext) iwc);    this.addActionListener( (IWActionListener) state);       // get resource bundle    IWResourceBundle resourceBundle = getResourceBundle(iwc);        // get entity name from one element of the entity collection    // if the entity name is not set and the collection is not empty    if ( leadingEntityName == null || leadingEntityName.length() == 0 )  {      if (entities == null || entities.isEmpty()) {        setErrorContent(resourceBundle);        return;      }      else {        // sometimes entities is a collection of collections        Class objectClass;        Object object = entities.iterator().next();        if (object instanceof Collection) {          Collection coll = (Collection) object;          if  (! coll.isEmpty())  {            objectClass = coll.iterator().next().getClass();          }          else  {            setErrorContent(resourceBundle);            return;          }        }        else  {          objectClass = object.getClass();        }        Class[] interfaces = objectClass.getInterfaces();        if (interfaces.length > 0)  {          Class firstInterfaceClass = interfaces[0];          leadingEntityName = firstInterfaceClass.getName();        }        else {          setErrorContent(resourceBundle);          return;        }      }    }       // get user properties, set MultiPropertyhandler    MultiEntityPropertyHandler multiPropertyHandler;    try {      multiPropertyHandler = new MultiEntityPropertyHandler(iwc, leadingEntityName);    }    catch (ClassNotFoundException e)  {      System.err.println("[EntityBrowser] Class was not recognized: " + leadingEntityName + " Message was: " +      e.getMessage());      // e.printStackTrace(System.err);      setErrorContent(resourceBundle);      return;    }    if (entityNames != null)  {      Iterator iterator = entityNames.iterator();      while (iterator.hasNext())  {        try {          multiPropertyHandler.addEntity((String) iterator.next());        }        catch (ClassNotFoundException e)  {          // do not show the error content, continue!          System.err.println("[EntityBrowser] Class was not recognized: " + leadingEntityName + " Message was: " +          e.getMessage());          //e.printStackTrace(System.err);        }      }    }                List visibleOrderedEntityPathes = getVisibleOrderedEntityPathes(multiPropertyHandler);    int numberOfRowsPerPage = getNumberOfRowsPerPage(multiPropertyHandler);        // get and save the state of the former iterator BEFORE changing the iterator    SetIterator entityIterator = retrieveSetIterator(iwc, entities);    String formerStateOfIterator = entityIterator.getStateAsString();    // set properties (it does not matter if they have change or not)    entityIterator.setIncrement(numberOfRowsPerPage);    entityIterator.setQuantity(numberOfRowsPerPage);        // parse action use as key the state of the iterator:    // If there is a reload of the page the action "next subset" or    // "previous subset" will no be performed again.    parseAndDoAction(iwc, formerStateOfIterator, entityIterator);    // set size of table    int necessaryRows = entityIterator.getQuantity();    int necessaryColumns = visibleOrderedEntityPathes.size();    // we need at least on column for buttons    necessaryColumns = (necessaryColumns == 0) ? 1 : necessaryColumns;    // plus rows for header and buttons    necessaryRows += 3;    setSize(necessaryColumns, necessaryRows);                // get now the table        fillEntityTable(visibleOrderedEntityPathes , entityIterator, iwc);    boolean enableForward = entityIterator.hasNextSet();    boolean enableBack = entityIterator.hasPreviousSet();         // get current subset position    String currentStateOfIterator = entityIterator.getStateAsString();    // store state in session    entityIterator.storeStateInSession(iwc, keyForEntityCollection, getMyId());    // set hidden input (import for releasing)    if (useExternalForm)  {           HiddenInput hiddenInputLastUsedMyId = new HiddenInput(LAST_USED_MY_ID_KEY, getMyId());      add(hiddenInputLastUsedMyId);    }        if (showHeaderNavigation && (enableBack || enableForward))       setNavigationPanel( HEADER_FORM_KEY,                           iwc,                           resourceBundle,                           entityIterator,                           currentStateOfIterator,                           enableBack,                           enableForward,                          1,                          necessaryColumns);    if (showBottomNavigation         && (enableBack || enableForward)         && ( (! showHeaderNavigation) ||              (entityIterator.getIncrement() > pageLimitForShowingBottomNavigation)) )                          setNavigationPanel( BOTTOM_FORM_KEY,                         iwc,                         resourceBundle,                         entityIterator,                         currentStateOfIterator,                         enableBack,                         enableForward,                        necessaryRows,                        necessaryColumns);                             }