Workflow : How to make a field required only for the accept button and not the reject one?

Hi,

On Nuxeo 5.6, using Studio, about forms in accept/reject tasks : I would like through the workflow designer to make a field required, but only for the “accept” button and not for the “reject” one.

I tried something by setting the required field to false and by using conditions on transitions in a way that I “manually” check the value of a given NodeVariable, if it is empty and the user pressed “validate”, the user is redirected to the same task. But this lead to a user-confusing experience I'm trying to avoid.

The nice way would be to work at the jsf form validation level so the user is not redirected to an other page. Is it possible through studio? Is it even possible outside studio?

Thanks

1 votes

2 answers

1157 views

ANSWER



2 votes



Ok, thx. I guess I ll stay with my condition trick for a while
05/14/2013

Hi,

Murkein, i unmarked this as a valid solution, as it's not the same issue: the "immediate" boolean on actions does have the same meaning than immediate attribute on JSF command tags, here's a good explanation of how it works http://balusc.blogspot.fr/2006/09/debug-jsf-lifecycle.html#AddImmediateTrueToUICommandOnly

If the need here is to make the field required only depending on which button is clicked, setting the action as immediate will not help (especially, submitted values will be ignored, required or not)

05/16/2013

ok, I thought he wanted the same behavior when a person develops a classical form with the accept and cancel buttons, where the person pressing the cancel button does not matter any validation
05/16/2013

Well, I understand the difference, however, the case suggested by murkein might be enough for me. In my specific case, I don't care about the field value when I reject the form.
05/16/2013


You can try adding the following expression for the custom property “required” on the widget definition:

#{request.getParameter('button') == 'accept'}

Here 'accept' is the name of the button defined on the workflow.

2 votes



thanks, it works
05/16/2013

Ok, I will try this one, I thought the "required" custom property was only evaluated when the form is rendered so it's value is precalculated before the form submition. I'll see :)
05/16/2013

well it is evaluated once, so that the form can display a "*" marker to show the user that the field is required, but it's evaluated again at submit
05/16/2013

I tried the given solution, but it is not working. The form is submitted and no validation error is thrown.
05/22/2013

strange, i tested it, and it seems murkein made it work too, so i don't know what could be wrong in your case, unless you have more details?
06/02/2013

Remark: Hello,

I have try this solution to test if a widget value is mandatory compare to an other widget value in the same workflow form task. like,

{ layoutValue.get('var') != null && layoutValue.get('var') != "" }

this need to click on the "next button" and come back with "previous button" of second form to see its mandatory setting up :-(

06/14/2013

Hi, I tried use it with a input user suggestion widget but not working. It Only worked with my input type: text, file, textarea …
06/14/2013