Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
Hello Everyone,
Is it possible to add GUI components like Textbox, Checkbox, Radio Button, Combo Box, and Text Area into an attribute panel using Builders?
I was able to achieve this using wrapper tags in JSP.
@Override
public ComponentConfig buildComponentConfig(ComponentParams param) throws WTException {
ComponentConfigFactory componentConfigFactory = getComponentConfigFactory();
AttributePanelConfig attributePanelConfig = componentConfigFactory.newAttributePanelConfig();
GroupConfig groupConfig = componentConfigFactory.newGroupConfig("GUI Componenets");
groupConfig.addComponent((ComponentConfig)componentConfigFactory.newAttributeConfig("date", "Date"));
groupConfig.addComponent((ComponentConfig)componentConfigFactory.newAttributeConfig("textBox", "TextBox"));
groupConfig.addComponent((ComponentConfig)componentConfigFactory.newAttributeConfig("comboBox", "ComboBox"));
groupConfig.addComponent((ComponentConfig)componentConfigFactory.newAttributeConfig("radioButton", "Radio Button"));
groupConfig.addComponent((ComponentConfig)componentConfigFactory.newAttributeConfig("checkbox", "Checkbox"));
attributePanelConfig.addComponent(groupConfig);
return attributePanelConfig;
}
Solved! Go to Solution.
Hi @HelesicPetr
Thank you for the suggestion.
I can able to create GUI component in Builders
import com.ptc.core.components.rendering.AbstractGuiComponent;
import com.ptc.core.components.rendering.guicomponents.ComboBox;
import com.ptc.core.components.rendering.guicomponents.TextArea;
import com.ptc.core.components.rendering.guicomponents.TextBox;
@Override
public Object buildComponentData(ComponentConfig config, ComponentParams param) throws WTException {
TextBox textbox = new TextBox();
textbox.setName("textBox");
textbox.setId("textBox");
textbox.setEditable(true);
textbox.setWidth(50);
ArrayList<String> displayList = new ArrayList<String>();
ArrayList<String> internalNameList = new ArrayList<String>();
ArrayList<String> selectedValue = new ArrayList<String>();
displayList.add("Option 1");
displayList.add("Option 2");
displayList.add("Option 3");
internalNameList.add("option1");
internalNameList.add("option2");
internalNameList.add("option3");
ComboBox comboBox = new ComboBox(displayList, internalNameList, selectedValue);
comboBox.setName("comboBox");
comboBox.setId("comboBox");
comboBox.setMultiSelect(false);
TextArea textArea = new TextArea();
textArea.setName("textArea");
textArea.setId("textArea");
textArea.setEditable(true);
Map<String, AbstractGuiComponent> guiMap = new HashMap<String, AbstractGuiComponent>();
guiMap.put("textBox", textbox);
guiMap.put("comboBox", comboBox);
guiMap.put("textArea", textArea);
return guiMap;
}
Output
Hello @HelesicPetr
I can achieve my requirement using JSP, but I want to know if the same can be done using Builder.
Please find the buildComponentConfig code below.
@Override
public ComponentConfig buildComponentConfig(ComponentParams param) throws WTException {
ComponentConfigFactory componentConfigFactory = getComponentConfigFactory();
AttributePanelConfig attributePanelConfig = componentConfigFactory.newAttributePanelConfig();
GroupConfig groupConfig1 = componentConfigFactory.newGroupConfig("gui","GUI Componenets",Integer.valueOf(1));
groupConfig1.addComponent((ComponentConfig)componentConfigFactory.newAttributeConfig("date", "Date"));
groupConfig1.addComponent((ComponentConfig)componentConfigFactory.newAttributeConfig("textBox", "TextBox"));
groupConfig1.addComponent((ComponentConfig)componentConfigFactory.newAttributeConfig("comboBox", "ComboBox"));
groupConfig1.addComponent((ComponentConfig)componentConfigFactory.newAttributeConfig("radioButton", "Radio Button"));
groupConfig1.addComponent((ComponentConfig)componentConfigFactory.newAttributeConfig("checkbox", "Checkbox"));
attributePanelConfig.addComponent(groupConfig1);
GroupConfig groupConfig2 = componentConfigFactory.newGroupConfig("epm", "EPM Attribute", Integer.valueOf(2));
groupConfig2.addComponent((ComponentConfig)componentConfigFactory.newAttributeConfig("name", "Name"));
groupConfig2.addComponent((ComponentConfig)componentConfigFactory.newAttributeConfig("number", "Number"));
attributePanelConfig.addComponent(groupConfig2);
return attributePanelConfig;
}
I'm getting output like below screenshot
Can we get the GUI component like
Hi @Ponnarasu
You have to set the component editable.
I do it in a datautility
checkBox.setEditable(true);
textArea.setEditable(true);
PetrH
Hi @HelesicPetr
Thank you for the suggestion.
I can able to create GUI component in Builders
import com.ptc.core.components.rendering.AbstractGuiComponent;
import com.ptc.core.components.rendering.guicomponents.ComboBox;
import com.ptc.core.components.rendering.guicomponents.TextArea;
import com.ptc.core.components.rendering.guicomponents.TextBox;
@Override
public Object buildComponentData(ComponentConfig config, ComponentParams param) throws WTException {
TextBox textbox = new TextBox();
textbox.setName("textBox");
textbox.setId("textBox");
textbox.setEditable(true);
textbox.setWidth(50);
ArrayList<String> displayList = new ArrayList<String>();
ArrayList<String> internalNameList = new ArrayList<String>();
ArrayList<String> selectedValue = new ArrayList<String>();
displayList.add("Option 1");
displayList.add("Option 2");
displayList.add("Option 3");
internalNameList.add("option1");
internalNameList.add("option2");
internalNameList.add("option3");
ComboBox comboBox = new ComboBox(displayList, internalNameList, selectedValue);
comboBox.setName("comboBox");
comboBox.setId("comboBox");
comboBox.setMultiSelect(false);
TextArea textArea = new TextArea();
textArea.setName("textArea");
textArea.setId("textArea");
textArea.setEditable(true);
Map<String, AbstractGuiComponent> guiMap = new HashMap<String, AbstractGuiComponent>();
guiMap.put("textBox", textbox);
guiMap.put("comboBox", comboBox);
guiMap.put("textArea", textArea);
return guiMap;
}
Output