12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- /*
- * Created on 2006-6-8 Administrator
- */
- package com.sysmodel.xformmodel.importcontrol;
- import java.util.List;
- import com.sysmodel.XFormFactory;
- import com.sysmodel.XFormModel;
- import com.sysmodel.datamodel.xmlmodel.DataContent;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- import com.sysmodel.datamodel.xmlmodel.able.MdpConstant;
- import com.sysmodel.datamodel.xmlmodel.able.Property;
- import com.sysmodel.datamodel.xmlmodel.able.SysModel;
- import com.sysmodel.xformmodel.able.Validate;
- public class RadioControl extends AbstractControl{
- private String constantName = "";
- private boolean singleLine = false;
- private static XFormModel XFormModel = XFormFactory.getXFormModel();
- public String produceHtml(String name, String value, String displayValue, Validate Validate) {
- StringBuffer sb = new StringBuffer();
- String appendBr = singleLine ? "" : "<br>";
- String FontTextCss = XFormModel.getCSSValue("FontTextCss");
- FontTextCss = FontTextCss.equals("") ? "" : " class=\"" + FontTextCss + "\"";
- SysModel sysmodel = ModelFactory.getSysmodel();
- MdpConstant element = sysmodel.getMdpConstantByName(constantName);
- Property uniqueProperty = element.getTemplate().getUniqueProperty();
- List<DataContent> list = element.getListDataContent();
- if (value.equals("")) {
- for (int i = 0; i < list.size(); i++) {
- DataContent content = list.get(i);
- String currentValue = content.getValue(uniqueProperty.getName()).toString();
- sb.append("<input type=\"radio\"");
- sb.append(" dojoType=\"" + Validate.getDojoShowType() + "\" ");
- sb.append("name=\"" + name + "\" value=\"").append(currentValue + "\">");
- sb.append("<font" + FontTextCss).append(">");
- sb.append(element.convertDisplayString(content));
- sb.append("</font>");
- if (list.size() != i + 1)
- sb.append(appendBr);
- }
- } else {
- for (int i = 0; i < list.size(); i++) {
- DataContent content = list.get(i);
- String currentValue = content.getValue(uniqueProperty.getName()).toString();
- sb.append("<input type=\"radio\" name=\"");
- if (currentValue.equals(value))
- sb.append(name + "\" checked value=\"").append(currentValue + "\">");
- else
- sb.append(name + "\" value=\"").append(currentValue + "\">");
- sb.append("<font" + FontTextCss).append(">");
- sb.append(element.convertDisplayString(content));
- sb.append("</font>");
- if (list.size() != i + 1)
- sb.append(appendBr);
- }
- }
- return sb.toString();
- }
- public String getConstantName() {
- return constantName;
- }
- public void setConstantName(String constantName) {
- this.constantName = constantName;
- }
- public boolean isSingleLine() {
- return singleLine;
- }
- public void setSingleLine(boolean singleLine) {
- this.singleLine = singleLine;
- }
- }
|