Package org.boco.seamwebappgen.utils

Examples of org.boco.seamwebappgen.utils.CodeChunk


    return orderingFunctions;
  }

  private static CodeChunk generateBeanManager_ListBoxFunctions(InfoReader infoReader, Bean bean, Vector<Relationship> relationships2ThisBean) throws Exception
  {
    CodeChunk listMethods = new CodeChunk(0);
    for (int i = 0; i < relationships2ThisBean.size(); i++)
    {
      Relationship rel = relationships2ThisBean.get(i);

      if ((rel.isUsed() && rel.isListBox()) || belongs2SearchAttribute(infoReader.getBean(rel.getFromBeanName()), rel))
      {
        // if (rel.isToMany())
        // {
        // ;
        // }
        // else
        // {
        String relatedAttributes = "";
        for (int k = 0; k < rel.getRelatedAttributes().size(); k++)
        {
          relatedAttributes += Utils.makeFirstLetterUpperCase(rel.getRelatedAttributes().get(k).getName());
        }

        CodeChunk tmp = new CodeChunk(0);

        tmp.addJavaCode("public HashMap<String, " + bean.getName() + "> get" + bean.getName() + "List");
        tmp.addJavaCode(relatedAttributes);
        tmp.addJavaCode("() throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException\r\n");
        tmp.addJavaCode("\t{\r\n");
        tmp.addJavaCode("\t\tString labels[] = {");

        for (int k = 0; k < rel.getRelatedAttributes().size(); k++)
        {
          if (k > 0)
            tmp.addJavaCode(",");

          tmp.addJavaCode("\"" + Utils.makeGet(rel.getRelatedAttributes().get(k).getName()) + "\"");
        }

        tmp.addJavaCode("};\r\n\r\n");

        tmp.addJavaCode("\t\tmakeList(labels);\r\n");
        tmp.addJavaCode("\r\n");

        // if (rel.isFromMany())
        if (!rel.isToMany())
        {
          // tmp.addJavaCode("\t\t" +
          // Utils.makeFirstLetterLowerCase(bean.getName()) + "Map.put(\"--
          // selezionare -- \", new " + bean.getName() + "());\r\n");
          // tmp.addJavaCode("\r\n");
        }

        tmp.addJavaCode("\t\treturn " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Map;\r\n");

        tmp.addJavaCode("\t}\r\n\r\n");

        if (!listMethods.getJavaCode().contains(tmp.getJavaCode()))
        {
          listMethods.addJavaCode(tmp.getJavaCode());
        }

      }

    }
View Full Code Here


    return false;
  }

  private static CodeChunk[] generateMasterDetailsReference(Bean bean, String sourceDir, String basePackage) throws Exception
  {
    CodeChunk ret[] = new CodeChunk[2];
    ret[0] = new CodeChunk(0);
    ret[1] = new CodeChunk(0);

    Vector<Relationship> relationships = bean.getRelationships();

    for (Relationship relationship : relationships)
    {
View Full Code Here

    {
      Attribute attribute = bean.getAttributes().get(i);

      if (!attribute.isKey() && (attribute.getImplementationType() != AttributeImplementationType.HIDEINFORM))
      {
        CodeChunk codeChunk = new CodeChunk(attribute.getOrderInForm());

        codeChunk.addHtmlCode("\t<tr><td width=\"100%\">\r\n");

        codeChunk.addHtmlCode("\t\t<rich:panel rendered=\"#{");

        codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE'");
        if (!attribute.getOnCreateIf().equals(""))
          codeChunk.addHtmlCode(" and " + attribute.getOnCreateIf());
        codeChunk.addHtmlCode(")");

        codeChunk.addHtmlCode(" or ");

        codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'");
        if (!attribute.getOnEditIf().equals(""))
          codeChunk.addHtmlCode(" and " + attribute.getOnEditIf());
        codeChunk.addHtmlCode(")");

        codeChunk.addHtmlCode(" or ");

        codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
        if (!attribute.getOnDisplayIf().equals(""))
          codeChunk.addHtmlCode(" and " + attribute.getOnDisplayIf());
        codeChunk.addHtmlCode(")");

        codeChunk.addHtmlCode(" or ");

        codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
        if (!attribute.getOnDeleteIf().equals(""))
          codeChunk.addHtmlCode(" and " + attribute.getOnDeleteIf());
        codeChunk.addHtmlCode(")");

        codeChunk.addHtmlCode("}\" >\r\n");

        codeChunk.addHtmlCode("\t\t\t<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n");
        codeChunk.addHtmlCode("\t\t\t<tr>\r\n");
        codeChunk.addHtmlCode("\t\t\t<td class=\"formFieldLabel\" >\r\n");
        codeChunk.addHtmlCode("\t\t\t\t<h:outputLabel for=\"" + attribute.getName() + "\"  value=\"#{msgs.form_" + bean.getName() + attribute.SeamLabel() + "}\" />\r\n");
        codeChunk.addHtmlCode("\t\t\t</td>\r\n");

        codeChunk.addHtmlCode("\t\t\t<td width=\"1%\">\r\n");
        if (attribute.isRequired())
          codeChunk.addHtmlCode("\t\t\t\t<h:outputText value=\"*\"  rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" style=\"color: red; font-weight: bold;\" />\r\n");
        codeChunk.addHtmlCode("\t\t\t</td>\r\n");

        if (attribute.getImplementationType() == AttributeImplementationType.TEXTAREA || attribute.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
        {
          if (attribute.getType().equals("java.lang.String"))
          {
            codeChunk.addHtmlCode("\t\t\t<td>\r\n");
            codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true));
            codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\"   value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");

            codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
            if (!attribute.getOnDisplayIf().equals(""))
              codeChunk.addHtmlCode(" and " + attribute.getOnDisplayIf());
            codeChunk.addHtmlCode(")");

            codeChunk.addHtmlCode(" or ");

            codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
            if (!attribute.getOnDeleteIf().equals(""))
              codeChunk.addHtmlCode(" and " + attribute.getOnDeleteIf());
            codeChunk.addHtmlCode(")");

            codeChunk.addHtmlCode("}\" ");

            if (attribute.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
            {
              if (!textAreaIds.equals(""))
                textAreaIds += ",";
              textAreaIds += "form:" + attribute.getName() + "";

              codeChunk.addHtmlCode(" escape=\"false\" ");
            }

            codeChunk.addHtmlCode("/>\r\n");

            codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");

            codeChunk.addHtmlCode("\t\t\t</td>\r\n");
          }
        }

        if (attribute.getImplementationType() == AttributeImplementationType.LISTBOX)
        {
          codeChunk.addHtmlCode("\t\t\t<td>\r\n");

          codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true));
          /**         
                    codeChunk.addHtmlCode("\t\t\t\t<h:selectOneMenu id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}\" styleClass=\"formField\" ");

                    codeChunk.addHtmlCode(" required=\"#{" + attribute.isRequired() + " and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!=\'DELETE\'}\"");

                    codeChunk.addHtmlCode(" rendered=\"#{");

                    codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE'");
                    if (!attribute.getOnCreateIf().equals(""))
                      codeChunk.addHtmlCode(" and " + attribute.getOnCreateIf());
                    codeChunk.addHtmlCode(")");

                    codeChunk.addHtmlCode(" or ");

                    codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'");
                    if (!attribute.getOnEditIf().equals(""))
                      codeChunk.addHtmlCode(" and " + attribute.getOnEditIf());
                    codeChunk.addHtmlCode(")");

                    codeChunk.addHtmlCode("}\" >\r\n");

                    codeChunk.addHtmlCode("\t\t\t\t\t<f:selectItem itemValue=\"\"  itemLabel=\"#{msgs.Application_noSelectionLabel}\" />\r\n");

                    for (String option : attribute.getLabels())
                    {
                      codeChunk.addHtmlCode("\t\t\t\t\t<f:selectItem itemValue=\"" + option + "\"  itemLabel=\"" + option + "\"/>\r\n");
                    }

                   
                    if (!attribute.getAjaxEvent().equals(""))
                    {
                      codeChunk.addHtmlCode("\t\t\t\t\t"+addAjaxSupport(attribute.getAjaxEvent(), attribute.getIdsToRerenderOnAjaxEvent())+"\r\n");
                    }
                   
                    codeChunk.addHtmlCode("\t\t\t\t</h:selectOneMenu>\r\n");
          **/
          codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\"  value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");

          codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
          if (!attribute.getOnDisplayIf().equals(""))
            codeChunk.addHtmlCode(" and " + attribute.getOnDisplayIf());
          codeChunk.addHtmlCode(")");

          codeChunk.addHtmlCode(" or ");

          codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
          if (!attribute.getOnDeleteIf().equals(""))
            codeChunk.addHtmlCode(" and " + attribute.getOnDeleteIf());
          codeChunk.addHtmlCode(")");

          codeChunk.addHtmlCode("}\" ");

          codeChunk.addHtmlCode("/>\r\n");

          codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
          codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");

          codeChunk.addHtmlCode("\t\t\t</td>\r\n");
        }

        if (attribute.getImplementationType() == AttributeImplementationType.TEXT)
        {
          if (attribute.getType().equals("java.lang.Boolean"))
          {
            codeChunk.addHtmlCode("\t\t\t<td>\r\n");
            codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");

            codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");

            codeChunk.addHtmlCode("\t\t\t</td>\r\n");
          }

          if (attribute.getType().equals("java.lang.String"))
          {
            codeChunk.addHtmlCode("\t\t\t<td>\r\n");
            codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\"  value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");

            codeChunk.addHtmlCode(" or ");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");

            codeChunk.addHtmlCode("}\" ");

            codeChunk.addHtmlCode("/>\r\n");

            codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");

            codeChunk.addHtmlCode("\t\t\t</td>\r\n");
          }

          if (attribute.getType().equals("java.util.Date"))
          {
            codeChunk.addHtmlCode("\t\t\t<td>\r\n");

            codeChunk.addHtmlCode("\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");

            codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\"   value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");

            codeChunk.addHtmlCode(" or ");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");

            codeChunk.addHtmlCode("}\" ");

            codeChunk.addHtmlCode(">\r\n");

            if (!attribute.isFormFormatOff())
              codeChunk.addHtmlCode("\t\t\t\t\t<s:convertDateTime pattern=\"#{msgs.Application_DateFormat}\"/>\r\n");

            codeChunk.addHtmlCode("\t\t\t\t</h:outputText>\r\n");

            codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");

            codeChunk.addHtmlCode("\t\t\t</td>\r\n");
          }

          if (attribute.getType().equals("java.lang.Double"))
          {
            codeChunk.addHtmlCode("\t\t\t<td>\r\n");
            codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\"  value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");

            codeChunk.addHtmlCode(" or ");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");

            codeChunk.addHtmlCode("}\" ");

            codeChunk.addHtmlCode(">\r\n");

            codeChunk.addHtmlCode("\t\t\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n");

            codeChunk.addHtmlCode("\t\t\t\t</h:outputText>\r\n");

            codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");

            codeChunk.addHtmlCode("\t\t\t</td>\r\n");
          }

          if (attribute.getType().equals("java.lang.Long"))
          {
            codeChunk.addHtmlCode("\t\t\t<td>\r\n");
            codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\"  value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");

            codeChunk.addHtmlCode(" or ");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");

            codeChunk.addHtmlCode("}\" ");

            codeChunk.addHtmlCode(">\r\n");

            if (!attribute.isFormFormatOff())
              codeChunk.addHtmlCode("\t\t\t\t<f:converter converterId=\"LongConverter\"/>\r\n");

            codeChunk.addHtmlCode("\t\t\t\t\t</h:outputText>\r\n");

            codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");

            codeChunk.addHtmlCode("\t\t\t</td>\r\n");
          }

          if (attribute.getType().equals("java.lang.Integer"))
          {
            codeChunk.addHtmlCode("\t\t\t<td>\r\n");
            codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\"  value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");

            codeChunk.addHtmlCode(" or ");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");

            codeChunk.addHtmlCode("}\" ");

            codeChunk.addHtmlCode(">\r\n");

            if (!attribute.isFormFormatOff())
              codeChunk.addHtmlCode("\t\t\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n");

            codeChunk.addHtmlCode("\t\t\t\t</h:outputText>\r\n");

            codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");

            codeChunk.addHtmlCode("\t\t\t</td>\r\n");
          }

          if (attribute.getType().contains("UploadedFile") || attribute.getType().contains("org.boco.seamUtility.upload.UploadedFile"))
          {
            /**
             * Gestione degli upload / download dal form
             */
            usesUpload = "enctype=\"multipart/form-data\"";

            if (bean.getRelationship(Utils.makeGet(bean.getName() + "Upload")) == null)
            {
              // Piu' allegati

              codeChunk.addHtmlCode("\t\t\t<td>\r\n");

              codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");

              codeChunk.addHtmlCode("\t\t\t\t<h:dataTable var=\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload\"  value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Uploads}\" >\r\n");

              codeChunk.addHtmlCode("\t\t\t\t<h:column>\r\n");

              codeChunk.addHtmlCode("\t\t\t\t\t<h:commandButton action=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + Utils.makeFirstLetterLowerCase(attribute.getName()) + "Fm.downloadFile(facesContext)}\" image=\"img/download.png\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null) and (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + Utils.makeFirstLetterLowerCase(attribute.getName()) + "Fm!=null) and ((" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'))}\" />\r\n");
              codeChunk.addHtmlCode("\t\t\t\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + Utils.makeFirstLetterLowerCase(attribute.getName()) + "Fm.fileName}\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + Utils.makeFirstLetterLowerCase(attribute.getName()) + "Fm!=null}\" />\r\n");
              codeChunk.addHtmlCode("\t\t\t\t\t<h:outputLabel for=\"delete" + Utils.makeFirstLetterLowerCase(attribute.getName()) + "\" value=\"Rimuovi\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");
              codeChunk.addHtmlCode("\t\t\t\t\t<h:selectBooleanCheckbox for=\"delete" + Utils.makeFirstLetterLowerCase(attribute.getName()) + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + Utils.makeFirstLetterLowerCase(attribute.getName()) + "Fm.checkDelete}\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");
              codeChunk.addHtmlCode("\t\t\t\t\t<h:outputLabel for=\"update" + Utils.makeFirstLetterLowerCase(attribute.getName()) + "\" value=\"Sostituisci\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");
              codeChunk.addHtmlCode("\t\t\t\t\t<h:selectBooleanCheckbox for=\"update" + Utils.makeFirstLetterLowerCase(attribute.getName()) + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + Utils.makeFirstLetterLowerCase(attribute.getName()) + "Fm.checkUpdate}\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");

              codeChunk.addHtmlCode("\t\t\t\t</h:column>\r\n");

              codeChunk.addHtmlCode("\t\t\t\t</h:dataTable>\r\n");

              codeChunk.addHtmlCode("\t\t\t</td>\r\n");
            }
            else
            {
              // Un solo allegato

              codeChunk.addHtmlCode("\t\t\t<td>\r\n");

              codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");

              codeChunk.addHtmlCode("\t\t\t\t<h:commandButton action=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + attribute.getName() + "Fm.downloadFile(facesContext)}\" image=\"img/download.png\" rendered=\"#{");

              codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null) and (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + attribute.getName() + "Fm!=null) and ((" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
              if (!attribute.getOnDisplayIf().equals(""))
                codeChunk.addHtmlCode(" and " + attribute.getOnDisplayIf());
              codeChunk.addHtmlCode(")");

              codeChunk.addHtmlCode(" or ");

              codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
              if (!attribute.getOnDeleteIf().equals(""))
                codeChunk.addHtmlCode(" and " + attribute.getOnDeleteIf());
              codeChunk.addHtmlCode("))");

              codeChunk.addHtmlCode("}\" ");

              codeChunk.addHtmlCode("/>\r\n");

              codeChunk.addHtmlCode("\t\t\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + attribute.getName() + "Fm.fileName}\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + attribute.getName() + "Fm!=null}\" />\r\n");

              codeChunk.addHtmlCode("\t\t\t\t<h:outputLabel for=\"delete" + attribute.getName() + "\" value=\"Rimuovere\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");
              codeChunk.addHtmlCode("\t\t\t\t<h:selectBooleanCheckbox for=\"delete" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + attribute.getName() + "Fm.checkDelete}\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");

              codeChunk.addHtmlCode("\t\t\t</td>\r\n");
            }
          }
        }

        /** Campi di sola visualizzazione * */

        if (attribute.getImplementationType() == AttributeImplementationType.READONLY)
        {
          if (attribute.getType().equals("java.lang.String"))
          {
            codeChunk.addHtmlCode("\t<td>\r\n");
            codeChunk.addHtmlCode("\t\t<tr:outputText id=\"" + attribute.getName() + "\"   value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" />\r\n");
            codeChunk.addHtmlCode("\t</td>\r\n");
          }

          if (attribute.getType().equals("java.util.Date"))
          {
            codeChunk.addHtmlCode("\t<trh:cellFormat >\r\n");

            codeChunk.addHtmlCode("\t\t<tr:outputText id=\"" + attribute.getName() + "\"   value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" >\r\n");

            codeChunk.addHtmlCode("\t\t\t<f:convertDateTime pattern=\"#{msgs.Application_DateFormat}\" />\r\n");

            codeChunk.addHtmlCode("\t\t</tr:outputText>\r\n");

            codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
          }
          if (attribute.getType().equals("java.lang.Integer"))
          {
            codeChunk.addHtmlCode("\t<trh:cellFormat >\r\n");

            codeChunk.addHtmlCode("\t\t<tr:outputText id=\"" + attribute.getName() + "\"   value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" >\r\n");

            codeChunk.addHtmlCode("\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n");

            codeChunk.addHtmlCode("\t\t</tr:outputText>\r\n");

            codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
          }
          if (attribute.getType().equals("java.lang.Long"))
          {
            codeChunk.addHtmlCode("\t<trh:cellFormat >\r\n");

            codeChunk.addHtmlCode("\t\t<tr:outputText id=\"" + attribute.getName() + "\"   value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" >\r\n");

            codeChunk.addHtmlCode("\t\t\t<f:converter converterId=\"LongConverter\" />\r\n");

            codeChunk.addHtmlCode("\t\t</tr:outputText>\r\n");

            codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
          }
          if (attribute.getType().equals("java.lang.Double"))
          {
            codeChunk.addHtmlCode("\t<trh:cellFormat >\r\n");

            codeChunk.addHtmlCode("\t\t<tr:outputText id=\"" + attribute.getName() + "\"   value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" >\r\n");

            codeChunk.addHtmlCode("\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n");

            codeChunk.addHtmlCode("\t\t</tr:outputText>\r\n");

            codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
          }
        }

        if (attribute.isHelp())
        {
          codeChunk.addHtmlCode("\t\t\t<td width=\"1%\"><h:graphicImage styleClass=\"imageLink\" url=\"img/info.gif\" onclick=\"help('help/form_" + bean.getName() + "_" + attribute.getName() + ".html');\" /></td>\r\n");
        }
        else
        {
          codeChunk.addHtmlCode("\t\t\t<td width=\"1%\"></td>\r\n");
        }

        codeChunk.addHtmlCode("\t\t\t</tr>\r\n");
        codeChunk.addHtmlCode("\t\t\t</table>\r\n");
        codeChunk.addHtmlCode("\t\t</rich:panel>\r\n");
        codeChunk.addHtmlCode("\t</td></tr>\r\n");

        codeChunks.add(codeChunk);
      }
    }

    // Inserisce gli attributi provenienti da relazioni che debbono essere
    // solo visualizzati
    for (int i = 0; i < bean.getShowInFormAttributes().size(); i++)
    {
      ShowAttribute attribute = bean.getShowInFormAttributes().get(i);

      CodeChunk codeChunk = new CodeChunk(attribute.getOrderInForm());

      if (attribute.getRelationship() != null && attribute.getRelationship().isToMany())
      {
        codeChunk.addHtmlCode("\r\n@ShowRelationshipAttributesInForm - Relazione :N non supportata - " + attribute.getRelationship().getName() + "\r\n");
      }
      else
      {
        codeChunk.addHtmlCode("\r\n\t<tr><td width=\"100%\">\r\n");

        if (!attribute.getOnCreateIf().equals("") || !attribute.getOnEditIf().equals("") || !attribute.getOnDisplayIf().equals("") || !attribute.getOnDeleteIf().equals(""))
        {
          codeChunk.addHtmlCode("\t\t<rich:panel width=\"100%\" rendered=\"#{");
          codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE'");
          if (!attribute.getOnCreateIf().equals(""))
            codeChunk.addHtmlCode(" and " + attribute.getOnCreateIf());
          codeChunk.addHtmlCode(")");

          codeChunk.addHtmlCode(" or ");

          codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'");
          if (!attribute.getOnEditIf().equals(""))
            codeChunk.addHtmlCode(" and " + attribute.getOnEditIf());
          codeChunk.addHtmlCode(")");

          codeChunk.addHtmlCode(" or ");

          codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
          if (!attribute.getOnDisplayIf().equals(""))
            codeChunk.addHtmlCode(" and " + attribute.getOnDisplayIf());
          codeChunk.addHtmlCode(")");

          codeChunk.addHtmlCode(" or ");

          codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
          if (!attribute.getOnDeleteIf().equals(""))
            codeChunk.addHtmlCode(" and " + attribute.getOnDeleteIf());
          codeChunk.addHtmlCode(")");
          codeChunk.addHtmlCode("}\" >\r\n");
        }
        else
        {
          codeChunk.addHtmlCode("\t<rich:panel>\r\n");
        }

        codeChunk.addHtmlCode("\t\t<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n");

        codeChunk.addHtmlCode("\t\t<tr>\r\n");

        codeChunk.addHtmlCode("\t\t<td class=\"formFieldLabel\" >\r\n");
        codeChunk.addHtmlCode("\t\t\t<h:outputLabel value=\"#{msgs.form_" + bean.getName() + "_" + attribute.getQualifiedName().replace(".", "_") + "}\" />\r\n");
        codeChunk.addHtmlCode("\t\t</td>\r\n");

        codeChunk.addHtmlCode("\t\t<td width=\"1%\"></td>\r\n");

        codeChunk.addHtmlCode("\t\t<td>\r\n");
        codeChunk.addHtmlCode("\t\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getQualifiedName() + "}\" />\r\n");
        codeChunk.addHtmlCode("\t\t</td>\r\n");

        codeChunk.addHtmlCode("\t\t</tr>\r\n");

        codeChunk.addHtmlCode("\t\t</table>\r\n");

        codeChunk.addHtmlCode("\t\t</rich:panel>\r\n");
        codeChunk.addHtmlCode("\t</td></tr>\r\n");
      }

      codeChunks.add(codeChunk);
    }

    // Inserisce gli attributi provenienti da relazioni
    for (int i = 0; i < bean.getRelationships().size(); i++)
    {
      Relationship rel = bean.getRelationships().get(i);

      if (rel.isUsed() && !rel.isMasterDetail())
      {
        CodeChunk codeChunk = null;

        //if ( infoReader.BeanCrudInPopUp(rel.getToBeanName()) )
        if (!rel.isListBox() && rel.isCRUD())
        {
          dynamicMenus += "<a4j:region>\r\n";
          dynamicMenus += "<rich:contextMenu attached=\"false\" id=\"menu" + rel.getName() + "\" submitMode=\"ajax\" >\r\n";

          dynamicMenus += "\t<rich:menuItem ajaxSingle=\"true\" value=\"#{msgs.list_" + rel.getToBeanName() + "_display}\" actionListener=\"#{" + rel.getToBeanName() + "Manager.popupMenuSelectItem}\" requestDelay=\"0\" oncomplete=\"openCrudPopUp_" + rel.getName() + "('Display');\">\r\n";
          dynamicMenus += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
          dynamicMenus += "\t</rich:menuItem>\r\n\r\n";

          if (rel.getPopUpEdit())
          {
            dynamicMenus += "\t<rich:menuItem ajaxSingle=\"true\" value=\"#{msgs.list_" + rel.getToBeanName() + "_edit}\" actionListener=\"#{" + rel.getToBeanName() + "Manager.popupMenuSelectItem}\" requestDelay=\"0\" oncomplete=\"openCrudPopUp_" + rel.getName() + "('Edit');\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT')}\" >\r\n";
            dynamicMenus += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
            dynamicMenus += "\t</rich:menuItem>\r\n\r\n";
          }

          if (rel.getPopUpDelete())
          {
            dynamicMenus += "\t<rich:menuItem ajaxSingle=\"true\" value=\"#{msgs.list_" + rel.getToBeanName() + "_delete}\" actionListener=\"#{" + rel.getToBeanName() + "Manager.popupMenuSelectItem}\" requestDelay=\"0\" oncomplete=\"openCrudPopUp_" + rel.getName() + "('Delete');\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT')}\" >\r\n";
            dynamicMenus += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
            dynamicMenus += "\t</rich:menuItem>\r\n\r\n";
          }

          dynamicMenus += "</rich:contextMenu>\r\n";
          dynamicMenus += "</a4j:region>\r\n";
        }

        if (!rel.isToMany())
        {
          // Relazione :1
          if (rel.isListBox())
          {
            // Relazione :1 implementata come ListBox
            codeChunk = insertSingleSelectionListBox2Form(sourceDir, bean, rel, true, false);
          }
          else
          {
            // Relazione :1 implementata come PopUp
            codeChunk = insertSingleSelectionPopUp2Form(sourceDir, bean, rel, inPopUp);
            if (rel.isRequired())
              updatePopUpRelationships += "\tupdatePopUpRelationships(\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + rel.getName() + "\");\r\n";
            else
              updatePopUpRelationships += "";
          }
        }
        else
        {
          // Relazione :N
          if (rel.isListBox())
          {
            // Relazione :N implementata come ListBox
            codeChunk = insertMultipleSelectionListBox2Form(bean, rel, true, false);
          }
          else
          {
            // Relazione :N implementata come PopUp
            codeChunk = insertMultipleSelectionPopUp2Form(sourceDir, bean, rel, inPopUp);
            if (rel.isRequired())
              updatePopUpRelationships += "\tupdatePopUpRelationships(\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + rel.getName() + "\");\r\n";
            else
              updatePopUpRelationships += "";
          }
        }

        codeChunk.setOrder(rel.getOrderInForm());
        codeChunks.add(codeChunk);
      }

      /** Relazioni master-detail in cui nel detail viene inserito anche una popup per la gestione del master **/
      if (rel.isUsed() && rel.isMasterDetail() && rel.getOrderInForm() != 0)
      {
        CodeChunk codeChunk = null;

        if (!rel.isToMany())
        {
          // Relazione :1 implementata come PopUp
          codeChunk = insertSingleSelectionPopUp2Form(sourceDir, bean, rel, inPopUp);
          if (rel.isRequired())
            updatePopUpRelationships += "\tupdatePopUpRelationships(\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + rel.getName() + "\");\r\n";
          else
            updatePopUpRelationships += "";
        }
        else
        {
          // Relazione :N implementata come PopUp
          codeChunk = insertMultipleSelectionPopUp2Form(sourceDir, bean, rel, inPopUp);
          if (rel.isRequired())
            updatePopUpRelationships += "\tupdatePopUpRelationships(\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + rel.getName() + "\");\r\n";
          else
            updatePopUpRelationships += "";
        }

        codeChunk.setOrder(rel.getOrderInForm());
        codeChunks.add(codeChunk);
      }

    }

    /** Predispone i Manager necessari per le chiamate remoting * */
    relatedManagers += bean.getName() + "Manager";

    for (int i = 0; i < bean.getRelationships().size(); i++)
    {
      Relationship rel = bean.getRelationships().get(i);

      if (rel.isUsed())
      {
        relatedManagers += "&" + rel.getToBeanName() + "Manager";
      }
    }

    /** Ordinamento dei chunck  **/

    CodeChunk chunks[] = codeChunks.toArray(new CodeChunk[0]);

    Arrays.sort(chunks, new CodeChunkComparator());

    //    for (int i = 0; i < chunks.length; i++)
    //    {
    //      javaScript += chunks[i].getJavascriptCode();
    //      rows += chunks[i].getHtmlCode();
    //    }

    Vector<CodeChunk> chunkVector = new Vector<CodeChunk>(java.util.Arrays.asList(chunks));

    /** Generazione dei grouppi di attributi **/
    for (int i = 0; i < bean.getFormFieldsGroups().size(); i++)
    {
      FormFieldsGroup group = bean.getFormFieldsGroups().get(i);

      CodeChunk start = new CodeChunk(group.getFromFieldOrder());
      start.addHtmlCode("\r\n\r\n<!-- START GROUP: " + group.getTitle() + "  -->\r\n");
      start.addHtmlCode("<rich:panel header=\"" + group.getTitle() + "\" rendered=\"#{");

      start.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE'");
      if (!group.getShowOnCreateIf().equals(""))
        start.addHtmlCode(" and " + group.getShowOnCreateIf());
      start.addHtmlCode(")");

      start.addHtmlCode(" or ");

      start.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'");
      if (!group.getShowOnEditIf().equals(""))
        start.addHtmlCode(" and " + group.getShowOnEditIf());
      start.addHtmlCode(")");

      start.addHtmlCode(" or ");

      start.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
      if (!group.getShowOnDisplayIf().equals(""))
        start.addHtmlCode(" and " + group.getShowOnDisplayIf());
      start.addHtmlCode(")");

      start.addHtmlCode(" or ");

      start.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
      if (!group.getShowOnDeleteIf().equals(""))
        start.addHtmlCode(" and " + group.getShowOnDeleteIf());
      start.addHtmlCode(")");

      start.addHtmlCode("}\" >\r\n\r\n");
      start.addHtmlCode("<table width=\"100%\">\r\n");

      int idx = getChunkIndex(chunkVector, start);

      chunkVector.add(idx, start);

      CodeChunk end = new CodeChunk(group.getToFieldOrder());

      end.addHtmlCode("</table>\r\n");
      end.addHtmlCode("\r\n\r\n</rich:panel>\r\n");
      //end.addHtmlCode("<tr:spacer height=\"25\" />\r\n");
      end.addHtmlCode("<!-- END GROUP: " + group.getTitle() + "  -->\r\n\r\n");

      idx = getChunkIndex(chunkVector, end);

      chunkVector.add(idx + 1, end);
    }
View Full Code Here

  /**
   * Genera un list box a selezione singola
   */
  private static CodeChunk insertSingleSelectionListBox2Form(String sourceDir, Bean bean, Relationship rel, boolean visible, boolean alwaysRendered)
  {
    CodeChunk ret = new CodeChunk(0);
    String disabledCondition = "";

    if (!visible)
    {
      if (rel.isOptions())
        ret.addHtmlCode("\t\t<tr:selectOneRadio id=\"" + rel.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" style=\"display:none;\" ");
      else
        ret.addHtmlCode("\t\t<h:selectOneMenu id=\"" + rel.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" style=\"display:none;\" ");

      if (!alwaysRendered)
      {
        ret.addHtmlCode(" rendered=\"#{" + bean.getName() + "Manager.getCallingBeanName().contains('" + bean.getName() + "')}\" ");
      }

      ret.addHtmlCode(" >\r\n");

      if (rel.isOptions() && !rel.isRequired())
        ret.addHtmlCode("\t\t\t<f:selectItem itemLabel=\"Nessuno\"/>\r\n");

      ret.addHtmlCode("\t\t\t<s:selectItems value=\"#{" + rel.getToBeanName() + "Manager.getSelectionItems(true," + Utils.makeFirstLetterLowerCase(bean.getName()) + ",'" + rel.getName() + "')}\" var=\"" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "\" ");

      ret.addHtmlCode("label=\"");

      for (int i = 0; i < rel.getRelatedAttributes().size(); i++)
      {
        if (i > 0)
          ret.addHtmlCode(" - ");

        ret.addHtmlCode("#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "." + rel.getRelatedAttributes().get(i).getName() + "}");
      }

      ret.addHtmlCode("\"");

      ret.addHtmlCode(" noSelectionLabel=\"Selezionare...\" hideNoSelectionLabel=\"true\" />\r\n");
      ret.addHtmlCode("\t\t\t\t\t<s:convertEntity />\r\n");

      if (rel.isOptions())
        ret.addHtmlCode("\t\t</tr:selectOneRadio>\r\n");
      else
        ret.addHtmlCode("\t\t</h:selectOneMenu>\r\n");

      return ret;
    }

    ret.addHtmlCode("\r\n");
    ret.addHtmlCode("\t<tr><td width=\"100%\">\r\n");
    ret.addHtmlCode("\t\t<rich:panel rendered=\"#{");

    /** Gestione della visibilita': showOnEditIf ...  **/

    if (alwaysRendered)
    {
      ret.addHtmlCode("true");
    }
    else
    {
      ret.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE'");
      if (!rel.getShowOnCreateIf().equals(""))
        ret.addHtmlCode(" and " + rel.getShowOnCreateIf());
      ret.addHtmlCode(")");

      ret.addHtmlCode(" or ");

      ret.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'");
      if (!rel.getShowOnEditIf().equals(""))
        ret.addHtmlCode(" and " + rel.getShowOnEditIf());
      ret.addHtmlCode(")");

      ret.addHtmlCode(" or ");

      ret.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
      if (!rel.getShowOnDisplayIf().equals(""))
        ret.addHtmlCode(" and " + rel.getShowOnDisplayIf());
      ret.addHtmlCode(")");

      ret.addHtmlCode(" or ");

      ret.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
      if (!rel.getShowOnDeleteIf().equals(""))
        ret.addHtmlCode(" and " + rel.getShowOnDeleteIf());
      ret.addHtmlCode(")");
    }

    if (!rel.getDisableOnCreateIf().equals(""))
    {
      disabledCondition += "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE' and (" + rel.getDisableOnCreateIf() + "))";
    }

    if (!rel.getDisableOnEditIf().equals(""))
    {
      if (!disabledCondition.equals(""))
        disabledCondition += " or ";

      disabledCondition += "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT' and (" + rel.getDisableOnEditIf() + "))";
    }

    if (!disabledCondition.equals(""))
      disabledCondition = " disabled=\"#{" + disabledCondition + "}\" ";

    ret.addHtmlCode("}\"" + disabledCondition + ">\r\n");

    ret.addHtmlCode("\t\t\t<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n");

    ret.addHtmlCode("\t\t\t<tr>\r\n");
    ret.addHtmlCode("\t\t\t<td  class=\"formFieldLabel\">\r\n");
    ret.addHtmlCode("\t\t\t\t<h:outputLabel for=\"" + rel.getName() + "\" value=\"#{msgs.form_" + rel.ToSeamLabel() + "}\" />\r\n");
    ret.addHtmlCode("\t\t\t</td>\r\n");

    ret.addHtmlCode("\t\t\t<td width=\"1%\">\r\n");

    if (rel.isRequired())
      ret.addHtmlCode("\t\t\t\t<h:outputText value=\"*\"  rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" style=\"color: red; font-weight: bold;\" />\r\n");

    ret.addHtmlCode("\t\t\t</td>\r\n");

    ret.addHtmlCode("\t\t\t<td>\r\n");

    if (!rel.getAjaxEvent().equals(""))
    {
      ret.addHtmlCode("<a4j:region>\r\n");
    }

    if (rel.isOptions())
      ret.addHtmlCode("\t\t\t\t<h:selectOneRadio  required=\"#{" + rel.isRequired() + " and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" id=\"" + rel.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" ");
    else
      ret.addHtmlCode("\t\t\t\t<h:selectOneMenu  required=\"#{" + rel.isRequired() + " and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" id=\"" + rel.getName() + "\" styleClass=\"formField\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" ");

    if (!alwaysRendered)
    {
      ret.addHtmlCode(" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DISPLAY' and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" ");
    }

    // Inserisce gli eventuali eventi presenti
    Vector<String> events = rel.getEvents();
    Vector<String> eventFunctions = rel.getEventFunctions();

    for (int i = 0; i < events.size(); i++)
    {
      ret.addHtmlCode(events.get(i) + "=" + "\"" + eventFunctions.get(i) + "\"");
    }

    if (rel.isFreeText())
    {
      // ret.addHtmlCode(" autoSubmit=\"true\" ");
    }

    ret.addHtmlCode(" >\r\n");

    ret.addHtmlCode("\t\t\t\t\t<s:selectItems value=\"#{" + rel.getToBeanName() + "Manager.getSelectionItems(true," + Utils.makeFirstLetterLowerCase(bean.getName()) + ",'" + rel.getName() + "')}\" var=\"" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "\" ");

    ret.addHtmlCode("label=\"");

    for (int i = 0; i < rel.getRelatedAttributes().size(); i++)
    {
      if (i > 0)
        ret.addHtmlCode(" - ");

      ret.addHtmlCode("#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "." + rel.getRelatedAttributes().get(i).getName() + "}");
    }

    ret.addHtmlCode("\"");

    if (rel.isOptions())
    {
      if (rel.isRequired())
        ret.addHtmlCode(" noSelectionLabel=\"#{msgs.Application_None}\" hideNoSelectionLabel=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");
      else
        ret.addHtmlCode(" noSelectionLabel=\"#{msgs.Application_None}\" />\r\n");
    }
    else
    {
      ret.addHtmlCode(" noSelectionLabel=\"#{msgs.Application_noSelectionLabel}\" hideNoSelectionLabel=\"false\" />\r\n");
    }

    ret.addHtmlCode("\t\t\t\t\t<s:convertEntity />\r\n");

    if (!rel.getAjaxEvent().equals(""))
    {
      //      String ids = "";
      //
      //      for (int i = 0; i < rel.getIdsToRerenderOnAjaxEvent().size(); i++)
      //      {
      //        if (i > 0)
      //          ids += ",";
      //
      //        ids += rel.getIdsToRerenderOnAjaxEvent().get(i);
      //      }
      //
      //      ret.addHtmlCode("\t\t\t\t\t<a4j:support event=\"" + rel.getAjaxEvent() + "\" reRender=\"" + ids + "\" limitToList=\"true\" />\r\n");
      //     
      ret.addHtmlCode("\t\t\t\t\t" + addAjaxSupport(rel.getAjaxEvent(), rel.getIdsToRerenderOnAjaxEvent()) + "\r\n");
    }

    if (rel.isFreeText())
    {
      ret.addHtmlCode("\t\t\t\t\t<a4j:support event=\"onchange\" reRender=\"" + rel.getName() + "_Text\" limitToList=\"true\" ajaxSingle=\"true\" />\r\n");
    }

    if (rel.isOptions())
      ret.addHtmlCode("\t\t\t\t</h:selectOneRadio>\r\n");
    else
      ret.addHtmlCode("\t\t\t\t</h:selectOneMenu>\r\n");

    if (rel.isFreeText())
    {
      // Aggiunge il campo di testo per l'inserimento di una opzione
      // aggiuntiva

      ret.addHtmlCode("\t\t<!-- FREE TEXT FIELD -->\r\n");
      ret.addHtmlCode("\t\t<h:inputText id=\"" + rel.getName() + "_Text\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + rel.getName() + Utils.makeFirstLetterUpperCase(rel.getRelatedAttributes().get(0).getName()) + "}\"  ");
      ret.addHtmlCode(" required=\"#{" + rel.isRequired() + " and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" ");
      ret.addHtmlCode(" disabled=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + ".");

      Properties prop = new Properties();
      try
      {
        prop.load(new FileInputStream(sourceDir + ".." + File.separator + "html" + File.separator + "WEB-INF" + File.separator + "classes" + File.separator + "messages.properties"));
      }
      catch (FileNotFoundException e)
      {
        e.printStackTrace();
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }

      ret.addHtmlCode(Utils.makeFirstLetterLowerCase(rel.getRelatedAttributes().get(0).getName()) + "!='" + prop.get("Application_other") + "'}\" ");

      ret.addHtmlCode(" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DISPLAY' and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" />\r\n");

      // Aggiunge il campo di testo per la visualizzazione dell'opzione
      // aggiuntiva

      ret.addHtmlCode("\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + rel.getName() + Utils.makeFirstLetterUpperCase(rel.getRelatedAttributes().get(0).getName()) + "}\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE') and (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + rel.getName() + Utils.makeFirstLetterUpperCase(rel.getRelatedAttributes().get(0).getName()) + "!=null)}\" />\r\n");
      ret.addHtmlCode("\t\t<h:outputText value=\"\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE') and (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + rel.getName() + Utils.makeFirstLetterUpperCase(rel.getRelatedAttributes().get(0).getName()) + "==null)}\" />\r\n");

      ret.addHtmlCode("\t\t<!-- FREE TEXT FIELD -->\r\n");
    }

    if (!rel.getAjaxEvent().equals(""))
    {
      ret.addHtmlCode("</a4j:region>\r\n");
    }

    if (!alwaysRendered)
    {
      ret.addHtmlCode("\t\t\t\t<h:outputText value=\"");

      for (int i = 0; i < rel.getRelatedAttributes().size(); i++)
      {
        if (i > 0)
          ret.addHtmlCode(" - ");

        ret.addHtmlCode("#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "." + rel.getRelatedAttributes().get(i).getName() + "}");
      }

      ret.addHtmlCode("\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE') and (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "!=null)}\" />\r\n");

      ret.addHtmlCode("\t\t\t\t<h:outputText value=\"\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE') and (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "==null)}\" />\r\n");
    }

    ret.addHtmlCode("\t\t\t\t<br />\r\n");
    ret.addHtmlCode("\t\t\t\t<h:message for=\"" + rel.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");

    ret.addHtmlCode("\t\t\t</td>\r\n");

    if (rel.isHelp())
    {
      ret.addHtmlCode("\t\t\t<td width=\"1%\"><h:graphicImage styleClass=\"imageLink\" url=\"img/info.gif\" onclick=\"help('help/form_" + bean.getName() + "_" + rel.getName() + ".html');\" /></td>\r\n");
    }
    else
    {
      ret.addHtmlCode("\t\t\t<td width=\"1%\"></td>\r\n");
    }

    ret.addHtmlCode("\t\t\t</tr>\r\n");
    ret.addHtmlCode("\t\t\t</table>\r\n");
    ret.addHtmlCode("\t\t</rich:panel>\r\n");
    ret.addHtmlCode("\t</td></tr>\r\n");

    return ret;
  }
View Full Code Here

TOP

Related Classes of org.boco.seamwebappgen.utils.CodeChunk

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.