cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

how do I programatically hide a tab on the Part Info page

smorrison
3-Newcomer

how do I programatically hide a tab on the Part Info page

I would like to have an attribute control the display of a custom tab on the Part info page.

So:

1) if I add a Boolean attribute called 'Is Pair'

2) if the 'Is Pair' = false  Then   the 'Pair' tab will NOT be displayed

a) After the part is checked in

b) When the Info page is navigated to

3) if the 'Is Pair' = true Then   the 'Pair' tab will be displayed

a) After the part is checked in

b) When the Info page is navigated to

Thanks for the help

SRM

8 REPLIES 8

Hi Scott,

Is the additional tab you created is added through Customization (action model) or created using New Tab > Customize option available out of the box?

Thanks,

Shirish

Good question.

It will be added through Customization (action model).

Scott

Hi Scott Morrison,

To achieve this you can write your own validator which will first get IBA value from WTPart. Once you have IBA value you can then decide whether to display or hide custom tab.

Your validator code will looks something like below:

public class HideCustomTab extends  DefaultUIComponentValidator {

  /* (non-Javadoc)

  * @see com.ptc.core.ui.validation.DefaultUIComponentValidator#performFullPreValidation(com.ptc.core.ui.validation.UIValidationKey, com.ptc.core.ui.validation.UIValidationCriteria, java.util.Locale)

  */

  @Override

  public UIValidationResultSet performFullPreValidation(UIValidationKey vkey, UIValidationCriteria vcriteria, Locale locale) throws WTException {

  return validateCustomTab(vkey, vcriteria, locale);

  }

  /* (non-Javadoc)

  * @see com.ptc.core.ui.validation.DefaultUIComponentValidator#performLimitedPreValidation(com.ptc.core.ui.validation.UIValidationKey, com.ptc.core.ui.validation.UIValidationCriteria, java.util.Locale)

  */

  @Override

  public UIValidationResultSet performLimitedPreValidation(UIValidationKey vkey, UIValidationCriteria vcriteria, Locale locale) throws WTException {

  return validateCustomTab(vkey, vcriteria, locale);

  }

  public UIValidationResultSet validateCustomTab(UIValidationKey vkey, UIValidationCriteria vcriteria, Locale locale) throws WTException {

  UIValidationResultSet vrs = UIValidationResultSet.newInstance();

  UIValidationResult vr = UIValidationResult.newInstance();

  vr.setValidationKey(vkey);

  // Below API will give you the actual object.

  WTReference wref = vcriteria.getPageObject();

  Persistable PObj = wref.getObject();

  if (PObj instanceof WTPart) {

  WTPart prt = (WTPart) PObj;

  PersistableAdapter theIBAs = new PersistableAdapter(prt, null, java.util.Locale.US, new UpdateOperationIdentifier());

  theIBAs.load("EnumValue");

  java.lang.Boolean ibaObject = Boolean.parseBoolean(theIBAs.get("EnumValue").toString());

  if (ibaObject) {

  vrs.addResult(UIValidationResult.newInstance(vkey, UIValidationStatus.ENABLED));

  }else{

  vrs.addResult(UIValidationResult.newInstance(vkey, UIValidationStatus.HIDDEN));

  }

  }

  return vrs;

  }

}

To hook this validator you can add below entry to site.xconf file and propagate changes by "xconfmanager -p" command:

<Service context="default" name="com.ptc.core.ui.validation.UIComponentValidator"

            targetFile="codebase/service.properties">

      <Option cardinality="singleton" order="0" overridable="true" requestor="null"

              selector="CustomTab4Part"

              serviceClass="ext.Validators.HideCustomTab"/>

   </Service>

Restart MS server and you're all set.

If IBA has value true, then Custom Tab will be displayed otherwise it will be hidden.

     Custom Tab.png

I hope this helps you!

Regards,

Shirish

Shirish,

This approach and code makes sense.

I will give this a try on Monday.

Thanks for the help.

Scott

We have same issue. We have added the tab using configuration, not using action model. In that case how to hide the tab, we have no idea which user has created that tab. Could you please suggest something around this.

Hi @AbhinavKr ,

As an Admin (wcadmin or Administrator) user you can go to information page of this object type where the tab is added > Right click on it and say either "Delete Tab" or "Set Private"

 

Hope this helps.

 

Regards,

Shirish

Hi Shirish,

 

We deleted tab using admin user but it is not hiding for other user.

 

Do you know in which table in database tabs entries inserted.We have full database access we can delete it from DB as well.  But DB table name we are not sure in which table these tabs entries go.

AbhinavKr
6-Contributor
(To:AbhinavKr)

Resolved - ClientTab Table store the information about the custom/configurable tab. From this table we can get the user name who has created and other details.

Announcements

Top Tags