String input, user prompt on empty input

Hello everyone,

I am building a web app and its first component the user is asked to fill in a string input. I am using a case switch to determine whether input was provided. In case the user doesn’t fill in anything, the component output ports will be inactive, but the component will still complete and the workflow will finish ‘successfully’. How can I instead keep the user in the component and prompt her that an input has to be given before the workflow can proceed?
image

1 Like

Hi @pzkor , there is a field called “Regular Expression” in the String Widget where you can add what a valid input should be:

So you can use an expression to validate if the input is empty.

EDIT: The only thing about setting the Regular Expression validator is that you have to set a default value, and a valid default value that is. So if the user is just clicking next and submitting the default value, and this is what you want to prevent, then this way won’t really prevent this, but it will submit a non-empty value though.

Otherwise, you can use your component within a Loop with a Variable Condition Loop End where you essentially keep looping until you are satisfied with the input.

3 Likes

Thanks Bruno! I wanted to avoid a default entry. But yes, of course, looping is the answer! Many thanks!

@pzkor
How exactly is this working. When the workflow is run and did not meet requirements then the loop runs infinitely until the workflow is interrupted and then after cancelling the user changes the value. I could only try a component locally as I do not have a KNIME Server to check. Or is there a better way?
THanks

1 Like

@Daniel_Weikert This is my problem too! Just trying to get it to work myself. I thought that perhaps the loop just needs to be outside of the UI component, but still the same result: the loop runs to the end and the UI doesn’t even show to the user. Anybody?

We may need to ask the guru of Guided Analytics @paolotamag himself to guide us through.

That is flattering :slight_smile:

In the case of simply checking whether a String Widget was not filled, I would use the Regex.
However the default should match the Regex, I do realize that this could be improved. I will talk to the devs.

You could use a default which is clearly a placeholder like “INSERT_YOUR_NAME_HERE”.
If the user removes the placeholder the Regex comes into place.
If the user leaves the placeholder you make the component view in the next page fail with a nice page/error phrase with the option to go back.

2022-06-29_11h45_31

Find the workflow here: KNIME WebPortal STRING Input Validation via Breakpoint node – KNIME Community Hub

I would avoid overcomplicating things with loop nodes around the component view.
This is also tricky to test and debug as it can only work well on KNIME WebPortal.
To make it work locally you can use in general the button “Do One Loop Step”

2022-06-29_10h52_45

The fact is that this only works as expected in KAP if no interactions are injected back into the workflow.

You need to run things on KNIME WebPortal to interact in each iteration.
In KAP you can still test (via “Apply and Close”) with the first iteration view and then select the loop end and select twice the button “Do One Loop Step”. Starting with the second interact KAP does not let you interact with the view anymore. “Apply&Close” or the new browser “Close & Apply Temporarily” do nothing after the first iteration.

ezgif-2-d7b78b0304

As you can see from the above GIF at the output of the loop only the first iteration interaction were properly saved. This changes if you deploy the same identical workflow on KNIME WebPortal.

To do this GIFs I used this workflow:

Did you already have a look at this other forum thread here?

That forum thread seems related and I provided there 2 more example workflows links:

Helpful?

I would recommend to start looking into a single page application setup.
Look at this example by @srauner :

More on the data app / refresh execution on a single page data app topic at:

You could even make the whole data app in a single component with a few configuration nodes to help a generic KNIME user deploy it more easily with different settings and documentation:

6 Likes

Thank you very much @paolotamag for the clear examples. You are a star. And the web app GUI components are the most important area of development in KNIME at the moment in my mind. This is the future. Keep up the good work!

I already got my app working once, but now I realise it again isn’t. I am feeding an UI component with a table with two columns: Entity and RelatedEntity. The component’s purpose is to let the user to choose which of the suggested Related Entities really are related. And as there are multiple Entities to do the mapping for, I am trying looping by Entity. But when running the app on the WebPortal, the loop only did one round (asked me for the mapping for the first Entity) but continued then the workflow never getting to the next Entity. What could explain this? The UI component is inside another component.

image

1 Like

Hi there, I do agree that the new data apps are extremely powerful.
Hopefully we can provide soon more examples of selected business use cases which are easily re-usable on your data.

I cannot guess from this screenshot what’s wrong.
Can you send the workflow with a small sample of the data with at least two categories?
Thanks
Paolo

2 Likes

When I isolate only the mapping component and the loop around it, it works perfectly. Somehow the culprit is how I have wired the wider workflow around it. But not that easy to make that example due to its complexity. But I’ll continue investigations and either manage to fix it or to regenerate the problem.

It all works now. I used to have all this wrapped into another component. After lumping together the ‘pre-work’ and ‘post-work’ instead and removing the component, the loop works just right.
image

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.