e35255029119a2a1dd1908e0577d659bef3cc682.svn-base 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Created on 2006-6-8 Administrator
  3. */
  4. package com.sysmodel.xformmodel.importcontrol;
  5. import java.util.List;
  6. import com.sysmodel.XFormFactory;
  7. import com.sysmodel.XFormModel;
  8. import com.sysmodel.datamodel.xmlmodel.DataContent;
  9. import com.sysmodel.datamodel.xmlmodel.ModelFactory;
  10. import com.sysmodel.datamodel.xmlmodel.able.MdpConstant;
  11. import com.sysmodel.datamodel.xmlmodel.able.Property;
  12. import com.sysmodel.datamodel.xmlmodel.able.SysModel;
  13. import com.sysmodel.xformmodel.able.Validate;
  14. public class RadioControl extends AbstractControl{
  15. private String constantName = "";
  16. private boolean singleLine = false;
  17. private static XFormModel XFormModel = XFormFactory.getXFormModel();
  18. public String produceHtml(String name, String value, String displayValue, Validate Validate) {
  19. StringBuffer sb = new StringBuffer();
  20. String appendBr = singleLine ? "" : "<br>";
  21. String FontTextCss = XFormModel.getCSSValue("FontTextCss");
  22. FontTextCss = FontTextCss.equals("") ? "" : " class=\"" + FontTextCss + "\"";
  23. SysModel sysmodel = ModelFactory.getSysmodel();
  24. MdpConstant element = sysmodel.getMdpConstantByName(constantName);
  25. Property uniqueProperty = element.getTemplate().getUniqueProperty();
  26. List<DataContent> list = element.getListDataContent();
  27. if (value.equals("")) {
  28. for (int i = 0; i < list.size(); i++) {
  29. DataContent content = list.get(i);
  30. String currentValue = content.getValue(uniqueProperty.getName()).toString();
  31. sb.append("<input type=\"radio\"");
  32. sb.append(" dojoType=\"" + Validate.getDojoShowType() + "\" ");
  33. sb.append("name=\"" + name + "\" value=\"").append(currentValue + "\">");
  34. sb.append("<font" + FontTextCss).append(">");
  35. sb.append(element.convertDisplayString(content));
  36. sb.append("</font>");
  37. if (list.size() != i + 1)
  38. sb.append(appendBr);
  39. }
  40. } else {
  41. for (int i = 0; i < list.size(); i++) {
  42. DataContent content = list.get(i);
  43. String currentValue = content.getValue(uniqueProperty.getName()).toString();
  44. sb.append("<input type=\"radio\" name=\"");
  45. if (currentValue.equals(value))
  46. sb.append(name + "\" checked value=\"").append(currentValue + "\">");
  47. else
  48. sb.append(name + "\" value=\"").append(currentValue + "\">");
  49. sb.append("<font" + FontTextCss).append(">");
  50. sb.append(element.convertDisplayString(content));
  51. sb.append("</font>");
  52. if (list.size() != i + 1)
  53. sb.append(appendBr);
  54. }
  55. }
  56. return sb.toString();
  57. }
  58. public String getConstantName() {
  59. return constantName;
  60. }
  61. public void setConstantName(String constantName) {
  62. this.constantName = constantName;
  63. }
  64. public boolean isSingleLine() {
  65. return singleLine;
  66. }
  67. public void setSingleLine(boolean singleLine) {
  68. this.singleLine = singleLine;
  69. }
  70. }