Index: main/plugin-datainclusion/i18n/messages_en.xml
===================================================================
--- main/plugin-datainclusion/i18n/messages_en.xml	(revision 39028)
+++ main/plugin-datainclusion/i18n/messages_en.xml	(working copy)
@@ -125,6 +125,10 @@
     <message key="PLUGINS_DATAINCLUSION_CONTENT_EDITION_QUERY_LABEL">Query</message>
     <message key="PLUGINS_DATAINCLUSION_CONTENT_EDITION_QUERY_DESCRIPTION">Insert result of query</message>
     
+    <!-- UI : inline editor deleted query dialog -->
+    <message key="PLUGINS_DATAINCLUSION_CONTENT_EDITION_DELETED_QUERY_TITLE">Inexistant query</message>
+    <message key="PLUGINS_DATAINCLUSION_CONTENT_EDITION_DELETED_QUERY_MSG">The referenced query no longer exists.</message>
+    
     <!-- UI : Choose query dialog -->
     <message key="PLUGINS_DATAINCLUSION_EDITOR_QUERY_TITLE">Choose query</message>
     <message key="PLUGINS_DATAINCLUSION_EDITOR_QUERY_HELPMESSAGE">Choose a query. Its results will be added in the text area.</message>
Index: main/plugin-datainclusion/i18n/messages_fr.xml
===================================================================
--- main/plugin-datainclusion/i18n/messages_fr.xml	(revision 39026)
+++ main/plugin-datainclusion/i18n/messages_fr.xml	(working copy)
@@ -125,6 +125,10 @@
     <message key="PLUGINS_DATAINCLUSION_CONTENT_EDITION_QUERY_LABEL">Requête</message>
     <message key="PLUGINS_DATAINCLUSION_CONTENT_EDITION_QUERY_DESCRIPTION">Insère le ou les résultats d'une requête</message>
     
+    <!-- UI : inline editor deleted query dialog -->
+    <message key="PLUGINS_DATAINCLUSION_CONTENT_EDITION_DELETED_QUERY_TITLE">Requête inexistante</message>
+    <message key="PLUGINS_DATAINCLUSION_CONTENT_EDITION_DELETED_QUERY_MSG">La requête référencée n'existe plus.</message>
+    
     <!-- UI : Choose query dialog -->
     <message key="PLUGINS_DATAINCLUSION_EDITOR_QUERY_TITLE">Insérer une requête</message>
     <message key="PLUGINS_DATAINCLUSION_EDITOR_QUERY_HELPMESSAGE">Choisissez la requête à insérer dans le texte riche.</message>
Index: main/plugin-datainclusion/resources/js/Ametys/plugins/datainclusion/editor/QueryEditorButton.js
===================================================================
--- main/plugin-datainclusion/resources/js/Ametys/plugins/datainclusion/editor/QueryEditorButton.js	(revision 39197)
+++ main/plugin-datainclusion/resources/js/Ametys/plugins/datainclusion/editor/QueryEditorButton.js	(working copy)
@@ -209,47 +209,61 @@
 		{
 			var queryData = this._queryData[queryId]
 			
-			// Name and description.
-	        this._queryDetailsPanel.add({
-	        	xtype: 'component',
-	            html: "<b><i18n:text i18n:key='PLUGINS_DATAINCLUSION_HANDLE_QUERIES_NAME'/></b> : " + queryData['name'],
-	            cls: "datainclusion-message-left",
-	            width: 200
-	        });
-	        this._queryDetailsPanel.add({
-	        	xtype: 'component',
-	            html: "<b><i18n:text i18n:key='PLUGINS_DATAINCLUSION_HANDLE_QUERIES_DESCRIPTION'/></b> : " + queryData['description'],
-	            cls: "datainclusion-message-left",
-	            width: 200
-	        });
-	        
-	        // Parameters.
-	        var parameters = queryData['parameters'];
-	        if (parameters.length < 1)
-	        {
-	            this._queryParamsPanel.add({
-	            	xtype: 'component',
-                    html: "<i18n:text i18n:key='PLUGINS_DATAINCLUSION_QUERY_NO_PARAMETER'/>",
-                    cls: "datainclusion-message"
-                });
-	        }
-	        
-	        // Add an input field per parameter.
-	        for (var i= 0; i < parameters.length; i++)
-	        {
-	            var paramName = parameters[i];
-	            // Initialize the field value.
-	            var field = this._addInputField(paramName);
-	            if (paramValues != null && paramValues[paramName] != null)
-	            {
-	                var value = paramValues[paramName];
-	                field.setValue(value);
-	            }
-	            else
-	            {
-	                field.setValue('');
-	            }
-	        }
+			if (Ext.Object.isEmpty(queryData))
+			{
+				Ametys.Msg.show ({
+					title: "<i18n:text i18n:key='PLUGINS_DATAINCLUSION_CONTENT_EDITION_DELETED_QUERY_TITLE'/>",
+					msg: "<i18n:text i18n:key='PLUGINS_DATAINCLUSION_CONTENT_EDITION_DELETED_QUERY_MSG'/>",
+					buttons: Ext.Msg.OK,
+					icon: Ext.MessageBox.ERROR
+			    });
+				
+				return;
+			}
+			else
+			{
+				// Name and description.
+		        this._queryDetailsPanel.add({
+		        	xtype: 'component',
+		            html: "<b><i18n:text i18n:key='PLUGINS_DATAINCLUSION_HANDLE_QUERIES_NAME'/></b> : " + queryData['name'],
+		            cls: "datainclusion-message-left",
+		            width: 200
+		        });
+		        this._queryDetailsPanel.add({
+		        	xtype: 'component',
+		            html: "<b><i18n:text i18n:key='PLUGINS_DATAINCLUSION_HANDLE_QUERIES_DESCRIPTION'/></b> : " + queryData['description'],
+		            cls: "datainclusion-message-left",
+		            width: 200
+		        });
+		        
+		        // Parameters.
+		        var parameters = queryData['parameters'];
+		        if (parameters.length < 1)
+		        {
+		            this._queryParamsPanel.add({
+		            	xtype: 'component',
+	                    html: "<i18n:text i18n:key='PLUGINS_DATAINCLUSION_QUERY_NO_PARAMETER'/>",
+	                    cls: "datainclusion-message"
+	                });
+		        }
+		        
+		        // Add an input field per parameter.
+		        for (var i= 0; i < parameters.length; i++)
+		        {
+		            var paramName = parameters[i];
+		            // Initialize the field value.
+		            var field = this._addInputField(paramName);
+		            if (paramValues != null && paramValues[paramName] != null)
+		            {
+		                var value = paramValues[paramName];
+		                field.setValue(value);
+		            }
+		            else
+		            {
+		                field.setValue('');
+		            }
+		        }
+			}
 		},
 		
 		/**
Index: main/plugin-datainclusion/src/org/ametys/plugins/datainclusion/data/jcr/JcrQueryDao.java
===================================================================
--- main/plugin-datainclusion/src/org/ametys/plugins/datainclusion/data/jcr/JcrQueryDao.java	(revision 39026)
+++ main/plugin-datainclusion/src/org/ametys/plugins/datainclusion/data/jcr/JcrQueryDao.java	(working copy)
@@ -241,26 +241,30 @@
         Map<String, Object> infos = new HashMap<>();
         
         Query query = getQuery(siteName, id);
-        infos.put("id", query.getId());
-        infos.put("name", query.getName());
-        infos.put("description", query.getDescription());
-        infos.put("type", query.getType());
-        infos.put("resultType", query.getResultType().name());
         
-        Map<String, String> additionalConf = query.getAdditionalConfiguration();
-        for (String confName : additionalConf.keySet())
+        if (query != null)
         {
-            String value = additionalConf.get(confName);
-            if (value != null)
+            infos.put("id", query.getId());
+            infos.put("name", query.getName());
+            infos.put("description", query.getDescription());
+            infos.put("type", query.getType());
+            infos.put("resultType", query.getResultType().name());
+            
+            Map<String, String> additionalConf = query.getAdditionalConfiguration();
+            for (String confName : additionalConf.keySet())
             {
-                infos.put(confName, value);
+                String value = additionalConf.get(confName);
+                if (value != null)
+                {
+                    infos.put(confName, value);
+                }
             }
+            
+            infos.put("parameters", query.getParameterNames());
+            
+            infos.put("dataSourceId", query.getDataSource().getId());
         }
         
-        infos.put("parameters", query.getParameterNames());
-        
-        infos.put("dataSourceId", query.getDataSource().getId());
-        
         return infos;
     }
     
