- 註冊Action
通常是在WT_HOME/codebase/config/actions/custom-actionModels.xml
界面效果:
- Action指向頁面
組件註冊:
- MVC組件定義
前臺頁面效果:
- 對應後臺代碼
數據處理方法:
組件定義,以及列定義的方法:
@Override
public ComponentConfig buildComponentConfig(ComponentParams params) throws WTException {
if (log.isDebugEnabled()) {
log.debug("WhereUsedTreeBuilder - Entering buildComponentConfig");
}
if (log.isTraceEnabled()) {
log.trace("WhereUsedTreeBuilder.buildComponentConfig input params " + params);
}
String whereUsedTableID = "";
NmHelperBean helper = ((JcaComponentParams) params).getHelperBean();
NmCommandBean commandBean = (NmCommandBean) helper.getNmCommandBean();
NmSessionBean sessionBean = helper.getNmSessionBean();
ComponentConfigFactory factory = getComponentConfigFactory();
JcaTreeConfig treeConfig = (JcaTreeConfig) factory.newTreeConfig();
Object context = commandBean.getPageOid().getRef();
// boolean configurable = false;
// if the context object is in a project, set the table values appropriately (do
// not show the drop down, and make the table view to "Latest" only
if (EnterpriseHelper.isProjectLink((Persistable) context)) {
whereUsedTableID = "whereUsed";
}
// if the context object is not in a project, set the table values appropriately
// (show the drop down,
// and make the table view to "Latest" and "All Revisions"
else {
whereUsedTableID = "whereUsed.view";
}
if (commandBean.getTextParameter("viewchange") != null) {
sessionBean.removeAllNodes(commandBean, "whereUsed.view");
}
params.setAttribute("whereUsedTableID", whereUsedTableID);
treeConfig.setId(whereUsedTableID);
treeConfig.setShowCustomViewLink(false);
treeConfig.setNodeColumn(DescriptorConstants.ColumnIdentifiers.NUMBER);
treeConfig.setExpansionLevel(DescriptorConstants.TableTreeProperties.FULL_EXPAND);
treeConfig.setTargetObject("contextObject");
treeConfig.setLabel(messageWhereUsedResource.getMessage(PartListSearchResource.PRIVATE_CONSTANT_CS_6));
treeConfig.setSelectable(true);
treeConfig.setActionModel("whereUsedTablePart");
log.debug("set Tree setSelectable & ExpansionLevel is true,NodeColumn is NUMBER.");
// Define the columns present for when no view is used
ColumnConfig col = factory.newColumnConfig(DescriptorConstants.ColumnIdentifiers.NUMBER, true);
col.setWidth(200);
col.setInfoPageLink(false);
col.setDataUtilityId("whereUsedNumber");
treeConfig.addComponent(col);
col =factory.newColumnConfig(DescriptorConstants.ColumnIdentifiers.ORG_ID, false);
treeConfig.addComponent(col);
col = factory.newColumnConfig(DescriptorConstants.ColumnIdentifiers.NAME, true);
col.setWidth(799);
treeConfig.addComponent(col);
col =factory.newColumnConfig("PL_NUMBER", true);
col.setWidth(200);
col.setDataUtilityId("PartListSearchDataUtility");
treeConfig.addComponent(col);
col = factory.newColumnConfig(DescriptorConstants.ColumnIdentifiers.VERSION, false);
col.setDataUtilityId("PartListSearchDataUtility");
col.setWidth(100);
treeConfig.addComponent(col);
col =factory.newColumnConfig(DescriptorConstants.ColumnIdentifiers.STATE, true);
col.setWidth(100);
treeConfig.addComponent(col);
col = factory.newColumnConfig(DescriptorConstants.ColumnIdentifiers.CONTAINER_NAME, true);
col.setWidth(200);
col.setTargetObject("contained");
treeConfig.addComponent(col);
// end of column definition
treeConfig.setHelpContext("WhereUsedTableHelp");
treeConfig.setDataSourceMode(DataSourceMode.ASYNCHRONOUS);
System.out.println("end of column definition," + treeConfig.getComponents());
return treeConfig;
}
節點數據處理的方法
@Override
public void buildNodeData(Object node, ComponentResultProcessor resultProcessor) throws Exception {
// special case for root nodes
if (node == TreeNode.RootNode) {
treeHandler = new WhereUsedTreeHandler(resultProcessor.getParams());
if(treeHandler.getRootNodes()!=null) {
// should fetch rootNodes and to ResultProcessor
resultProcessor.addElements(treeHandler.getRootNodes());
}
}
// case for any other node
else {
List nodeList = new ArrayList();
nodeList.add(node);
if (treeHandler == null) {
treeHandler = new WhereUsedTreeHandler(resultProcessor.getParams());
}
Map<Object, List> map = treeHandler.getNodes(nodeList);
Set keySet = map.keySet();
for (Object key : keySet) {
resultProcessor.addElements(map.get(key));
}
}
}
6. 前後臺對接,前臺輸入參數或者頁面初始化,調用後臺,數據加載到組件中