コード例 #1
0
  /**
   * Create the HC node to represent the help icon. This method is only called, if help is available
   * for this page. The created code looks like this by default:<br>
   * <code>
   * &lt;a href="<i>helpURL</i>" title="Show help for page <i>pageName</i>" target="simplehelpwindow"&gt;<br>
   * &lt;span class="page_help_icon"&gt;&lt;/span&gt;<br>
   * &lt;/a&gt;</code>
   *
   * @param aWPEC The web page execution context
   * @return The created help icon node. May be <code>null</code>.
   */
  @Nullable
  @OverrideOnDemand
  protected IHCNode getHelpIconNode(@Nonnull final WPECTYPE aWPEC) {
    final IRequestWebScopeWithoutResponse aRequestScope = aWPEC.getRequestScope();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();

    final HCA aHelpNode = new HCA(getHelpURL(aRequestScope, aDisplayLocale));
    final String sPageName = getDisplayText(aDisplayLocale);
    aHelpNode.setTitle(
        EWebBasicsText.PAGE_HELP_TITLE.getDisplayTextWithArgs(aDisplayLocale, sPageName));
    aHelpNode.addChild(new HCSpan().addClass(CSS_PAGE_HELP_ICON));
    aHelpNode.setTarget(new HCA_Target(HELP_WINDOW_NAME));
    return aHelpNode;
  }
コード例 #2
0
 /**
  * Create toolbar for editing an existing object
  *
  * @param aWPEC The web page execution context. Never <code>null</code>.
  * @param aForm The handled form. Never <code>null</code>.
  * @param aSelectedObject The selected object. Never <code>null</code>.
  * @return Never <code>null</code>.
  */
 @Nonnull
 @OverrideOnDemand
 protected IButtonToolbar<?> createEditToolbar(
     @Nonnull final WPECTYPE aWPEC,
     @Nonnull final HCForm aForm,
     @Nonnull final DATATYPE aSelectedObject) {
   final IButtonToolbar<?> aToolbar = createNewEditToolbar(aWPEC);
   aToolbar.addHiddenField(CHCParam.PARAM_ACTION, ACTION_EDIT);
   aToolbar.addHiddenField(CHCParam.PARAM_OBJECT, aSelectedObject.getID());
   aToolbar.addHiddenField(CHCParam.PARAM_SUBACTION, ACTION_SAVE);
   // Save button
   aToolbar.addSubmitButtonSave(aWPEC.getDisplayLocale());
   // Cancel button
   aToolbar.addButtonCancel(aWPEC.getDisplayLocale());
   modifyEditToolbar(aWPEC, aSelectedObject, aToolbar);
   return aToolbar;
 }
コード例 #3
0
 /**
  * Create toolbar for viewing an existing object. Contains the back button and the edit button.
  *
  * @param aWPEC The display locale to use
  * @param bCanGoBack true to enable back button
  * @param bCanEdit true to enable edit button
  * @param aSelectedObject The selected object
  * @return Never <code>null</code>.
  */
 @Nonnull
 @OverrideOnDemand
 protected IButtonToolbar<?> createViewToolbar(
     @Nonnull final WPECTYPE aWPEC,
     final boolean bCanGoBack,
     final boolean bCanEdit,
     @Nonnull final DATATYPE aSelectedObject) {
   final IButtonToolbar<?> aToolbar = createNewViewToolbar(aWPEC);
   if (bCanGoBack) {
     // Back to list
     aToolbar.addButtonBack(aWPEC.getDisplayLocale());
   }
   if (bCanEdit) {
     // Edit object
     aToolbar.addButtonEdit(aWPEC.getDisplayLocale(), createEditURL(aWPEC, aSelectedObject));
   }
   modifyViewToolbar(aWPEC, aSelectedObject, aToolbar);
   return aToolbar;
 }
コード例 #4
0
  protected final void handleViewObject(
      @Nonnull final WPECTYPE aWPEC,
      @Nonnull final DATATYPE aSelectedObject,
      final boolean bIsEditAllowed) {
    // Valid object found - show details
    showSelectedObject(aWPEC, aSelectedObject);

    if (showViewToolbar(aWPEC, aSelectedObject)) {
      // Toolbar on bottom
      aWPEC.getNodeList().addChild(createViewToolbar(aWPEC, true, bIsEditAllowed, aSelectedObject));
    }
  }
コード例 #5
0
 /**
  * Get the ID of the selected object from the passed execution context.
  *
  * @param aWPEC The current web page execution context. Never <code>null</code>.
  * @return <code>null</code> if no selected object is present.
  */
 @Nullable
 protected final String getSelectedObjectID(@Nonnull final WPECTYPE aWPEC) {
   return aWPEC.getAttributeAsString(CHCParam.PARAM_OBJECT);
 }
