HOWTO: Control the Display Mode of a Widget - JSF UI

Updated: July 23, 2024

JSF UI Deprecation
This requires to have the JSF UI addon installed on your server that is deprecated since Nuxeo Platform LTS 2019.
Please refer to the Web UI documentation.

It is a very frequent requirement to be able to control the display mode of a widget depending on some conditions such as the lifecycle state of the document, or the groups a user belongs to. Nuxeo Studio enables you to leverage the power of the Nuxeo Layout service and to implement your requirements using an expression when you configure your widget.

For instance, when you are editing a document layout, whether it is the creation, edition or view layout, if you edit the widgets you dropped on the layout, you will see the "Advanced mode configuration" section.

Make sure that the Nuxeo JSF UI target package is checked in your project's Application Definition to get all the needed features in Nuxeo Studio.

  1. Unfold the option by clicking on the black arrow,
  2. Fill the text area with an expression that will control the display of your widget. Here are some samples:
  • #{layoutValue.currentLifeCycleState =='approved' && == 'Nuxeo'?'edit':'hidden'} This expression says that the field will be invisible unless the document is in state "approved" and the company of the user is "Nuxeo". In that case it will be editable.
  • #{currentUser.isMemberOf('quality_managers') && (layoutValue.dc.nature=='procedure'||layoutValue.dc.nature=='decree')?'edit':'view'} This expression says that the field will be editable only for people from group quality_managers and only if the document is a decree or a procedure. Otherwise, value is just viewable.
  • #{nxd:hasPermission(layoutValue, 'Editorial')?'edit':'view'} This expression says that the widget will be editable only for users having the Editorial permission.

You can also see the reference documentation on layouts, more specifically the EL expressions in layouts and widgets section.