cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Introduce a new tab in WTDocument Page

Sha11
14-Alexandrite

Introduce a new tab in WTDocument Page

Hello,

 

I want to introduce a new tab under a specific type of WTDocument page and populate it with some of the attributes, could you shed some light on how to approach this requirement?

 

Thanks,

Sha

ACCEPTED SOLUTION

Accepted Solutions

I forgot mention very important point.

 

You should create own Validation class where you check if the action should be shown in the detailpage of your WTDocument subtype 

 

definition in customaction

 

<action name="ownJSPPageTab"  >
<component name="cz.aveng.NewDocTab.DetailTabBuilder" windowType="page" />
<includeFilter name="hideDocValidator"/>
</action>

 

 

definition in service.properties

wt.services/svc/default/com.ptc.core.ui.validation.SimpleValidationFilter/hideDocValidator/null/0=cz.aveng.NewDocTab.DocValidator/duplicate

 

this validator hide the action if the subtype document is not "DOCINTERNALSUBSTRING" internal name ends with this string

validator class 

 

package cz.aveng.NewDocTab;

import com.ptc.core.ui.validation.DefaultSimpleValidationFilter;
import com.ptc.core.ui.validation.UIValidationCriteria;
import com.ptc.core.ui.validation.UIValidationKey;
import com.ptc.core.ui.validation.UIValidationStatus;
import wt.fc.Persistable;
import wt.fc.WTReference;
import wt.type.TypedUtilityServiceHelper;
import wt.util.WTException;
import wt.wvs.WVSLogger;

import java.rmi.RemoteException;

public class DocValidator extends DefaultSimpleValidationFilter
{
	private static final WVSLogger logger = WVSLogger.getLogger(DocValidator.class, "cz.aveng.DocValidator");

	public DocValidator()
	{
	}

	public UIValidationStatus preValidateAction(UIValidationKey valKey, UIValidationCriteria criteria)
	{
		UIValidationStatus validatioNStatus = UIValidationStatus.ENABLED;
		WTReference contextObject = criteria.getContextObject();
		if (contextObject != null)
		{
			Persistable persistObject = contextObject.getObject();
			String subtypeString = null;
			try
			{
				// get object type 
				subtypeString = TypedUtilityServiceHelper.service.getExternalTypeIdentifier(persistObject);

				//
				if (!subtypeString.endsWith("DOCINTERNALSUBSTRING"))
				{
					validatioNStatus = UIValidationStatus.HIDDEN;
				}
			} catch (WTException | RemoteException e)
			{
				e.printStackTrace();
			}
		}

		logger.debug("Exit DocValidator.preValidateAction()  status=" + validatioNStatus);
		return validatioNStatus;
	}
}

 

 

PetrH

View solution in original post

5 REPLIES 5
HelesicPetr
22-Sapphire I
(To:Sha11)

Hi @Sha11 

You need to define own JSP page and crate action definition in the customAction and customActionModel

 

definition in customAction

<objecttype name="MYACTIONS">
		<action name="ownJSPPageTab"  >
			<component name="cz.aveng.NewDocTab.DetailTabBuilder" windowType="page" />
		</action>
	</objecttype>

Put the action to the customActionModel to show in the document tab menu  

third_level_nav_doc

   <model name="third_level_nav_doc" defaultActionName="iterationHistory" defaultActionType="history">
       <submodel name="general"/>
       <submodel name="relatedItems"/>
       <submodel name="changes"/>
       <submodel name="history"/>
       <submodel name="collaboration"/>
       <submodel name="security3rdnav"/>                <!-- Security -->
       <submodel name="configLinks"/>
       <submodel name="thingworxCustomizeMenu"/>
       <submodel name="quality"/>
       <action name="ownJSPPageTab" type="MYACTIONS"/>
   </model>

HelesicPetr_0-1674650064107.png

 

 

the builder class 

package cz.aveng.NewDocTab;

import com.ptc.mvc.components.*;
import org.apache.logging.log4j.Logger;
import wt.util.WTException;

@ComponentBuilder(value = "cz.aveng.NewDocTab.DetailTabBuilder", type = ComponentBuilderType.CONFIG_AND_DATA)
public class DetailTabBuilder extends AbstractComponentBuilder
{
	protected static Logger logger = ShowChangesInBOMLogger.GetShowChangesInBOMLogger();

