Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Using validator we can hide a tab.
Below is the code and article:
https://www.ptc.com/en/support/article/CS333921?source=search
________________
package ext.test.changerequest.validators;
import java.rmi.RemoteException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.ptc.core.ui.validation.DefaultUIComponentValidator;
import com.ptc.core.ui.validation.UIValidationCriteria;
import com.ptc.core.ui.validation.UIValidationKey;
import com.ptc.core.ui.validation.UIValidationStatus;
import wt.change2.WTChangeRequest2;
import wt.fc.Persistable;
import wt.fc.WTReference;
import wt.util.WTException;
public class HideChangeRequestNewTab extends DefaultUIComponentValidator {
private static final Logger logger = LogManager.getLogger(HideChangeRequestNewTab.class.getName());
@Override
public UIValidationStatus preValidateAction(UIValidationKey validationKey,
UIValidationCriteria validationCriteria) {
// Call to Super() to perform basic validation and initialize the result
UIValidationStatus result = super.preValidateAction(validationKey, validationCriteria);
// Get the current object from the context.
WTReference contextObj = validationCriteria.getContextObject();
Persistable object = contextObj.getObject();
WTChangeRequest2 req = null;
String changeType = "";
req = (WTChangeRequest2) object;
try {
changeType = wt.type.TypedUtilityServiceHelper.service.getLocalizedTypeName(req)
.getLocalizedMessage(wt.session.SessionHelper.getLocale());
System.out.println("Type =" + changeType);
} catch (RemoteException | WTException e) {
logger.debug("Exception in HideChangeRequestNewTab file " + e);
}
if (changeType.equalsIgnoreCase("Change Request")) {
result = UIValidationStatus.ENABLED;
} else {
result = UIValidationStatus.HIDDEN;
}
return result;
}
}
Using validator we can hide a tab.
Below is the code and article:
https://www.ptc.com/en/support/article/CS333921?source=search
________________
package ext.test.changerequest.validators;
import java.rmi.RemoteException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.ptc.core.ui.validation.DefaultUIComponentValidator;
import com.ptc.core.ui.validation.UIValidationCriteria;
import com.ptc.core.ui.validation.UIValidationKey;
import com.ptc.core.ui.validation.UIValidationStatus;
import wt.change2.WTChangeRequest2;
import wt.fc.Persistable;
import wt.fc.WTReference;
import wt.util.WTException;
public class HideChangeRequestNewTab extends DefaultUIComponentValidator {
private static final Logger logger = LogManager.getLogger(HideChangeRequestNewTab.class.getName());
@Override
public UIValidationStatus preValidateAction(UIValidationKey validationKey,
UIValidationCriteria validationCriteria) {
// Call to Super() to perform basic validation and initialize the result
UIValidationStatus result = super.preValidateAction(validationKey, validationCriteria);
// Get the current object from the context.
WTReference contextObj = validationCriteria.getContextObject();
Persistable object = contextObj.getObject();
WTChangeRequest2 req = null;
String changeType = "";
req = (WTChangeRequest2) object;
try {
changeType = wt.type.TypedUtilityServiceHelper.service.getLocalizedTypeName(req)
.getLocalizedMessage(wt.session.SessionHelper.getLocale());
System.out.println("Type =" + changeType);
} catch (RemoteException | WTException e) {
logger.debug("Exception in HideChangeRequestNewTab file " + e);
}
if (changeType.equalsIgnoreCase("Change Request")) {
result = UIValidationStatus.ENABLED;
} else {
result = UIValidationStatus.HIDDEN;
}
return result;
}
}