List of usage examples for java.util Hashtable contains
public synchronized boolean contains(Object value)
From source file:MainClass.java
public static void main(String[] s) { Hashtable table = new Hashtable(); table.put("key1", "value1"); table.put("key2", "value2"); table.put("key3", "value3"); System.out.println(table.contains("value3")); }
From source file:Main.java
public static void main(String[] args) { Hashtable<String, String> ht = new Hashtable<String, String>(); ht.put("1", "One"); ht.put("2", "Two"); ht.put("3", "Three"); boolean blnExists = ht.contains("Two"); System.out.println("Two exists in Hashtable ? : " + blnExists); }
From source file:Main.java
public static void main(String[] s) { Hashtable<String, String> table = new Hashtable<String, String>(); table.put("key1", "value1"); table.put("key2", "value2"); table.put("key3", "value3"); System.out.println(table.contains("value3")); }
From source file:Main.java
public static void main(String args[]) { Hashtable<Integer, String> htable = new Hashtable<Integer, String>(); // put values into the table htable.put(1, "A"); htable.put(2, "B"); htable.put(3, "C"); htable.put(4, "from java2s.com"); // check if table contains "C" boolean isavailable = htable.contains("C"); // display search result System.out.println("Hash table contains 'C': " + isavailable); }
From source file:Main.java
public static Hashtable<Integer, Vector<Integer>> getNodeMembership(final Vector<Vector<Integer>> CmtyVV) { Hashtable<Integer, Vector<Integer>> NIDComVH = new Hashtable<Integer, Vector<Integer>>(); for (int CID = 0; CID < CmtyVV.size(); CID++) { for (Integer NID : CmtyVV.get(CID)) { if (!NIDComVH.contains(NID)) { Vector<Integer> v = new Vector<Integer>(); v.add(CID);//from ww w . jav a 2 s .c om NIDComVH.put(NID, v); } else { Vector<Integer> v = NIDComVH.get(NID); v.add(CID); NIDComVH.put(NID, v); } } } return NIDComVH; }
From source file:com.projity.configuration.Dictionary.java
public static void add(NamedItem namedItem, boolean replace) { String categories[] = namedItem.getCategory().split(";"); // can belong to more than one if separated by ; for (int i = 0; i < categories.length; i++) { String category = categories[i]; Hashtable subMap = (Hashtable) getInstance().mainMap.get(category); if (subMap == null) { subMap = new Hashtable(); getInstance().mainMap.put(category, subMap); }/*from ww w . j a v a 2 s.c o m*/ if (!subMap.contains(namedItem)) { subMap.put(namedItem.getName(), namedItem); } else { if (replace) subMap.put(namedItem.getName(), namedItem); //this is actually normal if overriding with another xml file ConfigurationReader.log.warn("named item " + namedItem + " already in category " + category); } } }
From source file:ffx.ui.KeywordPanel.java
private void configToKeywords(FFXSystem newSystem) { CompositeConfiguration properties = newSystem.getProperties(); Hashtable<String, Keyword> keywordHash = new Hashtable<>(); // Create the "Comments" property. Keyword keyword = new Keyword("COMMENTS"); keywordHash.put("COMMENTS", keyword); // Loop over properties from the keyword file. Configuration config = properties.getConfiguration(0); if (config instanceof PropertiesConfiguration) { PropertiesConfiguration prop = (PropertiesConfiguration) config; Iterator<String> keys = prop.getKeys(); while (keys.hasNext()) { String key = keys.next(); if (keywordHash.contains(key)) { keyword = keywordHash.get(key); keyword.append(prop.getStringArray(key)); } else { String[] values = prop.getStringArray(key); keyword = new Keyword(key, values); keywordHash.put(key, keyword); }/*from w ww . j a v a 2 s . c o m*/ } } newSystem.setKeywords(keywordHash); }
From source file:com.flexoodb.common.FlexUtils.java
/** * obtains an HTML Input Form prototype for the object. * * @param title optional title in the XSL prorotype, can be null (ie none). * @param obj optional UI configuration. * @param obj the object containing the elements that will be used to populate the XSL. * @return XSL string./*w w w. jav a 2s . co m*/ * @see Hashtable *@see Element */ public String getHTMLFormPrototype(String title, Config config, Object obj, String parentclass) throws Exception { Class c = obj.getClass(); //Method[] m = c.getMethods(); Vector ve = retrieveMethods(c, null); Method[] m = new Method[ve.size()]; ve.toArray(m); StringBuffer xml = new StringBuffer(); //xml.append("<"+c.getSimpleName()+">"); Hashtable fields = getFields(obj); Enumeration it = fields.keys(); if (parentclass != null) { xml.append("\n<div>\n<span style=\"font-size:14px;font-weight:bold\">\n"); xml.append(" <a onClick=\"javascript:linkchangecontent('<%var_context[" + parentclass.toLowerCase() + "parent]%>?id=<%var_context[" + parentclass.toLowerCase() + "parentid]%>','contentdyn')\" href=\"#\">\n"); xml.append(" <%var_context[" + parentclass.toLowerCase() + "parentname]%>\n"); xml.append(" </a>\n"); xml.append("</span>\n</div>\n\n"); } if (title != null) { xml.append(" <fieldset>\n <legend>" + title + "</legend>\n <div class=\"fieldsetwrap\">\n"); } else { xml.append(" <fieldset>\n <legend>New " + c.getSimpleName().substring(0, c.getSimpleName().length() - 4) + "</legend>\n <div class=\"fieldsetwrap\">\n"); } if (fields.contains("byte[]")) { xml.append("\n <form class=\"webform\" id=\"" + c.getSimpleName().toLowerCase() + "\" name=\"" + c.getSimpleName().toLowerCase() + "\" method=\"post\" enctype=\"multipart/form-data\" action=\"add" + c.getSimpleName() + ".igx\">\n"); } else { xml.append("\n <form class=\"webform\" id=\"" + c.getSimpleName().toLowerCase() + "\" name=\"" + c.getSimpleName().toLowerCase() + "\" method=\"post\" action=\"add" + c.getSimpleName() + ".igx\">\n"); } xml.append(" <input name=\"id\" type=\"hidden\" value=\"<%var_request[id]%>\"/>\n"); xml.append(" <div class=\"datafieldwrap\">\n"); xml.append(" <table class=\"datafield\">\n"); ConfigElement ce = config.getElementConfig(c.getSimpleName()); // if we found a config for this then we generate it in order. if (ce != null) { Map cef = ce.getFields(); Iterator itr = cef.values().iterator(); while (itr.hasNext()) { ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next(); if (cfi.visible && _types.indexOf(cfi.type) > -1) { if (cfi.type.equalsIgnoreCase("boolean")) { if (cfi.addable) { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\">\n<SELECT id=\"select" + cfi.name + "\" name=\"" + cfi.name.toLowerCase() + "\">\n<OPTION SELECTED=\"\">true</OPTION>\n<OPTION>false</OPTION>\n</SELECT></td></tr>\n"); } else { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"></td></tr>\n"); } } else if (cfi.type.equalsIgnoreCase("byte[]") || cfi.type.equalsIgnoreCase("file")) { if (cfi.addable) { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\">\n<input id=\"file" + cfi.name + "\" type=\"file\" name=\"" + cfi.name.toLowerCase() + "\"/></td></tr>\n"); } else { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"></td></tr>\n"); } } else if (cfi.type.equalsIgnoreCase("date")) { if (cfi.addable) { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\">\n<input class=\"txtdtt\" id=\"calendar" + cfi.name + "\" type=\"text\" name=\"" + cfi.name.toLowerCase() + "\"/><a href=\"javascript:NewCssCal('calendar" + cfi.name + "','yyyymmdd','arrow',false,24,true)\"><img src=\"images/cal.gif\" width=\"16\" height=\"16\" alt=\"Pick a date\"/></a></td></tr>\n"); } else { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"></td></tr>\n"); } } else if (cfi.type.equalsIgnoreCase("dateTime")) { if (cfi.addable) { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\">\n<input class=\"txtdtt\" id=\"calendar" + cfi.name + "\" type=\"text\" name=\"" + cfi.name.toLowerCase() + "\"/><a href=\"javascript:NewCssCal('calendar" + cfi.name + "','yyyymmdd','arrow',true,24,false)\"><img src=\"images/cal.gif\" width=\"16\" height=\"16\" alt=\"Pick a date\"/></a></td></tr>\n"); } else { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"></td></tr>\n"); } } else if (cfi.type.equalsIgnoreCase("select")) { if (cfi.addable) { String options = null; // first we check if the choices is a dynamic one if (cfi.choices.indexOf("Type.") > -1) { String optionname = null; String idfield = null; if (cfi.choices.split("=").length > 1) { optionname = cfi.choices.split("=")[0] + cfi.choices.split("=")[1]; idfield = cfi.choices.split("=")[0]; } else { optionname = cfi.choices; } options = "<%dyn_" + cfi.choices.substring(0, cfi.choices.indexOf(".")) + cfi.choices.substring(cfi.choices.indexOf(".") + 1) + "Select.igx%>"; } else { String[] choices = cfi.choices.split(","); if (choices != null && choices.length > 0) { for (int i = 0; i < choices.length; i++) { if (i == 0) { options = "<OPTION SELECTED=\"\" value=\"" + choices[i] + "\">" + choices[i] + "</OPTION>"; } else { options = options + "<OPTION value=\"" + choices[i] + "\">" + choices[i] + "</OPTION>"; } } } else { options = "<OPTION SELECTED=\"\" value=\"Active\">Active</OPTION>\n<OPTION value=\"Suspended\">Suspended</OPTION>"; } } xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\">\n<SELECT id=\"select" + cfi.name + "\" name=\"" + cfi.name.toLowerCase() + "\">\n" + options + "\n</SELECT></td></tr>\n"); } else { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"></td></tr>\n"); } } else if (cfi.type.equalsIgnoreCase("textarea")) { if (cfi.addable) { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"><textarea class=\"ta\" id=\"textarea" + cfi.name + "\" name=\"" + cfi.name.toLowerCase() + "\" rows=\"" + cfi.rows + "\" cols=\"" + cfi.columns + "\"></textarea></td></tr>\n"); } else { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"></td></tr>\n"); } } else { if (cfi.addable) { if (cfi.maxlength > 0) { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"><input class=\"txt\" id=\"text" + cfi.name + "\" name=\"" + cfi.name.toLowerCase() + "\" type=\"text\" value=\"\" style=\"width: " + (cfi.maxlength * 10) + "px;\" maxlength=\"" + cfi.maxlength + "\"/></td></tr>\n"); } else { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"><input class=\"txt\" id=\"text" + cfi.name + "\" name=\"" + cfi.name.toLowerCase() + "\" type=\"text\" value=\"\"/></td></tr>\n"); } } else { if (cfi.maxlength > 0) { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"></td></tr>\n"); } else { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"></td></tr>\n"); } } } } } } else { while (it.hasMoreElements()) { String f = (String) it.nextElement(); String t = (String) fields.get(f); if (t.equalsIgnoreCase("boolean")) { xml.append(" <tr><td class=\"lbl\">" + f + ":</td><td class=\"data full\">\n<SELECT id=\"select" + f + "\" name=\"" + f.toLowerCase() + "\">\n<OPTION SELECTED=\"\">true</OPTION>\n<OPTION>false</OPTION>\n</SELECT></td></tr>\n"); } else if (t.equalsIgnoreCase("byte[]")) { xml.append(" <tr><td class=\"lbl\">" + f + ":</td><td class=\"data full\">\n<input id=\"file" + f + "\" type=\"file\" name=\"" + f.toLowerCase() + "\"/></td></tr>\n"); } else if (t.equalsIgnoreCase("XMLGregorianCalendar")) { xml.append(" <tr><td class=\"lbl\">" + f + ":</td><td class=\"data full\">\n<input class=\"txtdtt\" id=\"calendar" + f + "\" type=\"text\" name=\"" + f.toLowerCase() + "\"/><a href=\"javascript:NewCssCal('calendar" + f + "','yyyymmdd','arrow',false,24,true)\"><img src=\"images/cal.gif\" width=\"16\" height=\"16\" alt=\"Pick a date\"/></a></td></tr>\n"); } else { // generate text area for common text field names if (_textfields.indexOf(f.toLowerCase()) > -1) { xml.append(" <tr><td class=\"lbl\">" + f + ":</td><td class=\"data full\"><textarea class=\"ta\" id=\"textarea" + f + "\" name=\"" + f.toLowerCase() + "\" rows=\"5\" cols=\"65\"></textarea></td></tr>\n"); } else { // hard coded convenience if (f.equalsIgnoreCase("status")) { xml.append(" <tr><td class=\"lbl\">" + f + ":</td><td class=\"data full\">\n<SELECT id=\"select" + f + "\" name=\"" + f.toLowerCase() + "\">\n<OPTION SELECTED=\"\">Active</OPTION>\n<OPTION>Suspended</OPTION>\n</SELECT></td></tr>\n"); } else { xml.append(" <tr><td class=\"lbl\">" + f + ":</td><td class=\"data full\"><input class=\"txt\" id=\"text" + f + "\" name=\"" + f.toLowerCase() + "\" type=\"text\" value=\"\"/></td></tr>\n"); } } } } } xml.append(" </table>\n"); xml.append(" </div>\n"); xml.append(" <input type=\"button\" value=\"Save\" onClick=\"javascript:buttonchangecontent('add" + c.getSimpleName() + ".igx','" + c.getSimpleName().toLowerCase() + "','contentdyn')\"/>\n"); xml.append(" </form>\n <div class=\"clear\"></div>\n </div>\n </fieldset>\n"); xml.append(" <table><tr>\n"); xml.append(" <td>\n"); xml.append(" <form class=\"inlineform\" id=\"list" + c.getSimpleName().toLowerCase() + "\" name=\"list" + c.getSimpleName().toLowerCase() + "\" method=\"post\" action=\"list" + c.getSimpleName() + ".igx\">\n"); if (parentclass != null) { xml.append(" <input type=\"button\" onClick=\"javascript:linkchangecontent('<%var_context[" + parentclass.toLowerCase() + "parent]%>?id=<%var_context[" + parentclass.toLowerCase() + "parentid]%>','contentdyn')\" value=\"Cancel\"/>\n"); } else { xml.append(" <input type=\"button\" onClick=\"javascript:linkchangecontent('list" + c.getSimpleName() + ".igx?from=0&to=10','contentdyn')\" value=\"Cancel\"/>\n"); } xml.append(" </form></td>\n"); xml.append(" </tr></table>\n"); //main.append("<"+c.getSimpleName()+" id=\""+id+"\" parentid=\""+parentid+"\">"); return xml.toString(); }
From source file:com.flexoodb.common.FlexUtils.java
/** * obtains an XSL prototype for the object. * * @param title optional title in the XSL prorotype, can be null (ie none). * @param config configuration for class type. * @param obj the object containing the elements that will be used to populate the XSL. * @param listtype set to '0' if its not a list type, 1 for regular list and 2 if this is a child list . * @param type 0 for non-edit viewing only, 1 to embed viewable contents in editable fields (ie for updating or editing) and 2 for empty fields (ie for new records). * @param message default message.// w w w .j a v a 2 s .c o m * @param parentclass parentclassname for reference. * @return XSL string. * @see Hashtable *@see Element */ public String getXSLPrototype(String title, Config config, Object obj, boolean list, int type, String message, String parentclass) throws Exception { Class c = obj.getClass(); String simplename = c.getSimpleName(); simplename = simplename.substring(0, simplename.length() - 4); ConfigElement ce = config.getElementConfig(c.getSimpleName()); Vector ve = retrieveMethods(c, null); Method[] m = new Method[ve.size()]; ve.toArray(m); String name, retval; String id = null; String parentid = null; StringBuffer xml = new StringBuffer(); StringBuffer listheader = new StringBuffer(); Hashtable fields = getFields(obj); Enumeration it = fields.keys(); if (list) { String callname = parentclass == null ? "list" + c.getSimpleName() + ".igx" : "get" + c.getSimpleName() + "WithParentID.igx"; String idref = parentclass == null ? "{../@id}" : "<%var_request[id]%>"; xml.append("\n\n<xsl:template match=\"records\">\n"); //xml.append("<div class=\"info\">\n"); xml.append("<div>\n"); // must be a child! if (parentclass != null) { xml.append("<span style=\"font-size:14px;font-weight:bold\">\n"); xml.append(" <a onClick=\"javascript:linkchangecontent('<%var_context[" + parentclass.toLowerCase() + "parent]%>?id=<%var_context[" + parentclass.toLowerCase() + "parentid]%>','contentdyn')\" href=\"#\">\n"); xml.append(" <%var_context[" + parentclass.toLowerCase() + "parentname]%>\n"); xml.append(" </a>\n"); xml.append("</span>\n"); } xml.append("<span style=\"float:right;padding-right:3px\">\n"); xml.append("\n"); xml.append("<!-- TOP -->\n"); xml.append(" <xsl:choose>\n"); xml.append(" <xsl:when test=\"number(@from) > 0\">\n"); xml.append(" <a onClick=\"javascript:linkchangecontent('" + callname + "?id=" + idref + "&from=0&to=15','contentdyn')\" href=\"#\">\n"); xml.append(" <img src=\"images/top.png\" alt=\"Top\"/>\n"); xml.append(" </a> \n"); xml.append(" </xsl:when>\n"); xml.append(" <xsl:otherwise>\n"); xml.append(" <img src=\"images/topg.png\" alt=\"Top\"/>\n"); xml.append(" </xsl:otherwise>\n"); xml.append(" </xsl:choose>\n"); xml.append("\n"); xml.append("<!-- PREV -->\n"); xml.append("<xsl:choose>\n"); xml.append(" <xsl:when test=\"@from > 0\">\n"); xml.append(" <xsl:choose>\n"); xml.append(" <xsl:when test=\"(number(@from)-15) < 0\">\n"); xml.append(" <a onClick=\"javascript:linkchangecontent('" + callname + "?id=" + idref + "&from=0&to=15','contentdyn')\" href=\"#\">\n"); xml.append(" <img src=\"images/prev.png\" alt=\"Previous\"/>\n"); xml.append(" </a> \n"); xml.append(" </xsl:when>\n"); xml.append(" <xsl:otherwise>\n"); xml.append(" <a onClick=\"javascript:linkchangecontent('" + callname + "?id=" + idref + "&from={number(@from)-15}&to={@from}','contentdyn')\" href=\"#\">\n"); xml.append(" <img src=\"images/prev.png\" alt=\"Previous\"/>\n"); xml.append(" </a> \n"); xml.append(" </xsl:otherwise>\n"); xml.append(" </xsl:choose>\n"); xml.append(" </xsl:when>\n"); xml.append(" <xsl:otherwise>\n"); xml.append(" <img src=\"images/prevg.png\" alt=\"Previous\"/>\n"); xml.append(" </xsl:otherwise>\n"); xml.append("</xsl:choose>\n"); xml.append("<!-- NEXT -->\n"); xml.append("<xsl:choose>\n"); xml.append(" <xsl:when test=\"(number(@from)+15) < number(@total)\">\n"); xml.append(" <xsl:choose>\n"); xml.append(" <xsl:when test=\"(number(@from)+15) > number(@total)\">\n"); xml.append(" <a onClick=\"javascript:linkchangecontent('" + callname + "?id=" + idref + "&from={number(@from)+15}&to={@total}','contentdyn')\" href=\"#\">\n"); xml.append(" <img src=\"images/next.png\" alt=\"Next\"/>\n"); xml.append(" </a> \n"); xml.append(" </xsl:when>\n"); xml.append(" <xsl:otherwise>\n"); xml.append(" <a onClick=\"javascript:linkchangecontent('" + callname + "?id=" + idref + "&from={number(@from)+15}&to={number(@from)+30}','contentdyn')\" href=\"#\">\n"); xml.append(" <img src=\"images/next.png\" alt=\"Next\"/>\n"); xml.append(" </a> \n"); xml.append(" </xsl:otherwise>\n"); xml.append(" </xsl:choose>\n"); xml.append(" </xsl:when>\n"); xml.append(" <xsl:otherwise>\n"); xml.append(" <img src=\"images/nextg.png\" alt=\"Next\"/>\n"); xml.append(" </xsl:otherwise>\n"); xml.append("</xsl:choose>\n"); xml.append("<!-- BOTTOM -->\n"); xml.append("<xsl:choose>\n"); xml.append(" <xsl:when test=\"number(@from) < (number(@total)-15)\">\n"); xml.append(" <xsl:choose>\n"); xml.append(" <xsl:when test=\"number(@total) > 15\">\n"); xml.append(" <a onClick=\"javascript:linkchangecontent('" + callname + "?id=" + idref + "&from={number(@total)-15}&to={@total}','contentdyn')\" href=\"#\">\n"); xml.append(" <img src=\"images/bottom.png\" alt=\"Bottom\"/>\n"); xml.append(" </a> \n"); xml.append(" </xsl:when>\n"); xml.append(" <xsl:otherwise>\n"); xml.append(" <a onClick=\"javascript:linkchangecontent('" + callname + "?id=" + idref + "&from={number(@from)+15}&to={number(@from)+30}','contentdyn')\" href=\"#\">\n"); xml.append(" <img src=\"images/bottom.png\" alt=\"Bottom\"/>\n"); xml.append(" </a> \n"); xml.append(" </xsl:otherwise>\n"); xml.append(" </xsl:choose>\n"); xml.append(" </xsl:when>\n"); xml.append(" <xsl:otherwise>\n"); xml.append(" <img src=\"images/bottomg.png\" alt=\"Bottom\"/>\n"); xml.append(" </xsl:otherwise>\n"); xml.append("</xsl:choose>\n"); xml.append("</span>\n"); xml.append("<span style=\"float:right;vertical-align:middle;padding-right:3px\">\n"); xml.append("<xsl:choose>\n"); xml.append(" <xsl:when test=\"number(@total) > 0\">\n"); xml.append(" Showing <xsl:value-of select=\"number(@from)+1\"/>\n"); xml.append( " to <xsl:value-of select=\"number(@from)+number(@returned)\"/> records of <xsl:value-of select=\"@total\"/>\n"); xml.append(" </xsl:when>\n"); xml.append(" <xsl:otherwise>\n"); xml.append(" No Records.\n"); xml.append(" </xsl:otherwise>\n"); xml.append("</xsl:choose>\n"); xml.append("</span>\n"); xml.append("\n"); xml.append("</div>\n"); xml.append("</xsl:template>\n\n"); xml.append("\n<xsl:template match=\"LIST\">\n"); /*if (title!=null) { xml.append("<div class=\"info\"><strong>"+title+"</strong> (found <xsl:value-of select=\"@COUNT\"/> records)</div>\n"); }*/ xml.append("<table class=\"sortable\">\n"); // create the header xml.append(" <!-- create the header -->\n"); xml.append(" <thead><tr>\n"); if (ce != null) { Map cef = ce.getFields(); Iterator itr = cef.values().iterator(); while (itr.hasNext()) { ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next(); if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type) > -1) { xml.append(" <th>" + cfi.label + "</th>\n"); } } } else { while (it.hasMoreElements()) { String f = (String) it.nextElement(); xml.append(" <th>" + f + "</th>\n"); } } xml.append(" <th>Action</th>\n"); xml.append(" </tr></thead>\n"); xml.append(" <xsl:apply-templates select=\"flexcontainer/" + c.getSimpleName().toLowerCase() + "\"/>\n"); xml.append("</table>\n"); xml.append("</xsl:template>\n"); // create the table contents xml.append("<xsl:template match=\"flexcontainer/" + c.getSimpleName().toLowerCase() + "\">"); xml.append("\n <!-- create table contents -->\n"); xml.append(" <xsl:for-each select=\".\">\n"); xml.append(" <tr>\n"); if (ce != null) { Map cef = ce.getFields(); Iterator itr = cef.values().iterator(); while (itr.hasNext()) { ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next(); if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type.toLowerCase()) > -1) { if (type == 0) { if (cfi.type.equals("byte[]") || cfi.type.equals("file") || cfi.type.equalsIgnoreCase("base64Binary")) { xml.append(" <td><a href=\"get" + cfi.name + "In" + c.getSimpleName() + ".igx?id={../@id}\"><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></a></td>\n"); } else { //format-number(units,'###,###,##0.00') if (cfi.type.equalsIgnoreCase("decimal")) { xml.append(" <td><xsl:value-of select=\"format-number(" + cfi.name.toLowerCase() + ",'###,###,##0.00')\"/></td>\n"); } else { xml.append(" <td><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></td>\n"); } } } else if (type == 1) { xml.append(" <td><input class=\"txt\" id=\"text" + cfi.name + "\" name=\"" + cfi.name.toLowerCase() + "\" type=\"text\" value=\"{" + cfi.name + "}\"/></td>\n"); } else { xml.append(" <td><input class=\"txt\" id=\"text" + cfi.name + "\" name=\"" + cfi.name.toLowerCase() + "\" type=\"text\" value=\"\"/></td>\n"); } } } } else { it = fields.keys(); while (it.hasMoreElements()) { String f = (String) it.nextElement(); String t = (String) fields.get(f); if (type == 0) { if (t.equals("byte[]") || t.equals("base64Binary")) { xml.append(" <td><a href=\"get" + f + "In" + c.getSimpleName() + ".igx?id={../@id}\"><xsl:value-of select=\"" + f.toLowerCase() + "\"/></a></td>\n"); } else { //format-number(units,'###,###,##0.00') if (t.equalsIgnoreCase("decimal")) { xml.append(" <td><xsl:value-of select=\"format-number(" + f.toLowerCase() + ",'###,###,##0.00')\"/></td>\n"); } else { xml.append(" <td><xsl:value-of select=\"" + f.toLowerCase() + "\"/></td>\n"); } } } else if (type == 1) { xml.append(" <td><input class=\"txt\" id=\"text" + f + "\" name=\"" + f.toLowerCase() + "\" type=\"text\" value=\"{" + f.toLowerCase() + "}\"/></td>\n"); } else { xml.append(" <td><input class=\"txt\" id=\"text" + f + "\" name=\"" + f.toLowerCase() + "\" type=\"text\" value=\"\"/></td>\n"); } } } xml.append(" <td>\n"); /*if (parentclass!=null) { xml.append(" <a onClick=\""+(message!=null?"javascript:hidedivDisplay('message');":"")+"javascript:linkchangecontent('get"+c.getSimpleName()+".igx?id={../@id}&do=savecontext&"+parentclass.toLowerCase()+"parent=get"+parentclass+".igx&"+parentclass.toLowerCase()+"parentname="+parentclass+"&"+parentclass.toLowerCase()+"parentid=<%var_request[id]%>','contentdyn')\" href=\"#\">View</a> | \n"); xml.append(" <a href=\"javascript:getConfirmation('Are You Sure You Want to Delete this Record?','delete"+c.getSimpleName()+".igx?id={../@id}&do=savecontext&"+parentclass.toLowerCase()+"parent=get"+parentclass+".igx&"+parentclass.toLowerCase()+"parentname="+parentclass+"&"+parentclass.toLowerCase()+"parentid=<%var_request[id]%>','')\">Delete</a>\n"); } else {*/ xml.append(" <a onClick=\"" + (message != null ? "javascript:hidedivDisplay('message');" : "") + "javascript:linkchangecontent('get" + c.getSimpleName() + ".igx?id={../@id}','contentdyn')\" href=\"#\">View</a> | <a href=\"javascript:getConfirmation('Are You Sure You Want to Delete this Record?','delete" + c.getSimpleName() + ".igx?id={../@id}','')\">Delete</a>\n"); //} xml.append(" </td>\n"); xml.append(" </tr>\n"); xml.append(" </xsl:for-each>\n"); xml.append("</xsl:template>\n"); } else { // for viewing and editing only if (type < 2) { xml.append("\n<xsl:template match=\"flexcontainer/" + c.getSimpleName().toLowerCase() + "\">\n\n"); if (parentclass == null) { xml.append("<!-- Printer Friendly Version -->\n"); xml.append("<div align=\"right\">\n"); xml.append(" <a href=\"javascript:" + (message != null ? "javascript:hidedivDisplay('message');" : "") + "javascript:window.location='get" + c.getSimpleName() + "AsXML.igx?id={../@id}';\"> <img src=\"images/xml.png\" width=\"16\" height=\"16\" border=\"0\" alt=\"XML\"></img></a>\n"); xml.append(" <a href=\"javascript:" + (message != null ? "hidedivDisplay('message');" : "") + "javascript:printClick('Print " + c.getSimpleName() + "','print" + c.getSimpleName() + "','printlist" + c.getSimpleName() + "')\"> <img src=\"images/printer.png\" width=\"16\" height=\"16\" border=\"0\" alt=\"Print Version\"></img></a>\n"); xml.append("</div>\n"); xml.append("\n\n"); } else { xml.append("<!-- Printer Friendly and XML Version, uncomment to enable printing -->\n"); xml.append("<!-- <div align=\"right\">\n"); xml.append(" <a href=\"javascript:" + (message != null ? "javascript:hidedivDisplay('message');" : "") + "javascript:window.location='get" + c.getSimpleName() + "AsXML.igx?id={../@id}';\"> <img src=\"images/xml.png\" width=\"16\" height=\"16\" border=\"0\" alt=\"XML\"></img></a>\n"); xml.append(" <a href=\"javascript:" + (message != null ? "hidedivDisplay('message');" : "") + "javascript:printClick('Print " + c.getSimpleName() + "','print" + c.getSimpleName() + "','printlist" + c.getSimpleName() + "')\"> <img src=\"images/printer.png\" width=\"16\" height=\"16\" border=\"0\" alt=\"Print Version\"></img></a>\n"); xml.append("</div>\n"); xml.append("-->\n\n"); xml.append("<span style=\"font-size:14px;font-weight:bold\">\n"); xml.append(" <a onClick=\"javascript:linkchangecontent('<%var_context[" + parentclass.toLowerCase() + "parent]%>?id=<%var_context[" + parentclass.toLowerCase() + "parentid]%>','contentdyn')\" href=\"#\">\n"); xml.append(" <%var_context[" + parentclass.toLowerCase() + "parentname]%>\n"); xml.append(" </a>\n"); xml.append("</span>\n\n"); } // generate the view prototype first xml.append("<!--- START OF view" + c.getSimpleName() + " CODE SEGMENT -->\n"); xml.append("<div id=\"view" + c.getSimpleName() + "\">\n\n"); if (message != null) { xml.append("<div class=\"info\" id=\"message\"><b>" + message + "</b></div>\n\n"); } xml.append("<fieldset>\n"); xml.append("<legend>View " + simplename + "</legend>\n"); xml.append("<div class=\"fieldsetwrap\">\n"); xml.append(" <div class=\"datafieldwrap\">\n"); xml.append(" <table class=\"datafield\">\n"); if (ce != null) { Map cef = ce.getFields(); Iterator itr = cef.values().iterator(); while (itr.hasNext()) { ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next(); if (cfi.visible && _types.indexOf(cfi.type) > -1) { if (cfi.type.equals("byte[]") || cfi.type.equals("file") || cfi.type.equals("base64Binary")) { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"><a href=\"get" + cfi.name + "In" + c.getSimpleName() + ".igx?id={../@id}\"><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></a></td></tr>\n"); } else { if (cfi.type.equalsIgnoreCase("decimal")) { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"><xsl:value-of select=\"format-number(" + cfi.name.toLowerCase() + ",'###,###,##0.00')\"/></td></tr>\n"); } else { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"><pre><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></pre></td></tr>\n"); } } } } } else { while (it.hasMoreElements()) { String f = (String) it.nextElement(); String t = (String) fields.get(f); if (t.equals("byte[]")) { xml.append(" <tr><td class=\"lbl\">" + f + ":</td><td class=\"data full\"><a href=\"get" + f + "In" + c.getSimpleName() + ".igx?id={../@id}\"><xsl:value-of select=\"" + f.toLowerCase() + "\"/></a></td></tr>\n"); } else { if (t.equalsIgnoreCase("decimal")) { xml.append(" <tr><td class=\"lbl\">" + f + ":</td><td class=\"data full\"><xsl:value-of select=\"format-number(" + f.toLowerCase() + ",'###,###,##0.00')\"/></td></tr>\n"); } else { xml.append(" <tr><td class=\"lbl\">" + f + ":</td><td class=\"data full\"><pre><xsl:value-of select=\"" + f.toLowerCase() + "\"/></pre></td></tr>\n"); } } } } xml.append(" </table>\n"); xml.append(" </div>\n"); xml.append("</div>\n"); xml.append("</fieldset>\n\n"); xml.append("<div class=\"btnrow\">\n"); xml.append(" <input type=\"button\" value=\"Edit\" onClick=\"" + (message != null ? "hidedivDisplay('message');" : "") + "hidedivDisplay('view" + c.getSimpleName() + "');showdivDisplay('edit" + c.getSimpleName() + "');\"/>\n"); xml.append(" <input type=\"button\" value=\"Delete\" onClick=\"" + (message != null ? "hidedivDisplay('message');" : "") + "getConfirmation('Are You Sure You Want to Delete this Record?','delete" + c.getSimpleName() + ".igx?id={../@id}','')\"/>\n"); xml.append("</div>\n\n"); xml.append("</div>\n"); xml.append("<div class=\"clear\"></div>\n"); xml.append("<!--- END OF view" + c.getSimpleName() + " CODE SEGMENT -->\n\n"); } if (type < 2) // if it also requires editing then we include the editing prototype { // then the editing prototype xml.append("<!--- START OF edit" + c.getSimpleName() + " CODE SEGMENT USED FOR EDITING MODE -->\n"); xml.append("<div class=\"hidden\" id=\"edit" + c.getSimpleName() + "\">\n\n"); xml.append("<fieldset>\n"); xml.append("<legend>Edit " + simplename + "</legend>\n"); xml.append("<div class=\"fieldsetwrap\">\n"); if (fields.contains("byte[]")) { xml.append("\n<form class=\"webform\" id=\"update" + c.getSimpleName().toLowerCase() + "\" name=\"update" + c.getSimpleName().toLowerCase() + "\" method=\"post\" enctype=\"multipart/form-data\" action=\"update" + c.getSimpleName() + ".igx?id={../@id}\">\n"); xml.append("<input name=\"id\" type=\"hidden\" value=\"{../@id}\"/>\n"); } else { xml.append("\n<form class=\"webform\" id=\"update" + c.getSimpleName().toLowerCase() + "\" name=\"update" + c.getSimpleName().toLowerCase() + "\" method=\"post\" action=\"update" + c.getSimpleName() + ".igx?id={../@id}\">\n"); } xml.append(" <div class=\"datafieldwrap\">\n"); xml.append(" <table class=\"datafield\">\n"); it = fields.keys(); if (ce != null) { Map cef = ce.getFields(); Iterator itr = cef.values().iterator(); while (itr.hasNext()) { ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next(); if (cfi.visible && _types.indexOf(cfi.type) > -1) { if (!cfi.editable || !cfi.addable) { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"><pre><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></pre></td></tr>\n"); } else { if (cfi.type.equalsIgnoreCase("boolean")) { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\">\n"); xml.append(" <select id=\"select" + cfi.name + "\" name=\"" + cfi.name.toLowerCase() + "\">\n"); xml.append(" <option selected=\"\"><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></option>\n"); xml.append(" <option>true</option><option>false</option>\n"); xml.append(" </select>"); xml.append(" </td></tr>\n"); } else if (cfi.type.equalsIgnoreCase("byte[]") || cfi.type.equalsIgnoreCase("file") || cfi.type.equalsIgnoreCase("base64Binary")) { xml.append(" <xsl:choose>\n"); xml.append(" <xsl:when test=\"normalize-space(" + cfi.name.toLowerCase() + ")\">\n"); xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"><input id=\"file" + cfi.name + "\" type=\"file\" name=\"" + cfi.name.toLowerCase() + "\"/><a href=\"get" + cfi.name + "In" + c.getSimpleName() + ".igx?id={../@id}\"><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></a> <a onClick=\"getConfirmation('Are you sure you want to remove {" + cfi.name.toLowerCase() + "}?','del" + cfi.name + "In" + c.getSimpleName() + ".igx?id={../@id}','')\" href=\"#\"><img src=\"images/trash.png\" alt=\"Trash\"/></a></td></tr>\n"); xml.append(" </xsl:when>\n"); xml.append(" <xsl:otherwise>\n"); xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"><input id=\"file" + cfi.name + "\" type=\"file\" name=\"" + cfi.name.toLowerCase() + "\"/></td></tr>\n"); xml.append(" </xsl:otherwise>\n"); xml.append(" </xsl:choose>\n"); } else if (cfi.type.equalsIgnoreCase("date")) { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"><input class=\"txtdtt\" id=\"calendar" + cfi.name + "\" type=\"text\" name=\"" + cfi.name.toLowerCase() + "\" value=\"{" + cfi.name.toLowerCase() + "}\"/><a href=\"javascript:NewCssCal('calendar" + cfi.name + "','yyyymmdd','arrow',false,24,true)\"><img src=\"images/cal.gif\" width=\"16\" height=\"16\" alt=\"Pick a date\"/></a></td></tr>\n"); } else if (cfi.type.equalsIgnoreCase("dateTime")) { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"><input class=\"txtdtt\" id=\"calendar" + cfi.name + "\" type=\"text\" name=\"" + cfi.name.toLowerCase() + "\" value=\"{" + cfi.name.toLowerCase() + "}\"/><a href=\"javascript:NewCssCal('calendar" + cfi.name + "','yyyymmdd','arrow',true,24,false)\"><img src=\"images/cal.gif\" width=\"16\" height=\"16\" alt=\"Pick a date\"/></a></td></tr>\n"); } else if (cfi.type.equalsIgnoreCase("select")) { String options = null; // first we check if the choices is a dynamic one if (cfi.choices.indexOf("Type.") > -1) { String optionname = null; String idfield = null; if (cfi.choices.split("=").length > 1) { optionname = cfi.choices.split("=")[0] + cfi.choices.split("=")[1]; idfield = cfi.choices.split("=")[0]; options = " <option value=\"{" + cfi.name.toLowerCase() + "}\" selected=\"\">{%dyn_get" + cfi.choices.substring(0, cfi.choices.indexOf(".")) + optionname + ".igx?id=<xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/>%}</option>\n"; } else { optionname = cfi.choices.substring(cfi.choices.indexOf(".") + 1); options = " <option value=\"{" + cfi.name.toLowerCase() + "}\" selected=\"\"><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></option>\n"; } //options = options+"<%dyn_get"+cfi.choices.substring(0,cfi.choices.indexOf("."))+cfi.choices.substring(cfi.choices.indexOf(".")+1)+".igx%>"; options = options + " <%dyn_" + cfi.choices.substring(0, cfi.choices.indexOf(".")) + optionname + "Select.igx%>\n "; } else { options = " <option selected=\"\"><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></option>\n"; String[] choices = cfi.choices.split(","); if (choices != null && choices.length > 0) { for (int i = 0; i < choices.length; i++) { options = options + " <option>" + choices[i] + "</option>\n"; } } else { options = " <option selected=\"\">Active</option>\n <option>Suspended</option>\n"; } } xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\">\n"); xml.append(" <select id=\"select" + cfi.name + "\" name=\"" + cfi.name.toLowerCase() + "\">\n" + options); xml.append(" </select>\n"); xml.append(" </td></tr>\n"); } else if (cfi.type.equalsIgnoreCase("textarea")) { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"><textarea class=\"ta\" id=\"textarea" + cfi.name + "\" name=\"" + cfi.name.toLowerCase() + "\" rows=\"" + cfi.rows + "\" cols=\"" + cfi.columns + "\"><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></textarea></td></tr>\n"); } else { if (cfi.maxlength > 0) { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"><input class=\"txt\" id=\"text" + cfi.name + "\" name=\"" + cfi.name.toLowerCase() + "\" type=\"text\" value=\"{" + cfi.name.toLowerCase() + "}\" style=\"width: " + (cfi.maxlength * 10) + "px;\" maxlength=\"" + cfi.maxlength + "\"/></td></tr>\n"); } else { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"><input class=\"txt\" id=\"text" + cfi.name + "\" name=\"" + cfi.name.toLowerCase() + "\" type=\"text\" value=\"{" + cfi.name.toLowerCase() + "}\"/></td></tr>\n"); } } } } } } else { while (it.hasMoreElements()) { String f = (String) it.nextElement(); String t = (String) fields.get(f); if (t.equalsIgnoreCase("boolean")) { xml.append(" <tr><td class=\"lbl\">" + f + ":</td><td class=\"data full\"><SELECT id=\"select" + f + "\" name=\"" + f.toLowerCase() + "\">\n<OPTION SELECTED=\"\"><xsl:value-of select=\"" + f.toLowerCase() + "\"/></OPTION>\n<OPTION>true</OPTION>\n<OPTION>false</OPTION>\n</SELECT></td></tr>\n"); } else if (t.equalsIgnoreCase("byte[]") || t.equalsIgnoreCase("file")) { xml.append(" <xsl:choose>\n"); xml.append(" <xsl:when test=\"" + f.toLowerCase() + "=''\">\n"); xml.append(" <tr><td class=\"lbl\">" + f + ":</td><td class=\"data full\"><input id=\"file" + f + "\" type=\"file\" name=\"" + f.toLowerCase() + "\"/></td></tr>\n"); xml.append(" </xsl:when>\n"); xml.append(" <xsl:otherwise>\n"); xml.append(" <tr><td class=\"lbl\">" + f + ":</td><td class=\"data full\"><a href=\"get" + f + "In" + c.getSimpleName() + ".igx?id={../@id}\"><xsl:value-of select=\"" + f.toLowerCase() + "\"/></a>(<a href=\"remove" + f + "In" + c.getSimpleName() + ".igx?id={../@id}\">Remove</a>)<input id=\"file" + f + "\" type=\"file\" name=\"" + f.toLowerCase() + "\"/></td></tr>\n"); xml.append(" </xsl:otherwise>\n"); xml.append(" </xsl:choose>\n"); } else if (t.equalsIgnoreCase("XMLGregorianCalendar")) { xml.append(" <tr><td class=\"lbl\">" + f + ":</td><td class=\"data full\"><input class=\"txtdtt\" id=\"calendar" + f + "\" type=\"text\" name=\"" + f.toLowerCase() + "\" value=\"{" + f.toLowerCase() + "}\"/><a href=\"javascript:NewCssCal('calendar" + f + "','yyyymmdd','arrow',false,24,true)\"><img src=\"images/cal.gif\" width=\"16\" height=\"16\" alt=\"Pick a date\"/></a></td></tr>\n"); } else { if (_textfields.indexOf(f.toLowerCase()) > -1) { xml.append(" <tr><td class=\"lbl\">" + f + ":</td><td class=\"data full\"><textarea class=\"ta\" id=\"textarea" + f + "\" name=\"" + f.toLowerCase() + "\" rows=\"5\" cols=\"65\"><xsl:value-of select=\"" + f.toLowerCase() + "\"/></textarea></td></tr>\n"); } else { if (f.equalsIgnoreCase("status")) { xml.append(" <tr><td class=\"lbl\">" + f + ":</td><td class=\"data full\"><SELECT id=\"select" + f + "\" name=\"" + f.toLowerCase() + "\">\n<OPTION SELECTED=\"\"><xsl:value-of select=\"" + f.toLowerCase() + "\"/></OPTION>\n<OPTION>Active</OPTION>\n<OPTION>Suspended</OPTION>\n</SELECT></td></tr>\n"); } else { xml.append(" <tr><td class=\"lbl\">" + f + ":</td><td class=\"data full\"><input class=\"txt\" id=\"text" + f + "\" name=\"" + f.toLowerCase() + "\" type=\"text\" value=\"{" + f.toLowerCase() + "}\"/></td></tr>\n"); } } } } } xml.append(" </table>\n"); xml.append(" </div>\n\n"); xml.append( "<input type=\"button\" value=\"Update\" onClick=\"javascript:buttonchangecontent('update" + c.getSimpleName() + ".igx?id={../@id}','update" + c.getSimpleName().toLowerCase() + "','contentdyn')\"/>\n"); xml.append("</form>\n"); xml.append("<div class=\"clear\"></div>\n"); xml.append("</div>\n\n"); xml.append("</fieldset>\n\n"); xml.append("<div class=\"btnrow\">\n"); //xml.append(" <form class=\"inlineform\" method=\"post\" action=\"edit"+c.getSimpleName()+".igx?id={../@id}\">\n"); xml.append(" <form class=\"inlineform\">\n"); xml.append( " <input type=\"button\" value=\"Delete\" onClick=\"getConfirmation('Are You Sure You Want to Delete this Record?','delete" + c.getSimpleName() + ".igx?id={../@id}','')\"/>\n"); xml.append(" </form>\n"); xml.append(" <form class=\"inlineform\">\n"); xml.append(" <input type=\"button\" value=\"Cancel\" onClick=\"hidedivDisplay('edit" + c.getSimpleName() + "');showdivDisplay('view" + c.getSimpleName() + "');\"/>\n"); xml.append(" </form>\n"); xml.append("</div>\n\n"); xml.append("</div>\n"); xml.append("<div class=\"clear\"></div>\n"); xml.append("<!--- END OF edit" + c.getSimpleName() + " CODE SEGMENT -->\n\n"); } xml.append("<!--- START OF print" + c.getSimpleName() + " LIST SEGMENT USED FOR POP-UP PRINTER FRIENDLY OUTPUT -->\n"); xml.append("<div class=\"hidden\" id=\"printlist" + c.getSimpleName() + "\">\n\n"); // then we get the complex types! for (int i = 0; i < m.length; i++) { name = m[i].getName(); retval = m[i].getReturnType().getName(); // what if this is a list? if (retval.endsWith("List")) { String getter = m[i].getName(); Method met = c.getMethod(getter, (Class[]) null); ParameterizedType t = (ParameterizedType) met.getGenericReturnType(); Class c1 = (Class) t.getActualTypeArguments()[0]; String childname = m[i].getName().substring(3); childname = childname.substring(0, 1).toUpperCase() + childname.substring(1); String clsname = indexable(c1.getSimpleName()) ? "Flex" + c1.getSimpleName() : c1.getSimpleName(); xml.append(" <!--- START OF print" + childname + " LIST CODE SEGMENT -->\n"); xml.append(" <div id=\"print" + childname + "\">\n"); xml.append(" <fieldset>\n"); xml.append(" <legend>" + childname + " List</legend>\n"); xml.append(" <div class=\"fieldsetwrap\">\n"); xml.append(" <table class=\"sortable\">\n"); ConfigElement ce2 = config.getElementConfig(c1.getSimpleName()); Map cef = ce2.getFields(); Iterator itr = cef.values().iterator(); xml.append(" <thead><tr>\n"); String sortfield = null; while (itr.hasNext()) { ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next(); if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type) > -1) { xml.append(" <th>" + cfi.label + "</th>\n"); if (sortfield == null) { sortfield = cfi.name.toLowerCase(); } } } xml.append(" </tr></thead>\n"); xml.append(" <xsl:for-each select=\"" + c1.getSimpleName().toLowerCase() + "\">\n"); xml.append(" <xsl:sort select=\"" + sortfield + "\" order=\"descending\"/>\n"); xml.append(" <tr>\n"); itr = cef.values().iterator(); while (itr.hasNext()) { ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next(); if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type) > -1) { if (cfi.type.equals("byte[]")) { xml.append(" <td><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></td>\n"); } else { if (cfi.type.equalsIgnoreCase("decimal")) { xml.append(" <td><xsl:value-of select=\"format-number(" + cfi.name.toLowerCase() + ",'###,###,##0.00')\"/></td>\n"); } else { xml.append(" <td><pre><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></pre></td>\n"); } } } } xml.append(" </tr>\n"); xml.append(" </xsl:for-each>\n"); xml.append(" </table>\n"); xml.append(" <div class=\"clear\"></div>\n"); xml.append(" </div>\n\n"); xml.append(" </fieldset>\n"); xml.append(" </div>\n"); xml.append(" <!--- END OF print" + childname + " LIST CODE SEGMENT -->\n\n"); } else { if ("int,boolean".indexOf(retval) < 0 && !retval.startsWith("java") && !retval.equals("void") && !retval.equals("[B")) { String getter = m[i].getName(); Method met = c.getMethod(getter, (Class[]) null); Class c1 = (Class) met.getGenericReturnType(); String childname = m[i].getName().substring(3); childname = childname.substring(0, 1).toUpperCase() + childname.substring(1); String clsname = indexable(c1.getSimpleName()) ? "Flex" + c1.getSimpleName() : c1.getSimpleName(); xml.append(" <!--- START OF print" + childname + " CHILD CODE SEGMENT -->\n"); xml.append(" <div id=\"print" + childname + "\">\n"); xml.append(" <fieldset>\n"); xml.append(" <legend>" + childname + "</legend>\n"); xml.append(" <div class=\"fieldsetwrap\">\n"); xml.append(" <table class=\"sortable\">\n"); ConfigElement ce2 = config.getElementConfig(c1.getSimpleName()); Map cef = ce2.getFields(); Iterator itr = cef.values().iterator(); xml.append(" <thead><tr>\n"); String sortfield = null; while (itr.hasNext()) { ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next(); if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type) > -1) { xml.append(" <th>" + cfi.label + "</th>\n"); if (sortfield == null) { sortfield = cfi.name.toLowerCase(); } } } xml.append(" </tr></thead>\n"); xml.append( " <xsl:for-each select=\"" + c1.getSimpleName().toLowerCase() + "\">\n"); xml.append(" <xsl:sort select=\"" + sortfield + "\" order=\"descending\"/>\n"); xml.append(" <tr>\n"); itr = cef.values().iterator(); while (itr.hasNext()) { ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next(); if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type) > -1) { if (cfi.type.equals("byte[]") || cfi.type.equals("base64Binary")) { xml.append(" <td><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></td>\n"); } else { if (cfi.type.equalsIgnoreCase("decimal")) { xml.append(" <td><xsl:value-of select=\"format-number(" + cfi.name.toLowerCase() + ",'###,###,##0.00')\"/></td>\n"); } else { xml.append(" <td><pre><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></pre></td>\n"); } //xml.append(" <td><xsl:value-of select=\""+cfi.name.toLowerCase()+"\"/></td>\n"); } } } xml.append(" </tr>\n"); xml.append(" </xsl:for-each>\n"); xml.append(" </table>\n\n"); //xml.append(" </xsl:if>\n"); xml.append(" <div class=\"clear\"></div>\n"); xml.append(" </div>\n"); xml.append(" </fieldset>\n"); xml.append(" </div>\n"); xml.append(" <!--- END OF print" + childname + " CHILD CODE SEGMENT -->\n\n"); } } } xml.append("</div>\n"); xml.append("<!--- END OF print" + c.getSimpleName() + " LIST SEGMENT -->\n\n"); // as well as the print friendly version xml.append("<!--- START OF print" + c.getSimpleName() + " CODE SEGMENT -->\n"); xml.append("<div class=\"hidden\" id=\"print" + c.getSimpleName() + "\">\n"); xml.append("<!--- dont show the printing and editing divs -->\n"); xml.append( "<script language=\"JavaScript\">hidedivDisplay('edit" + c.getSimpleName() + "');</script>\n"); xml.append( "<script language=\"JavaScript\">hidedivDisplay('print" + c.getSimpleName() + "');</script>\n"); xml.append("<script language=\"JavaScript\">hidedivDisplay('printlist" + c.getSimpleName() + "');</script>\n"); xml.append("<fieldset>\n"); xml.append("<legend>View " + c.getSimpleName().substring(0, c.getSimpleName().length() - 4) + "</legend>\n"); xml.append("<div class=\"fieldsetwrap\">\n"); xml.append(" <div class=\"datafieldwrap\">\n"); xml.append(" <table class=\"datafield\">\n"); if (ce != null) { Map cef = ce.getFields(); Iterator itr = cef.values().iterator(); while (itr.hasNext()) { ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next(); if (cfi.visible && _types.indexOf(cfi.type) > -1) { if (cfi.type.equalsIgnoreCase("decimal")) { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"><xsl:value-of select=\"format-number(" + cfi.name.toLowerCase() + ",'###,###,##0.00')\"/></td></tr>\n"); } else { xml.append(" <tr><td class=\"lbl\">" + cfi.label + ":</td><td class=\"data full\"><pre><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></pre></td></tr>\n"); } //xml.append(" <th>"+cfi.label+"</th>\n"); } } } else { it = fields.keys(); while (it.hasMoreElements()) { String f = (String) it.nextElement(); String t = (String) fields.get(f); if (t.equalsIgnoreCase("decimal")) { xml.append(" <tr><td class=\"lbl\">" + f + ":</td><td class=\"data full\"><xsl:value-of select=\"format-number(" + f.toLowerCase() + ",'###,###,##0.00')\"/></td></tr>\n"); } else { xml.append(" <tr><td class=\"lbl\">" + f + ":</td><td class=\"data full\"><pre><xsl:value-of select=\"" + f.toLowerCase() + "\"/></pre></td></tr>\n"); } } } xml.append(" </table>\n"); xml.append(" </div>\n"); xml.append("</div>\n"); xml.append("</fieldset>\n"); xml.append("</div>\n"); xml.append("<div class=\"clear\"></div>\n"); xml.append("<!--- END OF print" + c.getSimpleName() + " CODE SEGMENT -->\n\n"); // if this is a prototype for an empty record if (type == 2) { System.out.println("NO PROTOTYPE FOR " + c.getSimpleName()); } xml.append("<!--- START OF " + c.getSimpleName() + " LIST SEGMENT -->\n"); xml.append("<div id=\"list" + c.getSimpleName() + "\">\n\n"); // then we get the complex types! for (int i = 0; i < m.length; i++) { name = m[i].getName(); retval = m[i].getReturnType().getName(); // what if this is a list? if (retval.endsWith("List")) { String getter = m[i].getName(); Method met = c.getMethod(getter, (Class[]) null); ParameterizedType t = (ParameterizedType) met.getGenericReturnType(); Class c1 = (Class) t.getActualTypeArguments()[0]; String childname = m[i].getName().substring(3); childname = childname.substring(0, 1).toUpperCase() + childname.substring(1); String clsname = indexable(c1.getSimpleName()) ? "Flex" + c1.getSimpleName() : c1.getSimpleName(); xml.append(" <!--- START OF " + childname + " LIST CODE SEGMENT -->\n"); xml.append(" <div id=\"child" + childname + "\">\n"); xml.append(" <fieldset>\n"); xml.append(" <legend>" + childname + " List</legend>\n"); xml.append(" <div class=\"fieldsetwrap\">\n"); xml.append(" <div style=\"overflow:auto; height:200px;\">\n"); xml.append(" <table class=\"sortable\">\n"); ConfigElement ce2 = config.getElementConfig(c1.getSimpleName()); Map cef = ce2.getFields(); Iterator itr = cef.values().iterator(); xml.append(" <thead><tr>\n"); String sortfield = null; while (itr.hasNext()) { ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next(); if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type) > -1) { xml.append(" <th>" + cfi.label + "</th>\n"); if (sortfield == null) { sortfield = cfi.name.toLowerCase(); // by default the first column } } } xml.append(" </tr></thead>\n"); xml.append(" <xsl:for-each select=\"" + c1.getSimpleName().toLowerCase() + "\">\n"); xml.append(" <xsl:sort select=\"" + sortfield + "\" order=\"descending\"/>\n"); xml.append(" <tr>\n"); itr = cef.values().iterator(); while (itr.hasNext()) { ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next(); if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type) > -1) { if (cfi.type.equals("byte[]") || cfi.type.equals("base64Binary")) { xml.append(" <td><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></td>\n"); } else { if (cfi.type.equalsIgnoreCase("decimal")) { xml.append(" <td><xsl:value-of select=\"format-number(" + cfi.name.toLowerCase() + ",'###,###,##0.00')\"/></td>\n"); } else { xml.append(" <td><pre><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></pre></td>\n"); } } } } /*Hashtable v = getFields(c1.newInstance()); Enumeration it2 = v.keys(); xml.append(" <thead><tr>\n"); while (it2.hasMoreElements()) { String f2 = (String) it2.nextElement(); xml.append(" <th>"+f2+"</th>\n"); } xml.append(" </tr></thead>\n"); it2 = v.keys(); xml.append(" <xsl:for-each select=\""+childname+"\">\n"); xml.append(" <tr>\n"); while (it2.hasMoreElements()) { String f2 = (String) it2.nextElement(); String t2 = (String) v.get(f2); if (t2.equals("byte[]")) { xml.append(" <td><xsl:value-of select=\""+f2+"\"/></td>\n"); } else { xml.append(" <td><xsl:value-of select=\""+f2+"\"/></td>\n"); } } */ xml.append(" </tr>\n"); xml.append(" </xsl:for-each>\n"); xml.append(" </table>\n"); xml.append(" </div>\n"); xml.append(" <div id=\"list" + childname + "buttons\">\n\n"); xml.append(" <input type=\"button\" value=\"View " + childname + " List\" onClick=\"" + (message != null ? "hidedivDisplay('message');" : "") + "javascript:linkchangecontent('get" + clsname + "WithParentID.igx?id={../@id}&do=savecontext&" + c1.getSimpleName().toLowerCase() + "parent=get" + c.getSimpleName() + ".igx&" + c1.getSimpleName().toLowerCase() + "parentname=" + c.getSimpleName().substring(0, c.getSimpleName().length() - 4) + "&" + c1.getSimpleName().toLowerCase() + "parentid=<%var_request[id]%>&from=0&to=15','contentdyn')\"/>\n"); xml.append(" <input type=\"button\" value=\"New " + childname + "\" onClick=\"" + (message != null ? "hidedivDisplay('message');" : "") + "javascript:linkchangecontent('new" + clsname + ".htm?id={../@id}&do=savecontext&" + c1.getSimpleName().toLowerCase() + "parent=get" + c.getSimpleName() + ".igx&" + c1.getSimpleName().toLowerCase() + "parentname=" + c.getSimpleName().substring(0, c.getSimpleName().length() - 4) + "&" + c1.getSimpleName().toLowerCase() + "parentid=<%var_request[id]%>','contentdyn')\"/>\n"); xml.append(" </div>\n\n"); xml.append(" <div class=\"clear\"></div>\n"); xml.append(" </div>\n\n"); xml.append(" </fieldset>\n"); xml.append(" </div>\n"); xml.append(" <!--- END OF " + childname + " LIST CODE SEGMENT -->\n\n"); } else { if ("int,boolean".indexOf(retval) < 0 && !retval.startsWith("java") && !retval.equals("void") && !retval.equals("[B")) { String getter = m[i].getName(); Method met = c.getMethod(getter, (Class[]) null); Class c1 = (Class) met.getGenericReturnType(); String childname = m[i].getName().substring(3); childname = childname.substring(0, 1).toUpperCase() + childname.substring(1); String clsname = indexable(c1.getSimpleName()) ? "Flex" + c1.getSimpleName() : c1.getSimpleName(); xml.append(" <!--- START OF SINGLETON " + childname + " CHILD CODE SEGMENT -->\n"); xml.append(" <div id=\"child" + c.getSimpleName() + "\">\n"); xml.append(" <fieldset>\n"); xml.append(" <legend>" + childname + "</legend>\n"); xml.append(" <div class=\"fieldsetwrap\">\n"); xml.append(" <div style=\"overflow:auto; height:200px;\">\n"); xml.append(" <table class=\"sortable\">\n"); ConfigElement ce2 = config.getElementConfig(c1.getSimpleName()); Map cef = ce2.getFields(); Iterator itr = cef.values().iterator(); xml.append(" <thead><tr>\n"); String sortfield = null; while (itr.hasNext()) { ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next(); if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type) > -1) { xml.append(" <th>" + cfi.label + "</th>\n"); if (sortfield == null) { sortfield = cfi.name.toLowerCase(); } } } xml.append(" </tr></thead>\n"); xml.append( " <xsl:for-each select=\"" + c1.getSimpleName().toLowerCase() + "\">\n"); xml.append(" <xsl:sort select=\"" + sortfield + "\" order=\"descending\"/>\n"); xml.append(" <tr>\n"); itr = cef.values().iterator(); while (itr.hasNext()) { ConfigFieldInfo cfi = (ConfigFieldInfo) itr.next(); if (cfi.visible && cfi.showinlist && _types.indexOf(cfi.type) > -1) { if (cfi.type.equals("byte[]") || cfi.type.equals("base64Binary")) { xml.append(" <td><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></td>\n"); } else { if (cfi.type.equalsIgnoreCase("decimal")) { xml.append(" <td><xsl:value-of select=\"format-number(" + cfi.name.toLowerCase() + ",'###,###,##0.00')\"/></td>\n"); } else { xml.append(" <td><pre><xsl:value-of select=\"" + cfi.name.toLowerCase() + "\"/></pre></td>\n"); } } } } /*Hashtable v = getFields(c1.newInstance()); Enumeration it2 = v.keys(); xml.append(" <thead><tr>\n"); while (it2.hasMoreElements()) { String f2 = (String) it2.nextElement(); xml.append(" <th>"+f2+"</th>\n"); } xml.append(" </tr></thead>\n"); it2 = v.keys(); xml.append(" <xsl:for-each select=\""+childname+"\">\n"); xml.append(" <tr>\n"); while (it2.hasMoreElements()) { String f2 = (String) it2.nextElement(); String t2 = (String) v.get(f2); if (t2.equals("byte[]")) { xml.append(" <td><xsl:value-of select=\""+f2+"\"/></td>\n"); } else { xml.append(" <td><xsl:value-of select=\""+f2+"\"/></td>\n"); } } */ xml.append(" </tr>\n"); xml.append(" </xsl:for-each>\n"); xml.append(" </table>\n"); xml.append(" </div>\n\n"); xml.append(" <div id=\"list" + childname + "buttons\">\n\n"); xml.append(" <input type=\"button\" value=\"View " + childname + "\" onClick=\"" + (message != null ? "hidedivDisplay('message');" : "") + "javascript:linkchangecontent('get" + clsname + "WithParentID.igx?id={../@id}&do=savecontext&" + c1.getSimpleName().toLowerCase() + "parent=get" + c.getSimpleName() + ".igx&" + c1.getSimpleName().toLowerCase() + "parentname=" + c.getSimpleName() + "&" + c1.getSimpleName().toLowerCase() + "parentid=<%var_request[id]%>','contentdyn')\"/>\n"); xml.append(" <input type=\"button\" value=\"Create " + childname + "\" onClick=\"" + (message != null ? "hidedivDisplay('message');" : "") + "javascript:linkchangecontent('new" + clsname + ".htm?id={../@id}','contentdyn')\"/>\n"); xml.append(" </div>\n\n"); xml.append(" <div class=\"clear\"></div>\n"); xml.append(" </div>\n"); xml.append(" </fieldset>\n"); xml.append(" </div>\n"); xml.append(" <!--- END OF SINGLETON " + childname + " CHILD CODE SEGMENT -->\n\n"); } } } xml.append("</div>\n"); xml.append("<!--- END OF " + c.getSimpleName() + " LIST SEGMENT -->\n\n"); xml.append("</xsl:template>\n\n"); } return xml.toString(); }