Example 9: Wizard
If you can't play the video, make sure that you are logged in at Wex Solutions.
-
What will we do? - How to add a Wizard to any Windchill extension and how to configure the Wizard
-
What do you need? - Site access to a non-production Windchill
-
How long will it take - 5 minutes
This example shows how to add a Wizard using JCA. You can find the code for this example in our GitHub repository.
Implementation
This example will generate a pop-up page that contains a 2-step Wizard. It involves the following elements:
Name | Type | Description |
---|---|---|
ExampleWizardFormProcessor.java | Class | The class that will process the form. |
edkWizard.jsp | JSP | The page that defines the wizard steps. |
edkWizardStep1.jsp | JSP | The step page. |
edkWizardStep2.jsp | JSP | Another step page. |
WexResources.java | Class | The class that will name the steps |
The hook points are standard, but the actions must be defined in the WEX's definition.xml
file:
<install>
<menus>
<extension menu="more parts actions" file="PartClient-actionmodels" action="edkWizard"/>
</menus>
<actions>
<wizard class="com.wincomplm.wex.kernel.impl.forms.WexObjectFormProcessor" name="edkWizard"
url="edkWizard.jsp?wex-form-processor=com.wincomplm.wex-example-wizard.ExampleWizardFormProcessor" shortcut="false"/>
<wizard-step name="edkWizardStep1" url="edkWizardStep1.jsp"/>
<wizard-step name="edkWizardStep2" url="edkWizardStep2.jsp" preloadWizardPage="false"/>
</actions>
</install>
The wizard
tag includes in the URL the reference to the form processor. Again, as we are inside of a WEX, this cannot be defined in the class tag.
The menus
tag is where you define where the created wizard will be shown. In this example it's defined only for WTParts. You can add as many extensions as needed.
The form processor is defined as follows, extending DefaultObjectFormProcessor
and implementing doOperation
:
@WexComponent(uid = "ExampleWizardFormProcessor", description = "Example form processor")
public class ExampleWizardFormProcessor extends DefaultObjectFormProcessor {
private static IWexLogger logger = WexLogger.getLogger(ExampleWizardFormProcessor.class);
@Override
public FormResult doOperation(NmCommandBean ncb, List<ObjectBean> list) throws WTException {
logger.trace("=>doOperation");
FormResult result = new FormResult(FormProcessingStatus.SUCCESS);
logger.trace("<=doOperation {0}", result);
return result;
}
}
Wizard
The main wizard is defined as follow. It contains all the steps that the popup will have. edkWizard.jsp
file:
<%@ include file="/netmarkets/jsp/components/beginWizard.jspf"%>
<%@ taglib uri="http://www.ptc.com/windchill/taglib/fmt" prefix="fmt"%>
<%@ taglib uri="http://www.ptc.com/windchill/taglib/mvc" prefix="mvc"%>
<fmt:setLocale value="${localeBean.locale}"/>
<jca:wizard title="Example Wizard" buttonList="DefaultWizardButtonsNoApply">
<jca:wizardStep action="edkWizardStep1" type="com.wincomplm.wex.example.wizard"/>
<jca:wizardStep action="edkWizardStep2" type="com.wincomplm.wex.example.wizard"/>
</jca:wizard>
<%@include file="/netmarkets/jsp/util/end.jspf"%>
This is an example of how a simple step should looks like.edkWizardStep1.jsp
and edkWizardStep2.jsp
file:
<%@ include file="/netmarkets/jsp/util/begin.jspf"%>
Step 1
<%@include file="/netmarkets/jsp/util/end.jspf"%>
wexResources contains where you named all the variable of your wizard. wexResources.java
file:
@WexComponent(uid = "com.wincomplm.wex.example.wizard.resources.WexResources", description = "Resource bundle")
@RBUUID("com.wincomplm.wex.example.wizard.resources.WexResources")
@RBNameException
public class WexResources extends WTListResourceBundle {
@RBEntry("Wizard Example")
public static final String P0 = "com.wincomplm.wex.example.wizard.edkWizard.description";
@RBEntry("Wizard Example")
public static final String P1 = "com.wincomplm.wex.example.wizard.edkWizard.tooltip";
@RBEntry("Wizard Example")
public static final String P2 = "com.wincomplm.wex.example.wizard.edkWizard.activetooltip";
@RBEntry("Step 1")
public static final String P3 = "com.wincomplm.wex.example.wizard.edkWizardStep1.description";
@RBEntry("Step 1")
public static final String P4 = "com.wincomplm.wex.example.wizard.edkWizardStep1.title";
@RBEntry("Step 1")
public static final String P5 = "com.wincomplm.wex.example.wizard.edkWizardStep1.tooltip";
@RBEntry("Step 2")
public static final String P6 = "com.wincomplm.wex.example.wizard.edkWizardStep2.description";
@RBEntry("Step 2")
public static final String P7 = "com.wincomplm.wex.example.wizard.edkWizardStep2.title";
@RBEntry("Step 2")
public static final String P8 = "com.wincomplm.wex.example.wizard.edkWizardStep2.tooltip";
}
Execution
After deploying the WEX, navigate to any part as any user (no validators are used in this example, so all user groups will be able to access the new entry):
This will launch the Wizard: