Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
To create a link "Test" in Header ribbon to launch an internet page as a popup window:
The above task could be a very simple one for Windchill developers, but for the benifit of beginners like me, I had tried to shortly list out the steps to be done for this task as per my learning and understanding:
1. Define Action model related to the header items:
Refer to the section "header actions" in the file <Windchill_HOME>\codebase\config\actions\navigation-actionModels.xml
Below would be the default content:
<model name="header actions">
<description>actions that appear in the top right of the header</description>
<action name="clipboard" type="netmarkets"/>
<action name="separator" type="separator"/>
<action name="globalWindchillHelp" type="netmarkets"/>
<action name="separator" type="separator"/>
<action name="emailPage" type="project"/>
<action name="separator" type="separator"/>
<action name="hotList" type="user"/>
</model>
Copy the above content onto the below file:
<Windchill_HOME>\codebase\config\actions\custom-actionModels.xml
The above file may or may not contain information related to customizations done for your company.
Add new action name "Test" in this section as below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE actionmodels SYSTEM "actionmodels.dtd">
<actionmodels>
<model name="header actions">
<description>actions that appear in the top right of the header</description>
<action name="clipboard" type="netmarkets"/>
<action name="separator" type="separator"/>
<action name="globalWindchillHelp" type="netmarkets"/>
<action name="separator" type="separator"/>
<action name="emailPage" type="project"/>
<action name="separator" type="separator"/>
<action name="hotList" type="user"/>
<action name="separator" type="separator"/>
<action name="Test" type="netmarkets"/>
</model>
</actionmodels>
The above list defines the order of links that appears in the header ribbon at top right.
Save the file.
2. Define the details for the action:
Refer to the file <Windchill_HOME>\codebase\config\actions\navigation-actions.xml for how the details of the action are defined.
Edit the below file:
<Windchill_HOME>\codebase\config\actions\custom-actions.xml
Again, the above file may or may not contain information related to customizations done for your company.
Add the details for the action "Test" as below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE listofactions SYSTEM "actions.dtd">
<listofactions>
<objecttype name="netmarkets" class="" resourceBundle="com.your_company.UIRB">
<action name="Test" enabledwhensuspended="true" renderType="GENERAL">
<command url="/netmarkets/jsp/com/your_company/UI.jsp" windowType="popup"/>
</action>
</objecttype>
</listofactions>
The above definitons may be different as per specific requirements.
resourceBundle (com.your_company.UIRB) would have definitions on what text should appear for the link, what tooltip should appear and so on. This is explained in next section.
command url would be used for execution on hitting the link.
3. Define the Resource Bundle:
Refer to <Windchill_HOME>\src\com\ptc\core\ui\navigationRB.rbInfo for how the details for the link are defined.
Create the below file:
<Windchill_HOME>\src\com\your_company\UIRB.rbInfo
Edit the above file in a text editor and include below details:
ResourceInfo.class=wt.tools.resource.StringResourceInfo
ResourceInfo.customizable=true
ResourceInfo.deprecated=false
netmarkets.Test.description.value=Test Link
netmarkets.Test.description.comment=Used for the text on the Test link in the global header.
netmarkets.Test.tooltip.value=This link is to test a new action
netmarkets.Test.tooltip.comment=Used for the tooltip for the Test link in the global header.
Save the above file.
4. ResourceBuild the rbInfo file to generate the corresponding class file:
Launch a Windchill shell and browse to <Windchill_HOME>\src\com\your_company\
Launch the below command:
ResourceBuild com.your_company
The above command would build the class file corresponding to the UIRB.rbInfo file to the location <Windchill_HOME>\codebase\com\your_company\. Below would be the resultant class file:
<Windchill_HOME>\codebase\com\your_company\UIRB.class
If required, create the folder your_company at <Windchill_HOME>\codebase\com\ beforehand.
5. Create the jsp file to launch the desired internet page:
Create below file:
<Windchill_HOME>\codebase\netmarkets\jsp\com\your_company\UI.jsp
I had content something to below in the jsp file:
<script>
window.location="http://www.google.com";
</script>
Save the file.
Restart Windchill application.
Note:
The above customization/deployment setup is just one way of doing the task. There could be many ways and practices (related to the files to be modified, to be created, directory structure, etc.,) by which one could manage the customizations/deployments and that would depend on each administrator and organization's policies. Please also refer to PTC's Windchill Customizer’s Guide for much more details.
Hope this helps.
very helpful.
I had a requirement of adding link in Header. i did changes only in the jsp file.
Adding A Link To Header
Browse to %WT_HOME%\codebase\netmarkets\jsp\util\ and copy the file
begin_custom.jspf to
%WT_HOME%\wtSafeArea\ptcOrig\codebase\netmarkets\jsp\util\
Open the file begin_custom.jspf from %WT_HOME%\codebase\netmarkets\jsp\util\ in
Notepad
Enter the following code:
<div style="color: sienna; position: absolute; top: 15px; z-index: 1000;left: 300px; font-size:
18px;">
<h1>
<a href="javascript:history.go(0)"
onclick="window.open('http://www.productspace.com)">Test Link</a>
</h1>
</div>
You can modify this code to change the URL/display name/position/size/etc.
Restart Windchill
This functionality is great to add in custom Quick Links to a Windchill Site,
the URL string can accept either relative (i.e. content on the same windchill server/site), or a
http(s)://
string to access other sites or webpages.
Unfortunately, it doesn't seem that this URL attribute can accept
mailto:
or
file://
strings, as it takes it to be a relative path in Windchill!
This means it's not possible to have a link to an intranet file (might sound like a bad idea, but it can be required occasionally), nor a link to a support email via mailto: