/**
   * This method delegates to the RequestContext.isPartialRequest() with the exception that JSF Ajax
   * render="@all" requests are reported as non-partial
   *
   * @param context
   * @return
   */
  public static boolean isPartialRequest(FacesContext context) {
    RequestContext rc = RequestContext.getCurrentInstance();
    if (rc == null) return false;
    boolean isPartial = rc.isPartialRequest(context);

    if (isPartial && context.getPartialViewContext().isRenderAll()) {
      // We do not want to create PartialPageContext and use the tree visit (if enabled)
      // for the 'render all' <f:ajax> case
      isPartial = false;
    }

    return isPartial;
  }
Пример #2
0
 public String goBack() {
   JsfUtils.removeFromPageFlow("profilePerson");
   JsfUtils.removeFromSession("profilePerson");
   //   JsfUtils.deleteGridDataFromPageFlow();
   RequestContext.getCurrentInstance().returnFromDialog(null, null);
   return UserFavoritesWebUtils.getInstance().getOriginPageToInterests();
 }
 public void prepareAndReturn(ActionEvent event) {
   //        MultiMediaTableOfContent selectedRow = (MultiMediaTableOfContent)
   // table.getSelectedRowData();
   MultiMediaTableOfContent selectedRow =
       (MultiMediaTableOfContent) JsfUtils.resolveVariable("row");
   RequestContext.getCurrentInstance().returnFromDialog(selectedRow, null);
 }
Пример #4
0
  public DisplayLegalMemberBean() {

    GeneralProfile profile =
        (GeneralProfile)
            RequestContext.getCurrentInstance().getPageFlowScope().get("generalProfile");

    if (profile != null) {
      this.generalProfile = profile;
      this.legalPerson =
          NliProfileServiceProxy.getInstance()
              .findLegalProfilePersonByProfilePersonId(
                  profile.getRegisterationUnit().getProfilePerson().getId());

      this.unitStr = this.generalProfile.getRegisterationUnit().getWorkGroup().getName();

      if (this.generalProfile instanceof LoanProfile) {
        this.selectUnitLabel = JsfUtils.getStringFromBundle("library");
        this.selectedRequestType = UserManagementDataMap.Request_type.SafeKeeping.getValue();
      } else if (this.generalProfile instanceof ProberProfile) {
        this.selectUnitLabel = JsfUtils.getStringFromBundle("unit");
        this.selectedRequestType = UserManagementDataMap.Request_type.Scholar.getValue();
      } else {
        this.selectUnitLabel = JsfUtils.getStringFromBundle("library");
        this.selectedRequestType = UserManagementDataMap.Request_type.Exchange.getValue();
      }

      this.unitStr =
          this.generalProfile.getRegisterationUnit().getWorkGroup() == null
              ? " "
              : this.generalProfile.getRegisterationUnit().getWorkGroup().getName();

      if (this.legalPerson.getImage() != null && this.legalPerson.getImage().length > 0)
        this.imageSource = JsfUtils.getVirtualImageUrl(this.legalPerson.getImage(), "personImage");
    }
  }
  public void selectAndReturn(ActionEvent event) {

    AccessModuleRowData row = (AccessModuleRowData) JsfUtils.resolveVariable("row");
    AccessModule accessModule = (AccessModule) row.getEntity();

    Map map = new HashMap();
    map.put(UserManagementConstants.SELECTED_ACCESSMODULE_OBJECT_NAME, accessModule);

    RequestContext.getCurrentInstance().returnFromDialog(accessModule.getTitle(), map);
  }
