Skip to main content
15-Moonstone
September 15, 2023
Solved

how to display custom user picker value

  • September 15, 2023
  • 1 reply
  • 2686 views

Dears,

I wrote a customized User Picker according to the Demo, it is working fine under the Creat and Edit modes, but it can't show the selected property value, I think I should need to write some code under the getDataValue method for the ComponentMode.VIEW, how can I make writing this part of the code to be able to display it on the VIEW under getDataValue method. Thank you.

 

 

	@Override
	public Object getDataValue(String component_id, Object object, ModelContext mc) throws WTException {
		String attributeId = component_id;
		Object obj = null;
		GUIComponentArray guiArray = new GUIComponentArray();
		if (ComponentMode.CREATE.equals(mode) || ComponentMode.EDIT.equals(mode)) {
			obj = super.getDataValue(attributeId, object, mc);
			if (obj instanceof PickerInputComponent) {
				PickerInputComponent pickerComponent = (PickerInputComponent) obj;
				guiArray.addGUIComponent(pickerComponent);
			}
		} else if (ComponentMode.VIEW.equals(mode)) {
//TODO
		}

		return obj;

	}

 

 

 

Best answer by HelesicPetr

Hi @CZ_9645217 

You can use Lable (com.ptc.core.components.rendering.guicomponents.Lable)

 

Label nameComponent = new Label("");
nameComponent.setColumnName(AttributeDataUtilityHelper.getColumnName(component_id, obj, modelContext));
nameComponent.setId(component_id);
nameComponent.setValue(pickerComponent.getValue());

 PetrH

1 reply

HelesicPetr
22-Sapphire II
22-Sapphire II
September 15, 2023

Hi @CZ_9645217 

You can use Lable (com.ptc.core.components.rendering.guicomponents.Lable)

 

Label nameComponent = new Label("");
nameComponent.setColumnName(AttributeDataUtilityHelper.getColumnName(component_id, obj, modelContext));
nameComponent.setId(component_id);
nameComponent.setValue(pickerComponent.getValue());

 PetrH

15-Moonstone
September 15, 2023

Hi @HelesicPetr 

Thank you very much for your prompt reply, it solved my problem!

 

 

8-Gravel
March 6, 2024

Hi @CZ_9645217

 

Could you share your getDataValue method after you were able to get working?   I have spent a couple of days trying to get this to work but I have been unsuccessful.  Thank you.