Sample Code
Example implementation for the InfoPageComponent
This example can be viewed in the Windchill product by navigating to Customization -> Example Information Page. The Customization tab is hidden out-of-the-box but can be enabled via the “Client Customization” preference available in Site->Utilities->Preferences Manager.
This example shows an info page for an object of the new type “Carambola.”. The Carambola object type is a simple Java class with an icon and various attributes. The example illustrates how to:
create a set of tabs
define a tab customization menu (tab actions)
define an action dropdown menu
display status glyphs next to the object name
add a help topic
construct a custom VisualizationDelegate
use a custom view jsp that adds toggle buttons for commonspace/ workspace and a Go to Latest link.
Two of the tabs displayed on the info page illustrate what happens when the server encounters errors when producing a page. The tab “Error Page With Generic Exception” shows how exception messages are displayed when java or scriplet code executed on a jsp page throws an exception. The tab “404 error” shows how a HTTP 404 response code is displayed when the jsp page specified in an action could not be found. The action “Action Has Invalid Onclick” in the Actions menu illustrates the message that is provided when the javascript provided in the “onclick” attribute of an action command subtag is invalid.
The action “Action Has Complex Onclick” illustrates another action with an invalid “onclick” attribute. Onclick attributes should contain a single javascript function call. In this case, the onclick attribute has multiple function calls. The action framework wraps the multiple statements in one function call to prevent the page display from aborting.
The panels and tables available for display on the info page tabs via the Customize link are ones created for other examples in the Customization tab, such as the Attribute Panel, Property Panel, and Table examples.
Files Used in this Example
Action Models Used in this Example
Action Model File
Action Model Names
Name: Carambola-actionModels.xml
Codebase path: codebase/config/actions
CustEx_infoPage_tabset
carambola_details
CustEx_default_myTab
CustEx_error_on_page
CustEx_error_404
CustEx_infoPage_third_level_navigation
CustEx_submodel_simpleTable
CustEx_submodel_advancedTable
CustEx_InfoPage_attributes
carambola_info_page
carambola_sub_model
Actions Used in this Example
Action File
Action Names
Name: Carambola-actions.xml
Codebase path: codebase/config/actions
CustEx_simpleTable1
CustEx_simpleTable2
CustEx_simpleTable3
CustEx_advancedTable1
CustEx_advancedTable_custom_oid_actions
CustEx_error_on_page
CustEx_error_404
propertyPanel
attributePanel
visualizationAndAttributes
primaryAttributes
onclickIsInvalid
onclickToBeWrapped
Files Used in this Example
File
Description
Carambola.jar
Source code examples are located in the Carambola-java.jar file in the <Windchill>\Windchill\srclib\wnc diretory.
“Carambola” object class
CarambolaVisualizationDelegate.java
Source code examples are located in the Carambola-java.jar file in the <Windchill>\Windchill\srclib\wnc diretory.
Delegate that creates the content for the VisualizationComponent on the page
CarambolaInfoBuilder.java
Source code examples are located in the Carambola-java.jar file in the <Windchill>\Windchill\srclib\wnc diretory.
Info page builder class for object type “Carambola”
CarambolaVizAndAttrBuilder.java
Source code examples are located in the Carambola-java.jar file in the <Windchill>\Windchill\srclib\wnc diretory.
Builder for the Visualization and Attributes penel. You do not typically need to write a builder for this panel. Such a builder was required for this example only because the “Carambola” object type is not a type exposed in the Type Manager.
carambolaInfoPage.jsp
Source code examples are located in the Carambola-java.jar file in the <Windchill>\Windchill\srclib\wnc diretory.
View (jsp) for the page with javascript to produce toggle buttons and Go to Latest link.
<Windchill>\Windchill\codebase\com\ptc\carambola\carambola.service.properties.xconf
VisualizationDelegate service property
這是否有幫助?