Пример #6
0
 public String select() {
   AccessModuleRowData selectedRow = (AccessModuleRowData) JsfUtils.resolveVariable("row");
   if (selectedRow != null) {
     AccessModule accessModule = (AccessModule) selectedRow.getEntity();
     HashMap returnValue = new HashMap<String, AccessModule>();
     returnValue.put(Constants.KEY_RETURN_FROM_DIALOG, accessModule);
     RequestContext.getCurrentInstance().returnFromDialog(accessModule.getTitle(), returnValue);
   }
   return null;
 }
  @SuppressWarnings("unchecked")
  @Override
  protected void decode(
      FacesContext facesContext,
      UIComponent component,
      @SuppressWarnings("unused") FacesBean facesBean,
      String clientId) {
    super.decode(facesContext, component, facesBean, clientId);

    RequestContext afContext = RequestContext.getCurrentInstance();
    // See if a ReturnEvent is waiting for us.  We don't deliver
    // the ReturnEvent - we just use its value
    ReturnEvent returnEvent = afContext.getDialogService().getReturnEvent(component);
    if (returnEvent != null) {
      afContext.addPartialTarget(component);
      queueReturnEvent(facesContext, component, returnEvent);
    } else {
      Map<String, String> parameterMap = facesContext.getExternalContext().getRequestParameterMap();

      Object source = parameterMap.get("source");
      clientId = clientId == null ? component.getClientId(facesContext) : clientId;
      if ((source != null) && source.equals(clientId)) {
        Object part = parameterMap.get(_PART_PARAMETER);
        if (_BUTTON_PART.equals(part)) {
          // Force partial rendering (if we're launching a window)
          // =-=AEW I don't believe this is necessary;  I believe
          // we've already got "partial" turned on
          TrinidadAgent agent = AgentUtil.getAgent(facesContext);
          if (XhtmlUtils.supportsSeparateWindow(agent))
            PartialPageUtils.forcePartialRendering(facesContext);

          queueActionEvent(facesContext, component);
        }
        // else ???
      }
    }
  }
  @SuppressWarnings("unchecked")
  public String select() {
    FacesContext context = FacesContext.getCurrentInstance();
    // The tableSelectOne is marked as required; so there'd better
    // be a selected row - an exception will result here if there
    // isn't.  Is there some better code?
    Iterator<Object> iterator = _table.getSelectedRowKeys().iterator();
    Object rowKey = iterator.next();
    Object oldRowKey = _table.getRowKey();
    _table.setRowKey(rowKey);
    ValueBinding binding = context.getApplication().createValueBinding("#{row.symbol}");
    Object value = binding.getValue(context);
    RequestContext.getCurrentInstance().returnFromDialog(value, null);
    _table.setRowKey(oldRowKey);

    return null;
  }
  /**
   * Set a property of type java.util.Date. If the value is an EL expression, it will be stored as a
   * ValueBinding. Otherwise, it will parsed as an ISO 8601 date (yyyy-MM-dd) and the time
   * components (hour, min, second, millisecond) maximized. Null values are ignored.
   */
  protected void setMaxDateProperty(FacesBean bean, PropertyKey key, ValueExpression expression) {
    if (expression == null) return;

    if (expression.isLiteralText()) {
      Date d = _parseISODate(expression.getValue(null));
      Calendar c = Calendar.getInstance();
      TimeZone tz = RequestContext.getCurrentInstance().getTimeZone();
      if (tz != null) c.setTimeZone(tz);
      c.setTime(d);
      // Original value had 00:00:00 for hours,mins, seconds now maximize those
      // to get the latest time value for the date supplied.
      c.set(Calendar.HOUR_OF_DAY, 23);
      c.set(Calendar.MINUTE, 59);
      c.set(Calendar.SECOND, 59);
      c.set(Calendar.MILLISECOND, 999);
      bean.setProperty(key, c.getTime());
    } else {
      bean.setValueExpression(key, expression);
    }
  }
 public String cancel() {
   RequestContext.getCurrentInstance().returnFromDialog(null, null);
   return null;
 }
