String textAreaIds = "";
String printButton = "";
String hiddenAttributes = "";
String dynamicMenus = "";
InfoReader infoReader = new InfoReader(sourceDir);
if (!inPopUp)
{
template = "." + File.separator + "templates" + File.separator + "Seam_Form.xhtml";
sourceForm = sourceDir + ".." + File.separator + "html" + File.separator + bean.getName() + ".xhtml";
targetForm = targetDir + "html" + File.separator + bean.getName() + ".xhtml";
}
else
{
template = "." + File.separator + "templates" + File.separator + "Seam_FormInPopUp.xhtml";
sourceForm = sourceDir + ".." + File.separator + "html" + File.separator + bean.getName() + "InPopUp.xhtml";
targetForm = targetDir + "html" + File.separator + bean.getName() + "InPopUp.xhtml";
}
Vector<CodeChunk> codeChunks = new Vector<CodeChunk>();
// Recupera il codice custom nella pagina
LinkedList<String> yourJavaScriptCode = Utils.getYourCode(sourceForm, CustomCodeType.JAVA);
LinkedList<String> yourCode = Utils.getYourCode(sourceForm, CustomCodeType.JSP);
/** Predispone la lista di tutti gli attributi da inserire nel form **/
/** I campi Transient sono gestiti in questa sezione **/
for (int i = 0; i < bean.getAttributes().size(); i++)
{
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);
}
/** Finalmente scrive i chunk nel tag che viene sostituito nel template **/
for (int i = 0; i < chunkVector.size(); i++)
{
javaScript += chunkVector.get(i).getJavascriptCode();
rows += chunkVector.get(i).getHtmlCode();
}
/** Gestione dei campi FORMATTEDTEXTAREA **/
if (!textAreaIds.equals(""))
{
String HtmlEditorJavascriptTemplate = "." + File.separator + "templates" + File.separator + "HtmlEditorJavascript.js";
HashMap<String, String> tags = new HashMap<String, String>();
tags.put("@TextAreaIds", textAreaIds);
javascriptHtmlEditor = Utils.SeamReplaceTag2String(tags, null, null, HtmlEditorJavascriptTemplate);
}
if (bean.getPrintMenuConditionInForm().equals(""))
printButton = "\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.Application_print}\" action=\"/" + bean.getName() + "Print.seam\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='CREATE'}\" style=\"text-decoration: none; color: black\" />";
else
printButton = "\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.Application_print}\" action=\"/" + bean.getName() + "Print.seam\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='CREATE' and " + bean.getPrintMenuConditionInForm() + "}\" style=\"text-decoration: none; color: black\" />";
/** Gestione campi nascosti per CRUDInSeparatePopup **/
if (inPopUp)
{
Vector<Relationship> relationships2ThisBean = infoReader.getAllRelationship2ThisBean(bean.getName());
for (int r = 0; r < relationships2ThisBean.size(); r++)
{
Relationship rel = relationships2ThisBean.get(r);
Bean fromBean = infoReader.getBean(rel.getFromBeanName());
String tmp = generatePopUpJavascriptFunctionsInPopup(fromBean).replace("startup", "loadHiddenFields").replace("\tdocument.forms[\"form\"].elements[\"form:", "\tdocument.forms[\"form\"].elements[\"form:" + rel.getFromBeanName());
// tmp += "\r\n"+generatePopUpJavascriptFunctionsInPopup(fromBean).replace("startup", "loadHiddenFields");
if (javaScript.contains("loadHiddenFields"))