一、效果
二、代码
public class ClassificationSelectableDataUtility extends AbstractDataUtility {
@Override
public Object getDataValue(String component_id, Object datum, ModelContext mc) throws WTException {
LWCStructEnumAttTemplate lwcsea = (LWCStructEnumAttTemplate) datum;
String objectOid = PersistenceHelper.getObjectIdentifier(lwcsea).getStringValue();
boolean isEndCls = isEndClassification(lwcsea);
Object component = getEnabledStatus(component_id, isEndCls, lwcsea.getName(), objectOid);
return component;
}
public static boolean isEndClassification(LWCStructEnumAttTemplate clsTemp) throws WTException{
String returnValue = "false";
boolean isSelectable = true;
String sqlForInstantiable = "";
long clsTempIda2a2= clsTemp.getPersistInfo().getObjectIdentifier().getId();
System.out.println(" >> clsTemp="+clsTemp.getName());
sqlForInstantiable = " "+
" select v.classnamekeyb4 , v.ida3b4, v.value "+
" from LWCPropertyValue v, lwcpropertydefinition d "+
" where v.ida3a4 = d.ida2a2 and "+
" d.name='instantiable' and "+
" v.ida3b4="+clsTempIda2a2+" ";
WTConnection connection = null;
PreparedStatement prepareStatement = null;
ResultSet rs = null;
try {
connection = (WTConnection) MethodContext.getContext().getConnection();
prepareStatement = connection.prepareStatement(sqlForInstantiable);
rs = prepareStatement.executeQuery();
while(rs.next()){
returnValue = rs.getString(3);
}
} catch (Exception e) {
e.printStackTrace();
}finally{
if(rs != null) try{rs.close();}catch (Exception e2) {}
if(prepareStatement != null) try{prepareStatement.close();}catch (Exception e2) {}
}
if("true".equalsIgnoreCase(returnValue)){
isSelectable = true;
}else if("false".equalsIgnoreCase(returnValue)){
isSelectable = false;
}
return isSelectable;
}
private GUIComponentArray getEnabledStatus(String strId, boolean isEdit, String internalName, String objectOid) {
GUIComponentArray gui_array = new GUIComponentArray();
if (isEdit) {
RadioButton checkBox;
checkBox = new RadioButton();
checkBox.setName(strId);
checkBox.setId(strId);
checkBox.setChecked(false);
checkBox.setEditable(isEdit);
checkBox.addJsAction("onClick", "classificationChecked('"+strId+"','"+internalName+"','"+objectOid+"')");
gui_array.addGUIComponent(checkBox);
}
return gui_array;
}
}