public static com.xdarkness.member.Member setPropValues( com.xdarkness.member.Member member, Mapx Request) { ZDMemberSchema m = new ZDMemberSchema(); String siteID = ""; m.setUserName(member.getUserName()); if (m.fill()) siteID = m.getSiteID() + ""; else { siteID = Request.getString("SiteID"); } m = setPropValues(m, Request, siteID); member.setValue(m.toMapx()); return member; }
public static String getColumnAndValue(ZDMemberSchema member) { DataTable dt = new QueryBuilder( "select * from ZDMemberField where SiteID = ? order by AddTime asc", member.getSiteID()) .executeDataTable(); String Columns = ""; for (int i = 0; i < dt.getRowCount(); i++) { Columns = Columns + getColumn(dt.getDataRow(i), member, dt.getString(i, "RealField")); } return Columns; }
public static ZDMemberSchema setPropValues(ZDMemberSchema member, Mapx map, String SiteID) { ZDMemberFieldSchema field = new ZDMemberFieldSchema(); ZDMemberFieldSet set = field.query(new QueryBuilder(" where SiteID = ?", SiteID)); for (int i = 0; i < set.size(); i++) { String Value = ""; String RealField = ""; String Code = ""; field = new ZDMemberFieldSchema(); field = set.get(i); Code = field.getCode(); RealField = field.getRealField(); Value = map.getString("_MC_" + Code); map.put(RealField, Value); } member.setValue(map); return member; }
private static String getColumn(DataRow dr, ZDMemberSchema member, String realField) { String columnName = dr.getString("Name"); String columnCode = dr.getString("Code"); String inputType = dr.getString("InputType"); String verifyType = dr.getString("VerifyType"); String listOption = dr.getString("ListOption"); String defaultValue = dr.getString("DefaultValue"); String isMandatory = dr.getString("IsMandatory"); String maxLength = dr.getString("MaxLength"); String HTML = dr.getString("HTML"); String verifyStr = "verify='" + columnName + "|"; if ("Y".equals(isMandatory)) { verifyStr = verifyStr + "NotNull"; } if (!STRING.equals(verifyType)) { if (NUMBER.equals(verifyType)) verifyStr = verifyStr + "&&Number"; else if (INT.equals(verifyType)) verifyStr = verifyStr + "&&Int"; else if (EMAIL.equals(verifyType)) verifyStr = verifyStr + "&&Email"; } if ((XString.isNotEmpty(maxLength)) && (!"0".equals(maxLength))) verifyStr = verifyStr + "&&Length<" + maxLength + "'"; else { verifyStr = verifyStr + "'"; } if ((member != null) && (realField != null)) { Mapx map = member.toMapx(); defaultValue = map.getString(realField); if (XString.isEmpty(defaultValue)) { defaultValue = ""; } } columnCode = "_MC_" + columnCode; StringBuffer sb = new StringBuffer(); sb.append("<tr><td height='25' align='right' >"); sb.append(columnName); sb.append(":</td><td align='left' >"); if (inputType.equals(Input)) { sb.append( "<input type='text' size='26' id='" + columnCode + "' name='" + columnCode + "' value='" + defaultValue + "' " + verifyStr + " />"); } if (inputType.equals(Text)) { sb.append( "<textarea style='width:" + dr.getString("ColSize") + "px;height:" + dr.getString("RowSize") + "px' id='" + columnCode + "' name='" + columnCode + "' " + verifyStr + ">" + defaultValue + "</textarea>"); } if (inputType.equals(Selecter)) { SelectTag select = new SelectTag(); select.setId(columnCode); if ("Y".equals(isMandatory)) { select.setVerify(columnName + "|NotNull"); } String[] array = listOption.split("\\n"); sb.append(select.getHtml(HtmlUtil.arrayToOptions(array, defaultValue, true))); } if (inputType.equals(Radio)) { String[] array = listOption.split("\\n"); if ((XString.isEmpty(defaultValue)) && (array.length > 0)) { defaultValue = array[0]; } sb.append(HtmlUtil.arrayToRadios(columnCode, array, defaultValue)); } if (inputType.equals(Checkbox)) { String[] array = listOption.split("\\n"); defaultValue = defaultValue.replaceAll(" ", ","); defaultValue = defaultValue.replaceAll(" ", ","); defaultValue = defaultValue.replaceAll(" ", ","); defaultValue = defaultValue.replaceAll(" ", ","); defaultValue = defaultValue.replaceAll(",,", ","); defaultValue = defaultValue.replaceAll(",,", ","); defaultValue = defaultValue.replaceAll(",", ","); String[] checkedArray = defaultValue.split(","); sb.append(HtmlUtil.arrayToCheckboxes(columnCode, array, checkedArray)); } if (inputType.equals(DateInput)) { sb.append( "<input name='" + columnCode + "' id='" + columnCode + "' value='" + defaultValue + "' type='text' size='20' xtype='Date' " + verifyStr + " />"); } if (inputType.equals(TimeInput)) { sb.append( "<input name='" + columnCode + "' id='" + columnCode + "' value='" + defaultValue + "' type='text' size='10' xtype='Time' " + verifyStr + " />"); } if (inputType.equals(HTMLInput)) { sb.append(HTML); } sb.append("</td></tr>"); return sb.toString(); }