return insertMultipleSelectionPopUp2Form(sourceDir, bean, rel, inPopUp, false);
}
private static CodeChunk insertMultipleSelectionPopUp2Form(String sourceDir, Bean bean, Relationship rel, boolean inPopUp, boolean alwaysRendered)
{
CodeChunk ret = new CodeChunk(0);
String disabledCondition = "";
if (!rel.isListBox() && !rel.isCRUD())
{
ret.addJavascriptCode("function openPopUp_" + rel.getName() + "()");
ret.JavascriptNewLine();
ret.addJavascriptCode("{");
ret.JavascriptNewLine();
if (inPopUp)
ret.addJavascriptCode("\twindow.open(\"popup/" + bean.getName() + rel.getName() + "PopUp.seam?callingBean=" + bean.getName() + "InPopUp&callingConversationId=\"+document.forms[\"form\"].elements['form:parentConversationId'].value+\"&conversationIsLongRunning=true\",\"" + rel.getToBeanName() + "Window\",\"resizable=yes,menubar=no,width=850,height=550,scrollbars=yes\");");
else
ret.addJavascriptCode("\twindow.open(\"popup/" + bean.getName() + rel.getName() + "PopUp.seam?callingBean=" + bean.getName() + "&callingConversationId=\"+document.forms[\"form\"].elements['form:parentConversationId'].value+\"&conversationIsLongRunning=true\",\"" + rel.getToBeanName() + "Window\",\"resizable=yes,menubar=no,width=850,height=550,scrollbars=yes\");");
ret.JavascriptNewLine();
ret.addJavascriptCode("}");
ret.JavascriptNewLine();
}
ret.addHtmlCode("\r\n<tr><td width=\"100%\">\r\n");
ret.addHtmlCode("\t<rich:panel");
/** Gestione della visibilita': showOnEditIf ... **/
if (!alwaysRendered)
{
ret.addHtmlCode(" rendered=\"#{");
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(")");
ret.addHtmlCode("}\"");
}
ret.addHtmlCode(">\r\n");
ret.addHtmlCode("\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\t<td class=\"formFieldLabel\"><h:outputLabel for=\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + Utils.makeFirstLetterLowerCase(rel.getName()) + "\" value=\"#{msgs.form_" + rel.ToSeamLabel() + "}\" /></td>\r\n");
ret.addHtmlCode("\t\t\t\t<td>\r\n");
if (!rel.isListBox() && rel.isCRUD())
{
ret.addHtmlCode("\t\t\t\t\t<s:link action=\"#{" + rel.getToBeanName() + "Manager.initCreateInPopUp}\" rendered=\"false\" />\r\n");
ret.addHtmlCode("\t\t\t\t\t<s:link action=\"#{" + rel.getToBeanName() + "Manager.initDisplayInPopUp}\" rendered=\"false\" />\r\n");
ret.addHtmlCode("\t\t\t\t\t<s:link action=\"#{" + rel.getToBeanName() + "Manager.initEditInPopUp}\" rendered=\"false\" />\r\n");
ret.addHtmlCode("\t\t\t\t\t<s:link action=\"#{" + rel.getToBeanName() + "Manager.initDeleteInPopUp}\" rendered=\"false\" />\r\n");
if (rel.getPopUpCreate())
{
// Inserisce il pulsante per la creazione della relazione
// Prima deve essere costrutita la condizione per la disabilitazione
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("\t\t\t\t\t<a4j:commandButton id=\"popup_New" + rel.getToBeanName() + "\" value=\"#{msgs.list_" + rel.getToBeanName() + "_new}\" onclick=\"openCrudPopUp_" + rel.getName() + "('Create');\" styleClass=\"formButton\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='SEARCH')}\" " + disabledCondition + " />\r\n");
}
ret.addJavascriptCode("function openCrudPopUp_" + rel.getName() + "(operation)\r\n");
ret.addJavascriptCode("{\r\n");
ret.addJavascriptCode("\twindow.open(\"" + bean.getName() + ".seam?conversationId=\"+document.forms[\"form\"].elements['form:parentConversationId'].value+\"&conversationIsLongRunning=true&actionMethod=" + bean.getName() + ".xhtml:" + rel.getToBeanName() + "Manager.init\"+operation+\"InPopUp&callingBean=" + bean.getName() + "&relationship=" + rel.getName() + "\",\"" + rel.getToBeanName() + "Window\",\"resizable=yes,menubar=no,width=850,height=550,scrollbars=yes\");\r\n");
ret.addJavascriptCode("}\r\n");
}
if (rel.isRequired())
{
ret.addHtmlCode("\t\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");
}
if (!rel.isCRUD())
ret.addHtmlCode("\t\t\t\t\t<a4j:commandButton id=\"popup_" + rel.getName() + "\" value=\"#{msgs.Application_buttonSelect}\" onclick=\"openPopUp_" + rel.getName() + "();\" styleClass=\"formButton\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='SEARCH')}\" />\r\n");
if (rel.isRequired())
{
ret.addHtmlCode("\t\t\t\t\t<h:inputText id=\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + Utils.makeFirstLetterLowerCase(rel.getName()) + "\" value=\"\" required=\"#{true and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" style=\"display:none;\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DISPLAY'}\" " + disabledCondition + " />\r\n");
ret.addHtmlCode("\t\t\t\t\t<h:message for=\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + Utils.makeFirstLetterLowerCase(rel.getName()) + "\" errorClass=\"rich-messages-label\" />\r\n");
}
ret.addHtmlCode("\t\t\t\t</td>\r\n");
ret.addHtmlCode("\t\t\t</tr>\r\n");
ret.addHtmlCode("\t\t\t<tr>\r\n");
ret.addHtmlCode("\t\t\t\t<td colspan=\"2\">\r\n");
ret.addHtmlCode("\t\t\t\t\t<rich:dataTable id=\"tab_" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + rel.getName() + "\" var=\"" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" width=\"100%\"\r\n");
if (!rel.isListBox() && rel.isCRUD())
{
ret.addHtmlCode("\t\t\t\t\tcolumnClasses=\"dataColumnCenterAlignment," + listColumnClasses(rel.getRelatedAttributes(), false) + "\"\r\n");
ret.addHtmlCode("\t\t\t\t\t>\r\n");
ret.addHtmlCode("<!-- POPUP MENU COLUMN -->\r\n");
ret.addHtmlCode("\t<rich:column width=\"1%\">\r\n");
ret.addHtmlCode("\t\t<f:facet name=\"header\"> </f:facet>\r\n");
ret.addHtmlCode("\t\t<h:panelGroup>\r\n");
ret.addHtmlCode("\t\t\t<h:graphicImage url=\"img/action.gif\" id=\"pic\" >\r\n");
ret.addHtmlCode("\t\t\t\t<rich:componentControl event=\"onclick\" for=\"menu" + rel.getName() + "\" operation=\"show\">\r\n");
ret.addHtmlCode("\t\t\t\t\t<f:param value=\"#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + ".id}\" name=\"selectedBean\"/>\r\n");
ret.addHtmlCode("\t\t\t\t</rich:componentControl>\r\n");
ret.addHtmlCode("\t\t\t</h:graphicImage>\r\n");
ret.addHtmlCode("\t\t</h:panelGroup>\r\n");
ret.addHtmlCode("\t</rich:column>\r\n");
ret.addHtmlCode("<!-- POPUP MENU COLUMN -->\r\n");
}
else
{
ret.addHtmlCode("\t\t\t\t\tcolumnClasses=\"" + listColumnClasses(rel.getRelatedAttributes(), false) + "\"\r\n");
ret.addHtmlCode("\t\t\t\t\t>\r\n");
}
for (int i = 0; i < rel.getRelatedAttributes().size(); i++)
{
ShowAttribute attr = rel.getRelatedAttributes().get(i);
ret.addHtmlCode("\t\t\t\t\t\t<rich:column");
ret.addHtmlCode(">\r\n");
ret.addHtmlCode("\t\t\t\t\t\t\t<f:facet name=\"header\">\r\n");
ret.addHtmlCode("\t\t\t\t\t\t\t\t<h:outputText value=\"#{msgs.form_" + bean.getName() + "_" + rel.getName());
for (int k = 0; k < attr.getRelationships().size(); k++)
{
ret.addHtmlCode("_");
ret.addHtmlCode(attr.getRelationships().get(k).getName());
}
ret.addHtmlCode("_" + attr.getName() + "");
ret.addHtmlCode("}\" />\r\n");
ret.addHtmlCode("\t\t\t\t\t\t\t</f:facet>\r\n");
if (attr.getRelationships().size() == 0)
{
ret.addHtmlCode("\t\t\t\t\t\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "." + attr.getName() + "}\"");
if (attr.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
ret.addHtmlCode(" escape=\"false\"");
ret.addHtmlCode(" >\r\n");
if (attr.getType().equals("java.util.Date"))
{
ret.addHtmlCode("\t\t\t\t\t\t\t\t<f:convertDateTime pattern=\"#{msgs.Application_DateFormat}\" />\r\n");
}
if (attr.getType().equals("java.lang.Double") && !attr.isListFormatOff())
{
ret.addHtmlCode("\t\t\t\t\t\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n");
}
if (attr.getType().equals("java.lang.Long") && !attr.isListFormatOff())
{
ret.addHtmlCode("\t\t\t\t\t\t\t\t<f:converter converterId=\"LongConverter\" />\r\n");
}
if (attr.getType().equals("java.lang.Integer") && !attr.isListFormatOff())
{
ret.addHtmlCode("\t\t\t\t\t\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n");
}
ret.addHtmlCode("\t\t\t\t\t\t\t</h:outputText >\r\n");
}
else
{
/**
*
* Attributo nella forma
*
* [relationship.]*Atribute
*
*/
if (!attribute2N(attr))
{
ret.addHtmlCode("\t\t\t\t\t\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + ".");
for (int k = 0; k < attr.getRelationships().size(); k++)
{
if (k > 0)
ret.addHtmlCode(".");
ret.addHtmlCode(Utils.makeMethod2Field(attr.getRelationships().get(k).getName()));
}
ret.addHtmlCode("." + attr.getName());
ret.addHtmlCode("}\"");
if (attr.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
ret.addHtmlCode(" escape=\"false\"");
ret.addHtmlCode(" >\r\n");
if (attr.getType().equals("java.util.Date"))
{
ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"#{msgs.Application_DateFormat}\" />\r\n");
}
if (attr.getType().equals("java.lang.Double") && !attr.isListFormatOff())
{
ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n");
}
if (attr.getType().equals("java.lang.Long") && !attr.isListFormatOff())
{
ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"LongConverter\" />\r\n");
}
if (attr.getType().equals("java.lang.Integer") && !attr.isListFormatOff())
{
ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n");
}
ret.addHtmlCode("\t\t\t\t\t\t</h:outputText>\r\n");
}
else
{
ret.addHtmlCode("\t\t\t\t<rich:dataTable verticalGridVisible=\"false\" horizontalGridVisible=\"true\" var=\"" + Utils.makeMethod2Field(attr.getRelationship().getName()) + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + ".");
for (int k = 0; k < attr.getRelationships().size(); k++)
{
if (k > 0)
ret.addHtmlCode(".");
ret.addHtmlCode(Utils.makeMethod2Field(attr.getRelationships().get(k).getName()));
}
ret.addHtmlCode("}\" >\r\n");
ret.addHtmlCode("\t\t\t\t\t<rich:column");
if (attr.getType().contains("Double") || attr.getType().contains("Integer") || attr.getType().contains("Long"))
{
ret.addHtmlCode(" align=\"right\" ");
}
if (attr.getType().contains("String"))
{
ret.addHtmlCode(" align=\"left\" ");
}
if (attr.getType().contains("Date") || attr.getType().contains("Boolean"))
{
ret.addHtmlCode(" align=\"center\" ");
}
// Celle senza bordi
ret.addHtmlCode(" style=\"background-color: transparent; border-left-style: none; border-right-style: none;\" >\r\n");
ret.addHtmlCode("\t\t\t\t\t\t<h:outputText value=\"#{" + Utils.makeMethod2Field(attr.getRelationship().getName()) + attr.SeamField() + "}\"");
if (attr.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
ret.addHtmlCode(" escape=\"false\"");
ret.addHtmlCode(" >\r\n");
if (attr.getType().equals("java.util.Date"))
{
ret.addHtmlCode("\t\t\t\t\t\t\t<f:converter converterId=\"#{msgs.Application_DateFormat}\" />\r\n");
}
if (attr.getType().equals("java.lang.Double"))
{
//ret.addHtmlCode("\t\t\t\t\t\t\t<f:convertNumber groupingUsed=\"true\" minFractionDigits=\"2\" maxFractionDigits=\"2\" locale=\"IT_it\" />\r\n");
ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n");
}
if (attr.getType().equals("java.lang.Long") && !attr.isListFormatOff())
{
ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"LongConverter\" />\r\n");
}
if (attr.getType().equals("java.lang.Integer") && !attr.isListFormatOff())
{
ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n");
}
ret.addHtmlCode("\t\t\t\t\t\t</h:outputText>\r\n");
ret.addHtmlCode("\t\t\t\t\t</rich:column>\r\n");
ret.addHtmlCode("\t\t\t\t</rich:dataTable>\r\n");
}
}
ret.addHtmlCode("\t\t\t\t\t\t</rich:column>\r\n");
}
ret.addHtmlCode("\t\t\t\t\t</rich:dataTable>\r\n");
ret.addHtmlCode("\t\t\t\t</td>\r\n");
ret.addHtmlCode("\t\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;
}