DataUtility 入门教程二[按钮:Button]
来源:互联网 发布:手机淘宝怎么交电费 编辑:程序博客网 时间:2024/05/23 01:55
一、效果
二、代码
public class MideaNoAttrClassificationPickerDataUtility extends AbstractDataUtility {@Override public Object getDataValue(String component_id, Object datum, ModelContext modelcontext) throws WTException { NmCommandBean commandBean = modelcontext.getNmCommandBean(); Object component = null; ComponentMode componentMode = modelcontext.getDescriptorMode(); if (componentMode.equals(ComponentMode.EDIT) || componentMode.equals(ComponentMode.CREATE)) { component = createPickerComponent(component_id, datum, modelcontext, componentMode); } else { com.ptc.core.components.rendering.guicomponents.Label lable = new com.ptc.core.components.rendering.guicomponents.Label(""); String rawValue = (String) modelcontext.getRawValue(); if (rawValue != null) { LWCStructEnumAttTemplate claObj = MPLUtil.getLWCStructEnumAttTemplateByName(rawValue); String resPath = ClassificationQueryUtil.getClassificationPath(claObj); lable.setValue(resPath); component = lable; } } return component; } private Object createPickerComponent(String component_id, Object datum, ModelContext mc, ComponentMode componentMode) throws WTException { ArrayList<GuiComponent> components = new ArrayList<GuiComponent>(); //默认值 String rawValue = (String) mc.getRawValue(); if(rawValue == null){ rawValue = ""; } TextBox clsPageState11 = createTextBox("", componentMode); clsPageState11.setId("=="); clsPageState11.setName("=="); clsPageState11.setInputType("hidden"); clsPageState11.setHidden(true); String hiddenDefaultValue11 = "============="; clsPageState11.setValue(hiddenDefaultValue11);//设置默认值 components.add(clsPageState11); /***** TEXT BOX for data store *****/ TextBox textBoxForStore = createTextBox(component_id, componentMode); textBoxForStore.setId(component_id); //textBoxForStore.setName(component_id); textBoxForStore.setInputType("hidden"); textBoxForStore.setColumnName(AttributeDataUtilityHelper.getColumnName(component_id, datum, mc)); textBoxForStore.setValue(rawValue);//设置默认值 components.add(textBoxForStore); /***** TEXT BOX for data display *****/ TextBox textBoxDisplay = createTextBox(component_id + "_display", componentMode); textBoxDisplay.setId(component_id + "_display"); textBoxDisplay.setName(component_id + "_display"); textBoxDisplay.setEnabled(true); textBoxDisplay.setEditable(true); textBoxDisplay.setReadOnly(true); textBoxDisplay.setRequired(isRequired(mc, component_id)); //textBoxDisplay.setColumnName(AttributeDataUtilityHelper.getColumnName(component_id, datum, mc)); LWCStructEnumAttTemplate claObj = null; String resPath = ""; if (!(rawValue ==null || rawValue.equals(""))) {//设置默认全路径名称 try{ claObj = MPLUtil.getLWCStructEnumAttTemplateByName(rawValue); if(claObj==null){ textBoxDisplay.setValue(rawValue+"(错误分类!)"); }else{ resPath = ClassificationQueryUtil.getClassificationPath(claObj); textBoxDisplay.setValue(resPath); } }catch (Exception e) { e.printStackTrace(); textBoxDisplay.setValue(rawValue+"(错误分类!)"); } } components.add(textBoxDisplay); // //如果有默认值,则增加隐藏字段,在页通过此隐藏字段决定是否显示分类页面。// if (rawValue != null && !rawValue.equals("")) {// if(claObj!=null){// TextBox clsPageState = createTextBox("", componentMode);// clsPageState.setId("_id_has_Cls_Value_");// clsPageState.setName("_has_Cls_Value_");// clsPageState.setInputType("hidden");// clsPageState.setHidden(true);// String hiddenDefaultValue = "{'clsInternalName':'" + claObj.getName() + "', 'clsOid':'" + PersistenceHelper.getObjectIdentifier(claObj).getStringValue() + "'," + " 'componentId':'"// + component_id + "' }";// clsPageState.setValue(hiddenDefaultValue);//设置默认值// components.add(clsPageState);// }// } //String imgClean = "netmarkets/images/clear_16x16.gif"; String host = com.midea.issue.ConstantResource.host; String url = "javascript:window.open('" + host + "netmarkets/jsp/midea/common/noAttrClassificationSelectorWizardHome.jsp?componentId=" + component_id + "','','toolbar=no,menubar=no,location=no,status=no,resizable=yes')"; IconComponent picker = new IconComponent("Search..."); picker.setName("Search..."); picker.setSrc("netmarkets/images/search.gif"); picker.setId(component_id + "_picker"); picker.addJsAction("onClick", url); picker.addJsAction("href", "javascript:void(0)"); components.add(picker); IconComponent iconComponentClean = new IconComponent("Clean..."); iconComponentClean.setName("Clean..."); iconComponentClean.setSrc("netmarkets/images/clear_16x16.gif"); iconComponentClean.addJsAction("onClick", "javascript:cleanMideaClsValue('" + component_id + "','" + component_id + "_display')"); iconComponentClean.addJsAction("href", "javascript:void(0)"); components.add(iconComponentClean); return new GUIComponentArray(components); } private Object displayDataUtility(String component_id, Object datum, ModelContext mc) throws WTException { String value = ""; Label inheritedFrom = new Label(""); inheritedFrom.setColumnName(AttributeDataUtilityHelper.getColumnName(component_id, datum, mc)); inheritedFrom.setId(component_id); String oids = (String) mc.getRawValue(); if (oids != null) { String[] oidArray = oids.split(";"); for (int i = 0; i < oidArray.length; i++) { String oid = oidArray[i]; ReferenceFactory rf = new ReferenceFactory(); Persistable p = rf.getReference(oid).getObject(); if (p instanceof WTDocumentMaster) { WTDocumentMaster docMaster = (WTDocumentMaster) p; if (i == 0) { value = docMaster.getNumber(); } else { value = value + ";" + docMaster.getNumber(); } } } } inheritedFrom.setValue(value); return inheritedFrom; } private TextBox createTextBox(String component_id, ComponentMode componentMode) throws WTException { TextBox text = new TextBox(); text.setMaxLength(200); text.setWidth(30); text.setId(component_id); //text.setEditable(isComponentEditable(component_id, componentMode)); return text; } private static boolean isRequired(ModelContext mc, String attrName) { boolean flag = false; TypeIdentifier typeIden = null; try { typeIden = mc.getTypeIdentifier(); List<String> ret = getIBAConstraintBySofttypeIBA(typeIden, attrName); for (String contString : ret) { if (contString.indexOf("ValueRequiredConstraint") > -1) { flag = true; break; } } } catch (WTException e) { e.printStackTrace(); } return flag; } private static List<String> getIBAConstraintBySofttypeIBA( TypeIdentifier typeIden, String attrname) throws WTException { List<String> ret = new ArrayList<String>(); TypeDefinitionReadView tdrv = TypeDefinitionServiceHelper.service .getTypeDefView(typeIden); AttributeDefinitionReadView adrv = tdrv.getAttributeByName(attrname); if (adrv == null) { return ret; } Collection<ConstraintDefinitionReadView> constraints = adrv .getAllConstraints(); for (ConstraintDefinitionReadView constraint : constraints) { ConstraintRuleDefinitionReadView crdrv = constraint.getRule(); if (crdrv != null) { String defClassname = crdrv.getDefClassname(); String ruleClassName = crdrv.getRuleClassname(); String constraintStr = defClassname + ":" + ruleClassName; ret.add(constraintStr); } } return ret; }}
0 0
- DataUtility 入门教程二[按钮:Button]
- DataUtility 入门教程二[按钮:RadioButton]
- ExtJs 入门教程六[按钮:Button]
- ExtJs 入门教程六[按钮:Button]
- DataUtility 入门教程一[下拉列表:Combobox]
- 无废话ExtJs 入门教程六[按钮:Button]
- 无废话ExtJs 入门教程六[按钮:Button]
- 按钮控件 Button Controls(二)
- 学习Button按钮控件(二)
- ActiveReport入门教程(二) - 单选按钮
- Android基础入门教程——2.3.3 Button(按钮)与ImageButton(图像按钮)
- jQuery 入门教程(27): jQuery UI Button示例(二)
- jQuery 入门教程(27): jQuery UI Button示例(二)
- Button 按钮
- Button按钮
- Button(按钮)
- 按钮 Button
- Button 按钮
- 泛型与EnumMap使用例子
- Android蓝牙开发的一些经验
- vba批量将一个文件夹内的多个同格式的工作薄中的数据合并
- Oracle自增列创建方法
- 11、Container With Most Water
- DataUtility 入门教程二[按钮:Button]
- 最大子序列和
- iOS 的事件处理 响应者链
- JS解析json数据并将json字符串转化为数组的实现方法
- C++中关于将对象赋值给整形的过程。
- 同余定理:poj2769 Reduced ID Numbers(标记数组)+hdu1021 Fibonacci Again(应用于递推公式)
- 简单的天气预报 (四)
- 关于labview的事件结构不循环问题
- Android各种蓝牙设备的UUID