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 the Community Ranking System, a fun gamification element of the PTC Community. X

How to create Custom Table in Custom Tab with MVC. Need really help :-)

dwallys
1-Visitor

How to create Custom Table in Custom Tab with MVC. Need really help :-)

Hi Guys,

I have a question to a topic which is currently really annoying me. I tried to create a custom table with MVC at first like described in this PTC Article:

https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS113931

(I also tried the Customization Guide Windchill 10.1 M50 from page 590 to 627 and page 264 to 291. But I didn't bring a step forward.)

It sounds very simple to me, so I tried to realize it in my testing instance. Just to see how a new table integration works in Windchill. I have done that before only in Windchill 9.1 with JSP code. Point 4 and 5 are not so clear to me so I have done it like shown in the screenshots. For point 4 see screenshot3_custom-actions.xml. For point 5 I tried two options, first with the custom-actionmodel.xml and second with the PartClient-actionsmodels.xml directly (see screenshot4 and screenshot5)I. But both options don't give me a table in die relations tab in Parts. In screenshot 6 you can see the registering of the custombuilder in the /mvc/custom.xml file. All steps did not bring me success. My code can be seen in screenshot2.

My goal at the end is to create a tab manually in die system via the GUI and use the customize button to add my custom table (see screenshot1). My custom table should show WTChangeActivity2 objects which are linked to a document which I would like to realize with the method ChangeHelper2.service.getAffectingChangeActivities.

Thank you for all your help in advance. Small hints are also welcome as a detailed description 😉

Best Regards,

Daniel

4 REPLIES 4
tbaltes
1-Visitor
(To:dwallys)

Hi Daniel -  Did you create a resource bundle for your custom action?  You will need that to get a custom action to display.

lmouchard
12-Amethyst
(To:dwallys)

Hi Daniel,

could you get it work as you expected? I would be really interested to know the key steps for implementing such a customization.

Best Regards,

Loïc

Marcika
7-Bedrock
(To:dwallys)

Hi Daniel,

To add a new tab with custom Table I did the followings:

(//code changes to you components, name…etc)

1.       Your component builder Java Code:

package ext.abb.dmpc.builders.table;

import com.ptc.mvc.components.AbstractComponentBuilder;

import com.ptc.mvc.components.ColumnConfig;

import com.ptc.mvc.components.ComponentBuilder;

import com.ptc.mvc.components.ComponentConfig;

import com.ptc.mvc.components.ComponentConfigFactory;

import com.ptc.mvc.components.ComponentParams;

import com.ptc.mvc.components.TableConfig;

import com.ptc.mvc.util.ClientMessageSource;

import ext.abb.dmpc.builders.table.utils.TableHelper;

import wt.util.WTException;

// This annotation is VERY important.

@ComponentBuilder("ext.com.builders.table.RelatedCompanionPartsTableBuilder")

public class RelatedCompanionPartsTableBuilder extends AbstractComponentBuilder{

 

   private static final String RESOURCE = "ext.com.CustomTabRB";

   private final ClientMessageSource messageSource = getMessageSource(RESOURCE);

 

   @Override

   public ComponentConfig buildComponentConfig(ComponentParams paramComponentParams) throws WTException {

          //get the ComponentConfigFactory

          ComponentConfigFactory factory = getComponentConfigFactory();

          //get an instance of TableConfig

          TableConfig table = factory.newTableConfig();

          // General table properties

          table.setId("ext.com.builders.table.RelatedCompanionPartsTableBuilder");

          table.setSelectable(true);

          table.setLabel(messageSource.getMessage("COMPANION_PARTS"));

          table.setShowCount(true);

          table.setActionModel("mvc_tables_toolbar");

        

          //add columns

          //name

          ColumnConfig col1 = factory.newColumnConfig("name", true);

          table.addComponent(col1);

        

          //number

          ColumnConfig col2 = factory.newColumnConfig("number", false);

          col2.setInfoPageLink(true);

          table.addComponent(col2);

          //type

          ColumnConfig col3 = factory.newColumnConfig("type", true);

          table.addComponent(col3);

          // Last Modified

          ColumnConfig col4 = factory.newColumnConfig("thePersistInfo.modifyStamp", true);

          table.addComponent(col4);

        

          // If you want different column name as Display name, use setLabel("New Name") function on column

          // If you data as link use setInfoPageLink(true) function on column

 

          return table;

   }

   @Override

   public Object buildComponentData(ComponentConfig paramComponentConfig, ComponentParams paramComponentParams) throws Exception {

        

          // your code which return a Query result containing the desired Parts

        

   }

}

In your other custom Table builder use the annotation: @ComponentBuilder("ext.com.builders.table.RelatedChangeActivitiesTableBuilder”);

2.       Define custom actions in custom-action.xml

wtCustom\codebase\config\actions\custom-action.xml

<!-- actions for tgt object type -->

   <objecttype name="tgt" class=""

          resourceBundle="ext.CustomTabRB">

          <action name="relatedCompanionParts" uicomponent="COMPANION_PARTS"

                 resourceBundle="ext.com.CustomTabRB" required="true">

                 <component

                 name="ext.com.builders.table.RelatedCompanionPartsTableBuilder " />

          </action>

          <action name="relatedChangeActivities" uicomponent="CHANGE_ACTIVITIES"

                 resourceBundle="ext.com.CustomTabRB" required="true">

                 <component

                 name="ext.com.builders.table.RelatedChangeActivitiesTableBuilder" />

          </action>

   </objecttype>

3.       Define A new custom action in InfoPage-actiomodels.xml in the section where you want the new menu item to appear:

<action name="relatedCompanionParts" type="tgt"/> <!-- Companion Part -->

<action name="relatedChangeActivities" type="tgt"/> <!—Change Activities -->

4.       Adding a custom TAB

Create a new TAB as you did in your screentshot1_xxx.png

Rename is as you wish.

Export the tabs from Windchill Shell using the with the command

java com.ptc.core.ui.ixb.ClientTabExport “My Custom Tab”.

A jar file will be exported which contain all tabs with the name “My Custom Tab”.

Change the content of the XML (TAG-ClientTab-0.xml) or create (MyCustomTab.xml) it manually as follows:

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE ClientTab SYSTEM "standardX24.dtd">

<ClientTab>

<csvname>My Custom Tab</csvname>

<csvobjtype>wt.part.WTPart</csvobjtype>

<csvtabsetkey>infoPage</csvtabsetkey>

<csvcomponents>[{&quot;name&quot;:&quot;relatedCompanionParts&quot;,&quot;type&quot;:&quot;tgt&quot;},{&quot;name&quot;:&quot;relatedChangeActivities&quot;,&quot;type&quot;:&quot;tgt&quot;}]</csvcomponents>

<csvparentContainerPath>/</csvparentContainerPath>

</ClientTab>

The changed/ created XML can be imported with the following command:

windchill wt.load.LoadFromFile -d "D:\ MyCustomTab.xml.xml" -CONT_PATH "/" -u “user” -p “password”

5.       RB File

Create a custom RB file where you have all the new texts:

@RBUUID("ext.CustomTabRB")

public class CustomTabRB extends WTListResourceBundle

{

// component link text    

@RBEntry("Related Companion Parts")

public static final String PRIVATE_CONSTANT_1 = "tgt.relatedCompanionParts.description";

     

// component link text

@RBEntry("Related Change Activities")

public static final String PRIVATE_CONSTANT_2 = "tgt.relatedChangeActivities.description";

     

// table title

@RBEntry("Related Companion Parts ")

public static final String HEAD_PROMOTIONS_HISTORY = "COMPANION_PARTS";

     

// table title

@RBEntry("Related Change Activities ")

public static final String MEMBER_PROMOTIONS_HISTORY = "CHANGE_ACTIVITIES";

}

6.       Changes is custom.xml

In custom.xml (wtCustom\codebase\config\mvc\custom.xml) ad the following line:

       <bean class="ext.com.builders.table.RelatedCompanionPartsTableBuilder"/>

       <bean class="ext.com.builders.table.RelatedChangeActivitiesTableBuilder"/>

7.      Rebuild, Synchronize eclipse, restart server….

Hi,

As much as possible, try to use the jcaDebug=1 option in the URL to find out what actions.xml and action-models.xml are used and follow the same steps as in the OOTB code. This will help.

Announcements

Top Tags