Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
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;
}
Solved! Go to Solution.
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
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
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.
Hi @tspain
What is your issue?
Can you get the right value from your attribute?
here is the easiest example:
public Object getDataValue(String component_id, Object object, ModelContext modelContext) throws WTException
{
Label nameComponent = new Label("My attribute Value");
nameComponent.setColumnName(AttributeDataUtilityHelper.getColumnName(component_id, obj, modelContext));
nameComponent.setId(component_id);
nameComponent.setValue("My attribute Value");
return nameComponent;
}
PetrH
Thanks for responding. My attribute for UID was showing blank on the info page. I tried your code example and now I am getting UID for the value instead of the actual value.
I noticed in your code that you reference obj instead of object. How is obj instantiated for ComponentMode.VIEW. I just used object for my test.
Hi @tspain
obj = object
You need to read the attribute value from the object. So you need to write code that retrieves the value of the attribute.
PetrH
Hi @tspain
Does your value has a string value? if not then the getRawValue does not work as you expect
use