Skip to main content
10-Marble
January 17, 2025
Question

post select validation is not getting called on click of custom action menu

  • January 17, 2025
  • 2 replies
  • 1058 views

Hello @DeepakParihar ,

 

I want to validate action once user select/clicks on it.

 

custom-actoin.xml : I registered the my class as below also update Onclick info.

 

<objecttype name="pdmObject" class="wt.fc.WTObject" >
 <action checkaccess="true" name="WSEXPORT" enabledwhensuspended="true" renderType="PDM" >
 <command class="ext.epm.validator.ValidateWSEXPORT" onClick="PTC.validation.AJAXPostSelectValidation(event, 'WSEXPORT')" method="WSEXPORT" windowType="page"/>
 </action>
	</objecttype>

 

 My class is as follow :

 

public class ValidateWSEXPORT extends DefaultUIComponentValidator {
	protected static final Logger logger = LogR.getLogger(ValidateWSEXPORT.class.getName());
	@Override
	public UIValidationResult validateSelectedAction(UIValidationKey vKey, UIValidationCriteria vCriteria,
			Locale locale) throws WTException {

		// TODO Auto-generated method stub
		System.out.println("---------- ValidateWSEXPORT Validation Started-----------");
		UIValidationResult result = UIValidationResult.newInstance(vKey, UIValidationStatus.ENABLED);

		WTReference reference = vCriteria.getContextObject();
		Object obj = reference.getObject();
		float fileSizeKB = checkPrimaryContent(obj);
		if (fileSizeKB >= 100.00) {
			result = UIValidationResult.newInstance(vKey, UIValidationStatus.DISABLED);
			System.out.println("---------- WSEXPORT action is DISABLED-----------");
		}

		return result;

	}

 

 

Validator is still not triggered once I click on WSEXPORT action.

Can you please help me ?

 

Reference topic: https://community.ptc.com/t5/Windchill-Customization/post-select-validation-is-not-getting-called-on-click-of-custom/m-p/993992 

2 replies

avillanueva
23-Emerald I
23-Emerald I
January 17, 2025

I might be wrong but this is not exactly how I think it should be setup. The command class is what you want to run when they click it but that is not a validator. A validator is something that enables or disables the action as the action dropdown is rendered. What does this action look like when you look at it with jcaDebug=true?

13-Aquamarine
January 20, 2025

I'm not sure if adding the validator method to the command is feasible, the way I'm using it is by registering the validator

<Service context="default"
 targetFile="codebase/service.properties"
			 name="com.ptc.core.ui.validation.UIComponentValidator">
		<Option requestor="null"
				serviceClass="ext.emp.validator.ValidateWSEXPOPRT"
				selector="WSEXPORT"
				cardinality="singleton" />
	</Service>
WT_01021910-MarbleAuthor
10-Marble
January 20, 2025

Hello @avillanueva  @Daniel_Ada ,

Thanks for your reply.

Yes , I have registered my validator as below

<Service context="default"
 targetFile="codebase/service.properties"
			 name="com.ptc.core.ui.validation.UIComponentValidator">
		<Option requestor="null"
				serviceClass="ext.emp.validator.ValidateWSEXPOPRT"
				selector="WSEXPORT"
				cardinality="singleton" />
	</Service>

 

I was referring the post : https://community.ptc.com/t5/Windchill-Customization/post-select-validation-is-not-getting-called-on-click-of-custom/m-p/939278. so tried replicating the custom-action.xml syntax provided there. 

 

but, I now even having :

<objecttype name="pdmObject" class="wt.fc.WTObject" >
 <action checkaccess="true" name="WSEXPORT" enabledwhensuspended="true" renderType="PDM" >
 <command method="WSEXPORT" class="java.lang.Object" windowType="page" onClick="PTC.validation.AJAXPostSelectValidation(event, 'WSEXPORT')" />
 </action>
</objecttype>

 

The action is resisted to validator successfully, but it didn't triggered.

LB_10619520_0-1737355239718.png

 

 

HelesicPetr
22-Sapphire II
22-Sapphire II
January 20, 2025

Hi @WT_010219 

Do you know that it is triggered just during a page refresh or Right Mouse Button click on the menu?

How do you know it is not triggered? because it has to be triggered if it is enabled by this validator.

 

PS> this validator just enable or disable the function during loading. It is not called if user click on the function.

 

be careful how you call the functions because based on the information's, you expect that the validator is called when user clicks on the function but this way it does not work. 

If you need to validate different things like data consistency, then you have to call it from a wizard page or jsp page that is opened with his action. 

 

PetrH