Пример #11
0
  private String processException(Exception exp, int flag) {

    String message = "";
    String type = "";
    Date requestDate = null;
    Date reviewDate = null;

    switch (flag) {
      case 0:
        LoanProfile loanProfile = ((DuplicateLoanProfileException) exp).getLoanProfile();
        type = loanProfile.getProfileState().getCode();
        requestDate = loanProfile.getRequestDate();
        reviewDate = loanProfile.getReviewDate();
        break;

      case 1:
        ExchangeProfile exchangeProfile =
            ((DuplicateExchangeProfileException) exp).getExchangeProfile();
        type = exchangeProfile.getProfileState().getCode();
        requestDate = exchangeProfile.getRequestDate();
        reviewDate = exchangeProfile.getReviewDate();
        break;

      case 2:
        ProberProfile proberProfile = ((DuplicateProberProfileException) exp).getProberProfile();
        type = proberProfile.getProfileState().getCode();
        requestDate = proberProfile.getRequestDate();
        reviewDate = proberProfile.getReviewDate();
        break;
    }

    if (type.equalsIgnoreCase(ProfileState.NEW_REQUEST_STATE)) {

      message =
          JsfUtils.getStringFromBundle("yourRequestForUnit")
              + " "
              + JsfUtils.getStringFromBundle(this.selectedUnitOrLib.getName())
              + JsfUtils.getStringFromBundle("andMembershipAt")
              + " "
              + JsfUtils.getStringFromBundle(
                  UserManagementDataMap.convertRequestType(this.selectedRequestType))
              + JsfUtils.getStringFromBundle("inDate")
              + " "
              + String.valueOf(requestDate)
              + JsfUtils.getStringFromBundle("isRegisteredAndCurrentlyIsUnderProcessing");

    } else if (type.equalsIgnoreCase(ProfileState.CONFIRMED_REQUEST_STATE)) {

      message =
          JsfUtils.getStringFromBundle("yourRequestForUnit")
              + " "
              + JsfUtils.getStringFromBundle(this.selectedUnitOrLib.getName())
              + JsfUtils.getStringFromBundle("andMembershipAt")
              + " "
              + JsfUtils.getStringFromBundle(
                  UserManagementDataMap.convertRequestType(this.selectedRequestType))
              + JsfUtils.getStringFromBundle("inDate")
              + " "
              + String.valueOf(requestDate)
              + JsfUtils.getStringFromBundle("isRegisteredAndInDate")
              + " "
              + String.valueOf(reviewDate)
              + JsfUtils.getStringFromBundle("havebeenRejected")
              + JsfUtils.getStringFromBundle("wouldYouLikeToSubmitANewRequest");

    } else if (type.equalsIgnoreCase(ProfileState.REJECTED_REQUEST_STATE)) {

      message =
          JsfUtils.getStringFromBundle("yourRequestForUnit")
              + " "
              + JsfUtils.getStringFromBundle(this.selectedUnitOrLib.getName())
              + JsfUtils.getStringFromBundle("andMembershipAt")
              + " "
              + JsfUtils.getStringFromBundle(
                  UserManagementDataMap.convertRequestType(this.selectedRequestType))
              + JsfUtils.getStringFromBundle("inDate")
              + " "
              + String.valueOf(requestDate)
              + JsfUtils.getStringFromBundle("isConfirmed");

    } else assert true : "Invalid Profile State!!!";

    FacesContext context = FacesContext.getCurrentInstance();
    ViewHandler viewHandler = context.getApplication().getViewHandler();
    UIViewRoot dialog =
        viewHandler.createView(context, "/usermanagement/generalPages/showMessagePage.jspx");

    Map properties = new HashMap();
    properties.put("width", new Integer(300));
    properties.put("height", new Integer(400));

    Map params = new HashMap();
    params.put(UserManagementConstants.DIALOG_MESSAGE, message);
    RequestContext requestContext = RequestContext.getCurrentInstance();
    requestContext.launchDialog(dialog, params, null, true, properties);

    return "";
  }
