Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Translate the entire conversation x

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

WT_010219
10-Marble

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

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 

7 REPLIES 7
avillanueva
22-Sapphire II
(To:WT_010219)

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?

Daniel_Ada
13-Aquamarine
(To:WT_010219)

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>

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
(To:WT_010219)

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 

HelesicPetr
22-Sapphire II
(To:WT_010219)

Hi @WT_010219 

Just add annother point.

Are you sure that you have loaded the right JS library where the function exists?

PTC.validation.AJAXPostSelectValidation

It seams that the function is not called at all because it is not loaded on the page. main.js

 

Also I would recommend to avoid using any OOTB names for the selectors

change the selector to different one. WSEXPORT -> EXT_WSEXPORT 

PetrH

Hello @HelesicPetr ,

 

Thanks for your reply.

1. I used function PTC.validation.AJAXPostSelectValidation  which is OOTB by PTC and implemented as per article : https://community.ptc.com/t5/Windchill-Customization/post-select-validation-is-not-getting-called-on-click-of-custom/m-p/993992

2. I will recheck for selector to be use.

 

Reply to your message above :

1. The action is enable correctly by my validator , please see screenshot :

LB_10619520_0-1738330833609.png

2. I am able to enable/disable action as per logic using my validator. but I want to trigger it once user click on action and give popup error to user based on logic. that's why I used "validateSelectedAction" method, isn't it correct ??

 

please help me if you know how do I achieve this ? with JSP or without JSP ?

 

Thanks in advance. 

 

 

 

HelesicPetr
22-Sapphire II
(To:WT_010219)

Hi @WT_010219 

As I said. You use the OOTB name selector WSEXPORT 

that can be the issue why your class is not called at all. 

the reason is that ootb validator class is called. 

Control it twice 😄 

PetrH

Announcements
Top Tags