Skip to main content
14-Alexandrite
January 25, 2023
Solved

Introduce a new tab in WTDocument Page

  • January 25, 2023
  • 1 reply
  • 1771 views

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

Best answer by HelesicPetr

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

1 reply

HelesicPetr
22-Sapphire II
22-Sapphire II
January 25, 2023

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

Sha1114-AlexandriteAuthor
14-Alexandrite
January 25, 2023

@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?