Пример #12
0
  public String doSave() {

    try {

      if (StringUtils.isEmpty(membershipNumber)) {
        ErrorReportingUtils.getInstance().reportErrors("membership-number-is-missing");
        return "";
      }
      if (selectedUnitOrLib instanceof LibraryUnit
          && selectedRequestType == UserManagementDataMap.Request_type.Scholar.getValue()) {
        ErrorReportingUtils.getInstance().reportErrors("select-valid-unit-library");
        return "";
      }

      if (selectedUnitOrLib instanceof OrganizationUnit
          && selectedRequestType != UserManagementDataMap.Request_type.Scholar.getValue()) {
        ErrorReportingUtils.getInstance().reportErrors("select-valid-unit-library");
        return "";
      }

      if (this.realPerson.getProfile() == null) this.realPerson.setProfile(new ProfilePerson());

      ProfilePerson profile = this.realPerson.getProfile();
      profile.setNationality(getNationality());
      profile.setTitle(this.realPerson.getFirstName() + " " + this.realPerson.getLastName());
      profile.setMembershipNo(this.membershipNumber);

      profile.setUserType(ProfilePerson.BOTH);
      profile.setRegisterType(Byte.valueOf(JsfUtils.getFromPageFlow("registerType").toString()));
      profile.setUserName(this.userName);
      profile.setPassword(WebApplication.getInstance().encodePassword(this.password));
      profile.setEmail(this.email);
      this.realPerson.setUniqeName(this.realPerson.createPersonIdentifierKey());

      if (this.selectedRequestType == UserManagementDataMap.Request_type.SafeKeeping.getValue()) {
        service.saveRealLoanProfileRequest(this.realPerson, this.selectedUnitOrLib);
      } else if (this.selectedRequestType
          == UserManagementDataMap.Request_type.Exchange.getValue()) {
        service.saveRealExchangeProfileRequest(this.realPerson, this.selectedUnitOrLib);
      } else if (this.selectedRequestType
          == UserManagementDataMap.Request_type.Scholar.getValue()) {
        service.saveRealProberProfileRequest(this.realPerson, this.selectedUnitOrLib);
      }

      this.realPerson = service.findRealProfilePersonByProfilePersonId(profile.getId());

      NliMailDefinitionServiceProxy.getInstance()
          .sendMessage(
              this.email,
              JsfUtils.getStringFromBundle("userNamePassEmailSubject"),
              "body",
              Constants.UTF8);

      Map map = RequestContext.getCurrentInstance().getPageFlowScope();
      map.put("realPerson", this.realPerson);
      map.put("selectedUnit", this.selectedUnitOrLib);
      map.put("requestType", this.selectedRequestType);

    } catch (DuplicateMembershipNoException exp) {
      ErrorReportingUtils.getInstance()
          .reportErrors(JsfUtils.getStringFromBundle("duplicateMembershipNoException"));
      return "";
    } catch (DuplicateMemberException e) {
      ErrorReportingUtils.getInstance()
          .reportErrors(JsfUtils.getStringFromBundle("duplicateMemberException"));
      return "";
    } catch (DuplicateNationalCodeException e) {
      ErrorReportingUtils.getInstance()
          .reportErrors(JsfUtils.getStringFromBundle("duplicateNationalCodeException"));
      return "";
    } catch (DuplicateUserNameException e) {
      ErrorReportingUtils.getInstance()
          .reportErrors(JsfUtils.getStringFromBundle("duplicateUsernameException"));
      return "";
    } catch (DuplicateLoanProfileException exp) {

      return processException(exp, 0);

    } catch (DuplicateExchangeProfileException exp) {

      return processException(exp, 1);

    } catch (DuplicateProberProfileException exp) {

      return processException(exp, 2);

    } catch (Exception exp) {
      exp.printStackTrace();

      return "";
    } finally {

    }

    return goBackList();
  }
 public void cancel() {
   RequestContext.getCurrentInstance().returnFromDialog(null, null);
 }
 public String cancelAction() {
   RequestContext.getCurrentInstance().returnFromDialog(null, null);
   return Constants.NULL_OUTCOME;
 }
 // We rely strictly on ISO 8601 formats
 private static DateFormat _getDateFormat() {
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
   TimeZone tz = RequestContext.getCurrentInstance().getTimeZone();
   if (tz != null) sdf.setTimeZone(tz);
   return sdf;
 }
Пример #16
0
 public String closeDeleteConfirmDialog() {
   RequestContext.getCurrentInstance().returnFromDialog(null, null);
   return null;
 }