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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Likely very simple question about input on wizards

avillanueva
22-Sapphire II

Likely very simple question about input on wizards

I have a very simple wizard when I just need to gather a text response from the user. I followed an example but must have missed something. My attribute panel appears but not the textbox I had expected. Here is what I see:

avillanueva_0-1680116900542.png

Here is the builder code that I used:

public AttributePanelConfig buildAttributesComponentConfig(ComponentParams arg0)
			throws WTException {
		
		 
		ComponentConfigFactory componentconfigfactory = getComponentConfigFactory();
		
		AttributePanelConfig attributeconfig = (AttributePanelConfig) componentconfigfactory.newAttributePanelConfig();
		attributeconfig.setComponentType(ComponentType.WIZARD_ATTRIBUTES_TABLE);
		JcaGroupConfig group=(JcaGroupConfig) componentconfigfactory.newGroupConfig();
		group.setId("justification");
		group.setLabel("Enter Justification");
		group.setIsGridLayout(true);
		JcaAttributeConfig attribute = (JcaAttributeConfig)componentconfigfactory.newAttributeConfig();
		attribute.setId("justification_value");
		attribute.setRequired(true);
		attribute.setLabel("Justification");
		attribute.setComponentMode(ComponentMode.EDIT);
		group.addComponent(attribute);
		attributeconfig.addComponent(group);
		return attributeconfig;
	}

I thought that all I needed was to set the component mode to edit. I did this before with a table but in that case I used a data utility to make a editable text box. Is that what I need to do here? This should just be a simple textbox where the user can enter a short few sentences and I can pass that to a workflow.

ACCEPTED SOLUTION

Accepted Solutions

You need to set the exact component in the buildComponentData method. There you can define if the attribute is a textbox, textarea, checkbox, dropdown, etc.

 @Override
  public ComponentConfig buildComponentConfig(ComponentParams arg0) throws WTException {

    ComponentConfigFactory factory = getComponentConfigFactory();

    AttributePanelConfig attributePanelConfig = factory.newAttributePanelConfig();
    GroupConfig groupConfig = factory.newGroupConfig("customConfig");
    groupConfig.setLabel("Input");
    groupConfig.setRenderOnTop(true);

    AttributeConfig attributeConfig2 = factory.newAttributeConfig("textArea", "Input");
    groupConfig.addComponent(attributeConfig2);

    attributePanelConfig.addComponent(groupConfig);

    return attributePanelConfig;
  }


  @Override
  public Object buildComponentData(ComponentConfig config, ComponentParams params) throws WTException {

    Map guiMap = new HashMap();

    TextArea textarea = new TextArea();
    textarea.setName("textArea");
    textarea.setId("textArea");
    textarea.setValue(message);
    textarea.setEditable(false);
    textarea.setRichText(true);
    textarea.setEnabled(false);

    guiMap.put("textArea", textarea);

    return guiMap;
  }

View solution in original post

3 REPLIES 3

You need to set the exact component in the buildComponentData method. There you can define if the attribute is a textbox, textarea, checkbox, dropdown, etc.

 @Override
  public ComponentConfig buildComponentConfig(ComponentParams arg0) throws WTException {

    ComponentConfigFactory factory = getComponentConfigFactory();

    AttributePanelConfig attributePanelConfig = factory.newAttributePanelConfig();
    GroupConfig groupConfig = factory.newGroupConfig("customConfig");
    groupConfig.setLabel("Input");
    groupConfig.setRenderOnTop(true);

    AttributeConfig attributeConfig2 = factory.newAttributeConfig("textArea", "Input");
    groupConfig.addComponent(attributeConfig2);

    attributePanelConfig.addComponent(groupConfig);

    return attributePanelConfig;
  }


  @Override
  public Object buildComponentData(ComponentConfig config, ComponentParams params) throws WTException {

    Map guiMap = new HashMap();

    TextArea textarea = new TextArea();
    textarea.setName("textArea");
    textarea.setId("textArea");
    textarea.setValue(message);
    textarea.setEditable(false);
    textarea.setRichText(true);
    textarea.setEnabled(false);

    guiMap.put("textArea", textarea);

    return guiMap;
  }

Hi @avillanueva @BjoernRueegg 

I have more complicated solution 😄

Define own Data Utility for the attribute and you can return what component type you wish  . 

 

@BjoernRueegg thank you for the experience.

I used buildComponentData to get objects in a table but I didn't know it is possible to use it for the AttributePanelConfig 😄 

 

Thanks 

 

PetrH

And here is the final result:

avillanueva_0-1680260557153.png

To retrieve the text from the textarea, I was able tie my shoes all by myself!

//find Justification
String justification="No Justification provided";
l.debug("Checking input for a justification");
l.debug("Bean Count:"+list.size());
for(ObjectBean bean:list)
{
	l.debug("checking bean " + bean.toString());
	if (bean.getChangedTextArea() == null)
	{
		l.debug("no changed text area in this bean");
		continue;
	}
	l.debug("Found a changed text area");
	Map<String,String> textAreas=bean.getChangedTextArea();
	l.debug("Map size:"+textAreas.size());
	l.debug("found justification");
				 
        justification=textAreas.get("Justification");
        //found justification
        break;			
}		

 

 

Announcements

Top Tags