示例#1
0
 public static String makeLinkHiddenFormName(
     Map<String, Object> context, ModelFormField modelFormField) {
   ModelForm modelForm = modelFormField.getModelForm();
   Integer itemIndex = (Integer) context.get("itemIndex");
   String iterateId = "";
   String formUniqueId = "";
   String formName = (String) context.get("formName");
   if (UtilValidate.isEmpty(formName)) {
     formName = modelForm.getName();
   }
   if (UtilValidate.isNotEmpty(context.get("iterateId"))) {
     iterateId = (String) context.get("iterateId");
   }
   if (UtilValidate.isNotEmpty(context.get("formUniqueId"))) {
     formUniqueId = (String) context.get("formUniqueId");
   }
   if (itemIndex != null) {
     return formName
         + modelForm.getItemIndexSeparator()
         + itemIndex.intValue()
         + iterateId
         + formUniqueId
         + modelForm.getItemIndexSeparator()
         + modelFormField.getName();
   } else {
     return formName + modelForm.getItemIndexSeparator() + modelFormField.getName();
   }
 }
示例#2
0
  public static void makeHiddenFormLinkAnchor(
      Appendable writer,
      String linkStyle,
      String description,
      String confirmation,
      ModelFormField modelFormField,
      HttpServletRequest request,
      HttpServletResponse response,
      Map<String, Object> context)
      throws IOException {
    if (UtilValidate.isNotEmpty(description)
        || UtilValidate.isNotEmpty(request.getAttribute("image"))) {
      writer.append("<a");

      if (UtilValidate.isNotEmpty(linkStyle)) {
        writer.append(" class=\"");
        writer.append(linkStyle);
        writer.append("\"");
      }

      writer.append(" href=\"javascript:document.");
      writer.append(makeLinkHiddenFormName(context, modelFormField));
      writer.append(".submit()\"");

      if (UtilValidate.isNotEmpty(modelFormField.getEvent())
          && UtilValidate.isNotEmpty(modelFormField.getAction(context))) {
        writer.append(" ");
        writer.append(modelFormField.getEvent());
        writer.append("=\"");
        writer.append(modelFormField.getAction(context));
        writer.append('"');
      }

      if (UtilValidate.isNotEmpty(confirmation)) {
        writer.append(" onclick=\"return confirm('");
        writer.append(confirmation);
        writer.append("')\"");
      }

      writer.append('>');

      if (UtilValidate.isNotEmpty(request.getAttribute("image"))) {
        writer.append("<img src=\"");
        writer.append(request.getAttribute("image").toString());
        writer.append("\"/>");
      }

      writer.append(description);
      writer.append("</a>");
    }
  }
示例#3
0
  public static void makeHyperlinkString(
      Appendable writer,
      String linkStyle,
      String targetType,
      String target,
      Map<String, String> parameterMap,
      String description,
      String confirmation,
      ModelFormField modelFormField,
      HttpServletRequest request,
      HttpServletResponse response,
      Map<String, Object> context,
      String targetWindow)
      throws IOException {
    if (UtilValidate.isNotEmpty(description)
        || UtilValidate.isNotEmpty(request.getAttribute("image"))) {
      writer.append("<a");

      if (UtilValidate.isNotEmpty(linkStyle)) {
        writer.append(" class=\"");
        writer.append(linkStyle);
        writer.append("\"");
      }

      writer.append(" href=\"");

      buildHyperlinkUrl(
          writer,
          target,
          targetType,
          parameterMap,
          null,
          false,
          false,
          true,
          request,
          response,
          context);

      writer.append("\"");

      if (UtilValidate.isNotEmpty(targetWindow)) {
        writer.append(" target=\"");
        writer.append(targetWindow);
        writer.append("\"");
      }

      if (UtilValidate.isNotEmpty(modelFormField.getEvent())
          && UtilValidate.isNotEmpty(modelFormField.getAction(context))) {
        writer.append(" ");
        writer.append(modelFormField.getEvent());
        writer.append("=\"");
        writer.append(modelFormField.getAction(context));
        writer.append('"');
      }
      if (UtilValidate.isNotEmpty(confirmation)) {
        writer.append(" onclick=\"return confirm('");
        writer.append(confirmation);
        writer.append("')\"");
      }
      writer.append('>');

      if (UtilValidate.isNotEmpty(request.getAttribute("image"))) {
        writer.append("<img src=\"");
        writer.append(request.getAttribute("image").toString());
        writer.append("\"/>");
      }

      writer.append(description);
      writer.append("</a>");
    }
  }
示例#4
0
  public static void makeHyperlinkByType(
      Appendable writer,
      String linkType,
      String linkStyle,
      String targetType,
      String target,
      Map<String, String> parameterMap,
      String description,
      String targetWindow,
      String confirmation,
      ModelFormField modelFormField,
      HttpServletRequest request,
      HttpServletResponse response,
      Map<String, Object> context)
      throws IOException {
    String realLinkType = WidgetWorker.determineAutoLinkType(linkType, target, targetType, request);
    if ("hidden-form".equals(realLinkType)) {
      if (modelFormField != null && "multi".equals(modelFormField.getModelForm().getType())) {
        WidgetWorker.makeHiddenFormLinkAnchor(
            writer,
            linkStyle,
            description,
            confirmation,
            modelFormField,
            request,
            response,
            context);

        // this is a bit trickier, since we can't do a nested form we'll have to put the link to
        // submit the form in place, but put the actual form def elsewhere, ie after the big form is
        // closed
        Map<String, Object> wholeFormContext =
            UtilGenerics.checkMap(context.get("wholeFormContext"));
        Appendable postMultiFormWriter =
            wholeFormContext != null
                ? (Appendable) wholeFormContext.get("postMultiFormWriter")
                : null;
        if (postMultiFormWriter == null) {
          postMultiFormWriter = new StringWriter();
          wholeFormContext.put("postMultiFormWriter", postMultiFormWriter);
        }
        WidgetWorker.makeHiddenFormLinkForm(
            postMultiFormWriter,
            target,
            targetType,
            targetWindow,
            parameterMap,
            modelFormField,
            request,
            response,
            context);
      } else {
        WidgetWorker.makeHiddenFormLinkForm(
            writer,
            target,
            targetType,
            targetWindow,
            parameterMap,
            modelFormField,
            request,
            response,
            context);
        WidgetWorker.makeHiddenFormLinkAnchor(
            writer,
            linkStyle,
            description,
            confirmation,
            modelFormField,
            request,
            response,
            context);
      }
    } else {
      WidgetWorker.makeHyperlinkString(
          writer,
          linkStyle,
          targetType,
          target,
          parameterMap,
          description,
          confirmation,
          modelFormField,
          request,
          response,
          context,
          targetWindow);
    }
  }