cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Replace number field with picker

akosolapov-2
14-Alexandrite

Replace number field with picker

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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();

}

View solution in original post

1 REPLY 1

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();

}

View solution in original post

Announcements