コード例 #6
0
  @Override
  protected final void fillContent(@Nonnull final WPECTYPE aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();

    // Get the selected object
    final DATATYPE aSelectedObject = getSelectedObject(aWPEC, getSelectedObjectID(aWPEC));

    final boolean bIsEditAllowed = isEditAllowed(aWPEC, aSelectedObject);
    boolean bShowList = true;
    final String sAction = aWPEC.getAction();
    EWebPageFormAction eFormAction = null;
    if (ACTION_VIEW.equals(sAction) && aSelectedObject != null)
      eFormAction = EWebPageFormAction.VIEW;
    else if (ACTION_CREATE.equals(sAction)) eFormAction = EWebPageFormAction.CREATE;
    else if (ACTION_EDIT.equals(sAction) && bIsEditAllowed && aSelectedObject != null)
      eFormAction = EWebPageFormAction.EDIT;
    else if (ACTION_COPY.equals(sAction) && aSelectedObject != null)
      eFormAction = EWebPageFormAction.COPY;
    else if (ACTION_DELETE.equals(sAction) && aSelectedObject != null)
      eFormAction = EWebPageFormAction.DELETE;
    else if (ACTION_UNDELETE.equals(sAction) && aSelectedObject != null)
      eFormAction = EWebPageFormAction.UNDELETE;

    // Try to lock object
    if (beforeProcessing(aWPEC, aSelectedObject, eFormAction).isContinue()) {
      if (eFormAction == EWebPageFormAction.VIEW) {
        // Valid object found - show details
        handleViewObject(aWPEC, aSelectedObject, bIsEditAllowed);

        bShowList = false;
      } else {
        if (eFormAction == EWebPageFormAction.CREATE
            || eFormAction == EWebPageFormAction.EDIT
            || eFormAction == EWebPageFormAction.COPY) {
          final boolean bIsEdit = eFormAction == EWebPageFormAction.EDIT;
          final boolean bIsCopy = eFormAction == EWebPageFormAction.COPY;

          // Create or edit a client
          final FormErrors aFormErrors = new FormErrors();
          boolean bShowInputForm = true;

          if (aWPEC.hasSubAction(CHCParam.ACTION_SAVE)) {
            // try to save
            validateAndSaveInputParameters(aWPEC, aSelectedObject, aFormErrors, bIsEdit);
            if (aFormErrors.isEmpty()) {
              // Save successful
              bShowInputForm = false;

              // Remove an optionally stored state
              FormStateManager.getInstance()
                  .deleteFormState(aWPEC.getAttributeAsString(FIELD_FLOW_ID));
            } else {
              // Show: changes could not be saved...
              aNodeList.addChild(getStyler().createIncorrectInputBox(aWPEC));
            }
          }

          if (bShowInputForm) {
            // Show the input form. Either for the first time or because of form
            // errors a n-th time
            bShowList = false;
            final HCForm aForm =
                isFileUploadForm(aWPEC) ? createFormFileUploadSelf(aWPEC) : createFormSelf(aWPEC);
            aForm.setID(INPUT_FORM_ID);
            aNodeList.addChild(aForm);

            // The unique form ID, that allows to identify on "transaction"
            // -> Used only for "form state remembering"
            aForm.addChild(
                new HCHiddenField(
                    new RequestField(FIELD_FLOW_ID, GlobalIDFactory.getNewStringID())));

            modifyFormBeforeShowInputForm(aWPEC, aForm);

            // Is there as saved state to use?
            final String sRestoreFlowID = aWPEC.getAttributeAsString(FIELD_RESTORE_FLOW_ID);
            if (sRestoreFlowID != null) {
              final FormState aSavedState =
                  FormStateManager.getInstance().getFormStateOfID(sRestoreFlowID);
              if (aSavedState != null) {
                // Restore all form values
                aForm.addChild(
                    new HCScriptOnDocumentReady(
                        JSFormHelper.setAllFormValues(
                            INPUT_FORM_ID, aSavedState.getAsAssocArray())));
              }
            }

            // Show the main input form
            showInputForm(aWPEC, aSelectedObject, aForm, bIsEdit, bIsCopy, aFormErrors);

            // Toolbar on bottom
            if (bIsEdit) {
              if (showEditToolbar(aWPEC, aSelectedObject))
                aForm.addChild(createEditToolbar(aWPEC, aForm, aSelectedObject));
            } else {
              if (showCreateToolbar(aWPEC, aSelectedObject))
                aForm.addChild(createCreateToolbar(aWPEC, aForm, aSelectedObject));
            }
          }
        } else if (eFormAction == EWebPageFormAction.DELETE) {
          bShowList = handleDeleteAction(aWPEC, aSelectedObject);
        } else if (eFormAction == EWebPageFormAction.UNDELETE) {
          bShowList = handleUndeleteAction(aWPEC, aSelectedObject);
        } else {
          // Other proprietary actions
          bShowList = handleCustomActions(aWPEC, aSelectedObject);
        }
      }
    }

    if (bShowList) {
      showListOfExistingObjects(aWPEC);
    }

    // Call after everything
    afterProcessing(aWPEC, aSelectedObject, eFormAction);
  }
コード例 #7
0
 /**
  * Overridable method to attach the help node to the page. This is called as the last action.
  *
  * @param aWPEC The web page execution context. Never <code>null</code>.
  * @param aHelpNode The help node to be inserted. Never <code>null</code>.
  */
 @OverrideOnDemand
 protected void insertHelpNode(@Nonnull final WPECTYPE aWPEC, @Nonnull final IHCNode aHelpNode) {
   // Add the help icon as the first child of the resulting node list
   aWPEC.getNodeList().addChild(0, aHelpNode);
 }
コード例 #8
0
 @Nullable
 @OverrideOnDemand
 public String getHeaderText(@Nonnull final WPECTYPE aWPEC) {
   return getDisplayText(aWPEC.getDisplayLocale());
 }