Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Hello All,
We have one functionality "Part Number Generator" in Customization tab which helps the users to have a certain set of part numbers in store for them if they want to create new WTParts.
Now I want to restrict certain users from using this functionality, either hide the functionality or disable the option.
Please instruct me on how to proceed.
P.S: I have done customization in Java code but not so much with the jsp and js and all.
Thanks and Regards,
Hari R
Solved! Go to Solution.
You have to create an action validation filter. I attached you an example to hide the action for all users except org and site admin.
xconf
<Service context="default" name="com.ptc.core.ui.validation.SimpleValidationFilter" targetFile="codebase/service.properties">
<Option requestor="null"
selector="hideForNonOrgOrSiteAdmins"
serviceClass="xxx.validators.HideFromNonOrgOrSiteAdminActionValidation"/>
</Service>
Java Class
package xxx.validators;
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 lombok.extern.slf4j.Slf4j;
/**
* Hides an action for all user except Org and Site administrators
*/
@Slf4j
public class HideFromNonOrgOrSiteAdminActionValidation extends DefaultSimpleValidationFilter {
@Override
public UIValidationStatus preValidateAction(UIValidationKey uiValidationKey,
UIValidationCriteria uiValidationCriteria) {
if (log.isTraceEnabled()) {
log.trace(" validtionKey -> " + uiValidationKey);
log.trace(" validationCriteria -> " + uiValidationCriteria.toString());
}
UIValidationStatus uiValidationStatus = UIValidationStatus.HIDDEN;
if (uiValidationCriteria.isSiteAdmin() || uiValidationCriteria.isOrgAdmin()) {
uiValidationStatus = UIValidationStatus.ENABLED;
}
return uiValidationStatus;
}
}
Include filter for action (name is defined in xconf property)
<action ajax="page"
name="xxx">
<command class="xxx"
method="execute"
url="xxx.jsp"
windowType="popup"/>
<includeFilter name="hideForNonOrgOrSiteAdmins"/>
</action>
You have to create an action validation filter. I attached you an example to hide the action for all users except org and site admin.
xconf
<Service context="default" name="com.ptc.core.ui.validation.SimpleValidationFilter" targetFile="codebase/service.properties">
<Option requestor="null"
selector="hideForNonOrgOrSiteAdmins"
serviceClass="xxx.validators.HideFromNonOrgOrSiteAdminActionValidation"/>
</Service>
Java Class
package xxx.validators;
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 lombok.extern.slf4j.Slf4j;
/**
* Hides an action for all user except Org and Site administrators
*/
@Slf4j
public class HideFromNonOrgOrSiteAdminActionValidation extends DefaultSimpleValidationFilter {
@Override
public UIValidationStatus preValidateAction(UIValidationKey uiValidationKey,
UIValidationCriteria uiValidationCriteria) {
if (log.isTraceEnabled()) {
log.trace(" validtionKey -> " + uiValidationKey);
log.trace(" validationCriteria -> " + uiValidationCriteria.toString());
}
UIValidationStatus uiValidationStatus = UIValidationStatus.HIDDEN;
if (uiValidationCriteria.isSiteAdmin() || uiValidationCriteria.isOrgAdmin()) {
uiValidationStatus = UIValidationStatus.ENABLED;
}
return uiValidationStatus;
}
}
Include filter for action (name is defined in xconf property)
<action ajax="page"
name="xxx">
<command class="xxx"
method="execute"
url="xxx.jsp"
windowType="popup"/>
<includeFilter name="hideForNonOrgOrSiteAdmins"/>
</action>