Skip to main content
14-Alexandrite
September 23, 2016
Solved

Replace number field with picker

  • September 23, 2016
  • 1 reply
  • 2835 views

Hi.

I need to build WTPart number in create wizard based on some classifier. Classifier item should be selected by user through picker.

So i created datautility that uses PickerInputComponent.

But now PickerInputComponent's input field has no binding to wtPart number. Windchill considers number as null and generates itself.

PickerInputComponent.setId() and PickerInputComponent.setColumnName() do not solve problem.

What can i do?

May be should i use another approach to solve problem?

Thanks.

Best answer by akosolapov-2

Solution is to create for number field DataUtility that extends com.ptc.core.components.factory.dataUtilities.NumberDataUtility (default data utility for number field).

Code example for this data utility:


public Object getDataValue(String componentId, Object o, ModelContext modelContext) throws WTException {

  GUIComponentArray guiComponentArray = new GUIComponentArray();

  AttributeInputCompositeComponent numberInput = (AttributeInputCompositeComponent) super.getDataValue(componentId, o, modelContext);

  guiComponentArray.addGUIComponent(numberInput);

  PickerIconButton pickerIconButton = new PickerIconButton(WTMessage.getLocalizedMessage("someYourResourceBundle", "YOUR_PICKER_LABEL"));

  pickerIconButton.setFieldId("number_picker");

  pickerIconButton.setColumnName(componentId);

  pickerIconButton.addStyleClass("pickerInputComponentFindButton");

  pickerIconButton.addJsAction("onclick", createJsOnLickAction());

  guiComponentArray.addGUIComponent(pickerIconButton);

   return guiComponentArray;

}

private String createJsOnLickAction() {

  StringBuilder onClickActionBuilder = new StringBuilder();

  onClickActionBuilder.append("popupAction('launchPicker', 'path to your jsp where itemPicker is defined'");

  onClickActionBuilder.append(", '', '', '', '', '', '', '', '', '', '', '', '', 'portlet', 'poppedup', 'context', null");

  onClickActionBuilder.append(", 'oid', null, null, 'none', 'com.ptc.netmarkets.search.NmSearchCommands', 'callSearchPicker'");

  onClickActionBuilder.append(", 'height=768,width=550', null, null, false, '', 'component', '', false, null");

  onClickActionBuilder.append(")");

   return onClickActionBuilder.toString();

}

1 reply

akosolapov-214-AlexandriteAuthorAnswer
14-Alexandrite
December 1, 2016

Solution is to create for number field DataUtility that extends com.ptc.core.components.factory.dataUtilities.NumberDataUtility (default data utility for number field).

Code example for this data utility:


public Object getDataValue(String componentId, Object o, ModelContext modelContext) throws WTException {

  GUIComponentArray guiComponentArray = new GUIComponentArray();

  AttributeInputCompositeComponent numberInput = (AttributeInputCompositeComponent) super.getDataValue(componentId, o, modelContext);

  guiComponentArray.addGUIComponent(numberInput);

  PickerIconButton pickerIconButton = new PickerIconButton(WTMessage.getLocalizedMessage("someYourResourceBundle", "YOUR_PICKER_LABEL"));

  pickerIconButton.setFieldId("number_picker");

  pickerIconButton.setColumnName(componentId);

  pickerIconButton.addStyleClass("pickerInputComponentFindButton");

  pickerIconButton.addJsAction("onclick", createJsOnLickAction());

  guiComponentArray.addGUIComponent(pickerIconButton);

   return guiComponentArray;

}

private String createJsOnLickAction() {

  StringBuilder onClickActionBuilder = new StringBuilder();

  onClickActionBuilder.append("popupAction('launchPicker', 'path to your jsp where itemPicker is defined'");

  onClickActionBuilder.append(", '', '', '', '', '', '', '', '', '', '', '', '', 'portlet', 'poppedup', 'context', null");

  onClickActionBuilder.append(", 'oid', null, null, 'none', 'com.ptc.netmarkets.search.NmSearchCommands', 'callSearchPicker'");

  onClickActionBuilder.append(", 'height=768,width=550', null, null, false, '', 'component', '', false, null");

  onClickActionBuilder.append(")");

   return onClickActionBuilder.toString();

}