Esempio n. 1
0
 public void setEntityRedirectorPageId(String redirectPageId) {
   this.redirectorPageId = redirectPageId;
   this.redirectorPage =
       (EntityRedirectorPage) getOwner().findPath(redirectPageId).getMatchedPath();
   if (redirectorPage != null) {
     setRequireRequestParam(redirectorPage.getEntityIdRequestParamName());
     // TODO: instead of skipping the entity id request param when retainParams is null, merge all
     // parameters into a single ValueSource.
     if (getRetainParams() == null) {
       setRetainParams(new StaticValueSource(redirectorPage.getEntityIdRequestParamName()));
     }
   }
 }
Esempio n. 2
0
  public boolean isValid(NavigationContext nc) {
    if (!super.isValid(nc)) return false;

    ActiveEntity activeEntity;

    // if we're coming from a redirector then it means that we may not need to rerun our queries
    final EntityRedirectorPage redirectorPage = getRedirectorPage();
    if (redirectorPage == null) {
      log.error(
          "No redirector page specified for entity page " + getQualifiedNameIncludingTreeId());
      return false;
    }

    EntitySubtypeRedirectInfo esri =
        EntityRedirectorPage.getEntitySubtypeRedirectInfo(
            nc, redirectorPage.getEntityIdRequestParamValue(nc));
    if (esri != null) activeEntity = (ActiveEntity) esri.getData();
    else {
      // if we get here it means we need to run our queries to get the active person
      ConnectionContext cc;
      try {
        cc = nc.getConnection(null, false);
      } catch (Exception e) {
        log.error(e);
        throw new NestableRuntimeException(e);
      }

      try {
        activeEntity = this.redirectorPage.getActiveEntity(nc, cc);
      } catch (Exception e) {
        log.error(e);
        throw new NestableRuntimeException(e);
      } finally {
        try {
          cc.close();
        } catch (SQLException e) {
          log.error(e);
          throw new NestableRuntimeException(e);
        }
      }
    }

    ((EntityPageState) nc.getActiveState()).setActiveEntity(activeEntity);
    return true;
  }