	@Override
	public ComponentConfig buildComponentConfig(ComponentParams componentParams) throws WTException
	{
		MultiComponentConfig multiComp = new MultiComponentConfig();
		//multiComp.addNestedComponent("cz.aveng.AVChangeInBOM.AVFilterBuilder");
		multiComp.addNestedComponent("cz.aveng.NewDocTab.TreeBuilder");
		multiComp.setView("/cz/aveng/NewDocTab/DetailTabBuilder.jsp");

		return multiComp;
	}

	@Override
	public Object buildComponentData(ComponentConfig componentConfig, ComponentParams componentParams) throws Exception
	{
		return null;
	}
}

 

NestedComponent is definition of table or attribute panel builder.. 

 

PetrH

Sha11
14-Alexandrite
(To:HelesicPetr)

@HelesicPetr  - Thank you for the info, will try to implement by following your steps. Could you let me know if there is any article or link which could provide more information on the implementation that you have mentioned?

@Sha11 

JSP Example>

<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="wt.lifecycle.LifeCycleTemplate" %>
<%@ page import="wt.lifecycle.LifeCycleHelper" %>
<%@ page import="java.util.Vector" %>
<%@ page import="wt.lifecycle.State" %>
<%@ page import="wt.fc.Persistable" %>
<%@ page import="com.ptc.netmarkets.model.NmOid" %>
<%@ page import="wt.part.WTPart" %>
<%@ page import="wt.lifecycle.LifeCycleManaged" %>
<%@ taglib uri="http://www.ptc.com/windchill/taglib/jcaMvc" prefix="mvc"%>
<%@ taglib prefix="wrap" uri="http://www.ptc.com/windchill/taglib/wrappers" %>


<%@include file="/netmarkets/jsp/util/begin_comp.jspf"%>
<mvc:tree/>
<%@ include file="/netmarkets/jsp/util/end_comp.jspf"%>

 

PetrH

I forgot mention very important point.

 

You should create own Validation class where you check if the action should be shown in the detailpage of your WTDocument subtype 

 

definition in customaction

 

<action name="ownJSPPageTab"  >
<component name="cz.aveng.NewDocTab.DetailTabBuilder" windowType="page" />
<includeFilter name="hideDocValidator"/>
</action>

 

 

definition in service.properties

wt.services/svc/default/com.ptc.core.ui.validation.SimpleValidationFilter/hideDocValidator/null/0=cz.aveng.NewDocTab.DocValidator/duplicate

 

this validator hide the action if the subtype document is not "DOCINTERNALSUBSTRING" internal name ends with this string

validator class 

 

package cz.aveng.NewDocTab;

import com.ptc.core.ui.validation.DefaultSimpleValidationFilter;
import com.ptc.core.ui.validation.UIValidationCriteria;
import com.ptc.core.ui.validation.UIValidationKey;
import com.ptc.core.ui.validation.UIValidationStatus;
import wt.fc.Persistable;
import wt.fc.WTReference;
import wt.type.TypedUtilityServiceHelper;
import wt.util.WTException;
import wt.wvs.WVSLogger;

import java.rmi.RemoteException;

public class DocValidator extends DefaultSimpleValidationFilter
{
	private static final WVSLogger logger = WVSLogger.getLogger(DocValidator.class, "cz.aveng.DocValidator");

	public DocValidator()
	{
	}

	public UIValidationStatus preValidateAction(UIValidationKey valKey, UIValidationCriteria criteria)
	{
		UIValidationStatus validatioNStatus = UIValidationStatus.ENABLED;
		WTReference contextObject = criteria.getContextObject();
		if (contextObject != null)
		{
			Persistable persistObject = contextObject.getObject();
			String subtypeString = null;
			try
			{
				// get object type 
				subtypeString = TypedUtilityServiceHelper.service.getExternalTypeIdentifier(persistObject);

				//
				if (!subtypeString.endsWith("DOCINTERNALSUBSTRING"))
				{
					validatioNStatus = UIValidationStatus.HIDDEN;
				}
			} catch (WTException | RemoteException e)
			{
				e.printStackTrace();
			}
		}

		logger.debug("Exit DocValidator.preValidateAction()  status=" + validatioNStatus);
		return validatioNStatus;
	}
}

 

 

PetrH

Announcements

Top Tags