Windchill MVC組件開發

  1. 註冊Action
    通常是在WT_HOME/codebase/config/actions/custom-actionModels.xml在這裏插入圖片描述
    界面效果:
    在這裏插入圖片描述
  2. Action指向頁面
    在這裏插入圖片描述
    組件註冊:
    在這裏插入圖片描述
  3. MVC組件定義
    在這裏插入圖片描述
    前臺頁面效果:
    在這裏插入圖片描述
  4. 對應後臺代碼
    在這裏插入圖片描述

數據處理方法:
在這裏插入圖片描述
組件定義,以及列定義的方法:

@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. 前後臺對接,前臺輸入參數或者頁面初始化,調用後臺,數據加載到組件中
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章