codeChunks.add(codeChunk);
}
else
{
// Attributo di ricerca appartenente ad una relazione
Relationship firstRelationship = attribute.getRelationship();
/**
* I campi della ricerca non sono mai required
*/
firstRelationship.setRequired(false);
if (attribute.getRelationships().size() == 1)
{
// L'attributo e' nella forma relazione.attributo
if (firstRelationship.isIgnoreImplementation())
{
// Gli attributi debbono essere inseriti come Text
if (attribute.getType().equals("java.util.Date"))
{
codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
codeChunk.addHtmlCode("\t<trh:cellFormat styleClass=\"formFieldLabel\" ><tr:outputLabel value=\"#{msgs.form_" + bean.getName() + "_search" + attribute.SeamLabel() + "}\" /></trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\t<trh:cellFormat>\r\n");
if (firstRelationship.isToMany())
{
/** Relazione :N **/
String singularRelationshipName = Utils.makeMethod2SingularField(firstRelationship.getName());
codeChunk.addHtmlCode("\t\t<rich:dataTable id=\"tab_" + singularRelationshipName + "_" + attribute.getName() + "\" var=\"" + singularRelationshipName + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(firstRelationship.getName()) + "}\" width=\"100%\" >\r\n");
codeChunk.addHtmlCode("\t\t\t<rich:column");
if (attribute.getType().contains("Double") || attribute.getType().contains("Integer") || attribute.getType().contains("Long"))
{
codeChunk.addHtmlCode(" align=\"right\" ");
}
if (attribute.getType().contains("String"))
{
codeChunk.addHtmlCode(" align=\"left\" ");
}
if (attribute.getType().contains("Date") || attribute.getType().contains("Boolean"))
{
codeChunk.addHtmlCode(" align=\"center\" ");
}
codeChunk.addHtmlCode(">\r\n");
codeChunk.addHtmlCode("\t\t\t\t<f:facet name=\"header\">\r\n");
codeChunk.addHtmlCode("\t\t\t\t</f:facet>\r\n");
codeChunk.addHtmlCode("\t\t\t\t<tr:inputDate id=\"" + attribute.getName() + "\" value=\"#{" + singularRelationshipName + "." + attribute.getName() + "}\" >\r\n");
codeChunk.addHtmlCode("\t\t\t\t\t<f:convertDateTime type=\"date\" pattern=\"#{msgs.Application_DateFormat}\" />\r\n");
codeChunk.addHtmlCode("\t\t\t\t</tr:inputDate>\r\n");
codeChunk.addHtmlCode("\t\t\t</rich:column>\r\n");
codeChunk.addHtmlCode("\t\t</rich:dataTable>\r\n");
}
else
{
/** Relazione :1 **/
if (attribute.getType().equals("java.util.Date"))
{
codeChunk.addHtmlCode("\t\t<tr:inputDate id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(attribute.getRelationship().getName()) + "." + attribute.getName() + "}\" >\r\n");
codeChunk.addHtmlCode("\t\t\t<f:convertDateTime type=\"date\" pattern=\"#{msgs.Application_DateFormat}\" />\r\n");
codeChunk.addHtmlCode("\t\t</tr:inputDate>\r\n");
}
else
codeChunk.addHtmlCode("\t\t\t\tTipo non supportato nella ricerca\r\n");
}
codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
codeChunk.addHtmlCode("</trh:rowLayout>\r\n");
}
else
{
codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
codeChunk.addHtmlCode("\t<trh:cellFormat styleClass=\"formFieldLabel\" ><tr:outputLabel value=\"#{msgs.form_" + bean.getName() + "_search" + attribute.SeamLabel() + "}\" /></trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\t<trh:cellFormat width=\"100%\" >\r\n");
codeChunk.addHtmlCode("\t\t<h:inputText id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(firstRelationship.getName()) + attribute.SeamField() + "}\" />\r\n");
codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
codeChunk.addHtmlCode("</trh:rowLayout>\r\n");
}
}
else
{
if (firstRelationship.isListBox())
{
// Gli attributi debbono essere inseriti come listbox
if (firstRelationship.isToMany())
{
codeChunk = insertMultipleSelectionListBox2Form(bean, firstRelationship, true, true);
}
else
{
codeChunk = insertSingleSelectionListBox2Form(sourceDir, bean, firstRelationship, true, true);
}
}
else
{
// Gli attributi debbono essere inseriti come popup
if (firstRelationship.isToMany())
{
codeChunk.addJavascriptCode("function openPopUp_" + firstRelationship.getName() + "()");
codeChunk.JavascriptNewLine();
codeChunk.addJavascriptCode("{");
codeChunk.JavascriptNewLine();
codeChunk.addJavascriptCode("\twindow.open(\"popup/" + bean.getName() + firstRelationship.getName() + "PopUp.seam?parentConversationId=\"+document.forms[\"form\"].elements['parentConversationId'].value+\"&conversationIsLongRunning=true\",\"" + firstRelationship.getToBeanName() + "Window\",\"resizable=yes,menubar=no,width=850,height=550,scrollbars=yes\");");
codeChunk.JavascriptNewLine();
codeChunk.addJavascriptCode("}");
codeChunk.JavascriptNewLine();
codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
codeChunk.addHtmlCode("\t<trh:cellFormat styleClass=\"formFieldLabel\" >\r\n");
codeChunk.addHtmlCode("\t\t<tr:outputLabel for=\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + Utils.makeFirstLetterLowerCase(firstRelationship.getName()) + "\" value=\"#{msgs.form_search_" + firstRelationship.ToSeamLabel() + "}\" />\r\n");
codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\t<trh:cellFormat><trh:tableLayout><trh:rowLayout width=\"100%\" ><trh:cellFormat>\r\n");
// BOB: Genera id sui pulsanti di selezione
codeChunk.addHtmlCode("\t\t<tr:goLink id=\"popup_" + firstRelationship.getName() + "\" value=\"Seleziona\" onclick=\"openPopUp_" + firstRelationship.getName() + "();\" styleClass=\"button\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='SEARCH')}\" />\r\n");
codeChunk.addHtmlCode("\t\t</trh:cellFormat><trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\t\t</trh:cellFormat></trh:rowLayout></trh:tableLayout>\r\n");
codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
codeChunk.addHtmlCode("</trh:rowLayout>\r\n");
codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
codeChunk.addHtmlCode("\t<trh:cellFormat columnSpan=\"2\">\r\n");
codeChunk.addHtmlCode("\t\t<rich:dataTable id=\"tab_" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + firstRelationship.getName() + "\" var=\"" + Utils.makeFirstLetterLowerCase(firstRelationship.getToBeanName()) + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(firstRelationship.getName()) + "}\" width=\"100%\" rowBandingInterval=\"1\" verticalGridVisible=\"true\" horizontalGridVisible=\"false\" >\r\n");
for (int m = 0; m < firstRelationship.getRelatedAttributes().size(); m++)
{
ShowAttribute attr = firstRelationship.getRelatedAttributes().get(m);
codeChunk.addHtmlCode("\t\t\t<rich:column");
if (attr.getType().contains("Double") || attr.getType().contains("Integer") || attr.getType().contains("Long"))
{
codeChunk.addHtmlCode(" align=\"right\" ");
}
if (attr.getType().contains("String"))
{
codeChunk.addHtmlCode(" align=\"left\" ");
}
if (attr.getType().contains("Date") || attr.getType().contains("Boolean"))
{
codeChunk.addHtmlCode(" align=\"center\" ");
}
codeChunk.addHtmlCode(">\r\n");
codeChunk.addHtmlCode("\t\t\t\t<f:facet name=\"header\">\r\n");
codeChunk.addHtmlCode("\t\t\t\t\t<h:outputText value=\"#{msgs.form_" + bean.getName());
for (int k = 0; k < attr.getRelationships().size(); k++)
{
codeChunk.addHtmlCode("_");
codeChunk.addHtmlCode(attr.getRelationships().get(k).getName());
}
codeChunk.addHtmlCode("_" + attr.getName() + "");
codeChunk.addHtmlCode("}\" />\r\n");
codeChunk.addHtmlCode("\t\t\t\t</f:facet>\r\n");
if (attr.getRelationships().size() == 0)
{
codeChunk.addHtmlCode("\t\t\t\t<tr:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(firstRelationship.getToBeanName()) + "." + attr.getName() + "}\" />\r\n");
}
else
{
codeChunk.addHtmlCode("\t\t\t\t<tr:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(firstRelationship.getToBeanName()) + ".");
for (int k = 1; k < attr.getRelationships().size(); k++)
{
if (k > 1)
codeChunk.addHtmlCode(".");
codeChunk.addHtmlCode(Utils.makeMethod2Field(attr.getRelationships().get(k).getName()));
}
codeChunk.addHtmlCode("." + attr.getName());
codeChunk.addHtmlCode("}\" />\r\n");
}
codeChunk.addHtmlCode("\t\t\t</rich:column>\r\n");
}
codeChunk.addHtmlCode("\t\t</rich:dataTable>\r\n");
codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
codeChunk.addHtmlCode("</trh:rowLayout>\r\n");
}
else
{
codeChunk = insertSingleSelectionPopUp2Form(sourceDir, bean, firstRelationship, false, true);
}
}
}
}
else
{
// Attributo nella forma [relazione.]*Attributo
if (attribute.getRelationships().get(0).isIgnoreImplementation())
{
// Gli attributi debbono essere inseriti come Text
codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
codeChunk.addHtmlCode("\t<trh:cellFormat styleClass=\"formFieldLabel\" >");
codeChunk.addHtmlCode("<tr:outputLabel value=\"#{msgs.form_" + bean.getName());
codeChunk.addHtmlCode("_" + attribute.getRelationships().get(0).getName());
codeChunk.addHtmlCode(attribute.SeamLabel() + "}\" /></trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\t<trh:cellFormat >\r\n");
codeChunk.addHtmlCode("\t\t<tr:inputText value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()));
for (Relationship rel : attribute.getRelationships())
{
codeChunk.addHtmlCode("." + Utils.makeMethod2Field(rel.getName()));
}
codeChunk.addHtmlCode("." + attribute.getName() + "}\" />\r\n");
codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
codeChunk.addHtmlCode("</trh:rowLayout>\r\n");
codeChunk.setOrder(attribute.getOrderInForm());
}
else
{
// codeChunk.setOrder(attribute.getOrderInForm());
// codeChunk.addHtmlCode("\r\n<trh:rowLayout>\r\n");
// codeChunk.addHtmlCode("\t<trh:cellFormat>NON SO
// !</trh:cellFormat>\r\n");
// codeChunk.addHtmlCode("\t\t<trh:cellFormat>NON SO
// !</trh:cellFormat>\r\n");
// codeChunk.addHtmlCode("</trh:rowLayout>\r\n");
}
}
// System.out.println(codeChunks.getHtmlCode());
// System.out.println(codeChunk.getHtmlCode());
if (!codeChunks.getHtmlCode().contains(codeChunk.getHtmlCode()))
{
codeChunk.setOrder(attribute.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";
}
}
CodeChunk chunks[] = codeChunks.toArray(new CodeChunk[0]);