Creates a separate error container, exposed to the Faces pages as 'errors'.
The page author decides whether and where to show errors, which so
far come in two categories: configuration errors and request errors.
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>\r
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
+<h:html xmlns="http://www.w3.org/1999/xhtml"\r
+ xmlns:f="http://java.sun.com/jsf/core"\r
+ xmlns:h="http://java.sun.com/jsf/html"\r
+ xmlns:ui="http://java.sun.com/jsf/facelets"\r
+ xmlns:cc="http://java.sun.com/jsf/composite">\r
+\r
+<head>\r
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\r
+</head>\r
+<body>\r
+\r
+ <cc:interface>\r
+ </cc:interface>\r
+ \r
+ <cc:implementation>\r
+ <h:panelGrid id="commandErrorMessagesAndSuggestions" rendered="${errors.hasCommandErrors()}" columns="2">\r
+ <h:column>\r
+ <h:outputText id="messages" value="#{errors.commandError.message}" style="color: red;"/>\r
+ </h:column>\r
+ <h:dataTable value="#{errors.commandError.suggestions}" var="suggestion" cellspacing="0" cellpadding="0"> \r
+ <h:column>\r
+ #{suggestion} \r
+ </h:column> \r
+ </h:dataTable>\r
+ </h:panelGrid> \r
+ </cc:implementation>\r
+ \r
+</body>\r
+</h:html>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>\r
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
+<h:html xmlns="http://www.w3.org/1999/xhtml"\r
+ xmlns:f="http://java.sun.com/jsf/core"\r
+ xmlns:h="http://java.sun.com/jsf/html"\r
+ xmlns:ui="http://java.sun.com/jsf/facelets"\r
+ xmlns:cc="http://java.sun.com/jsf/composite">\r
+\r
+<head>\r
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\r
+</head>\r
+<body>\r
+\r
+ <cc:interface>\r
+ </cc:interface>\r
+ \r
+ <cc:implementation>\r
+ <h:panelGrid id="configErrorMessagesAndSuggestions" rendered="${errors.hasConfigurationErrors()}">\r
+ <h:dataTable value="#{errors.configurationErrors}" var="error" cellspace="0" cellpadding="0" style="${errors.hasConfigurationErrors() ? 'display: block; vertical-align: top;' : 'display: none;'}">\r
+ <h:column valign="top">\r
+ <h:outputText value="#{error.message}" style="color: red;"/>\r
+ <h:dataTable value="#{error.suggestions}" var="suggestion" cellspacing="0" cellpadding="0">\r
+ <h:column>\r
+ #{suggestion} \r
+ </h:column> \r
+ </h:dataTable> \r
+ </h:column>\r
+ </h:dataTable>\r
+ </h:panelGrid> \r
+ </cc:implementation>\r
+ \r
+</body>\r
+</h:html>
\ No newline at end of file
{\r
//console.log('rendering ' + renderWhileActiveclients);\r
var sourcecomp = document.getElementById("pz2watch:activeclientsField");\r
- jsf.ajax.request(sourcecomp, null,{render: renderWhileActiveclients + " pz2watch:errorMessages"});\r
+ jsf.ajax.request(sourcecomp, null,{render: renderWhileActiveclients});\r
if (doRefresh) {\r
//console.log('Will do another ajax request after a timeout in order to render: pz2watch:activeclientsField'); \r
renderTargetsReqVar=setTimeout(\r
<h:outputText id="activeClientsLabel" value="Active clients: " style="${cc.attrs.debug == 'true' ? '' : 'display:none;'}"/> \r
<h:outputText id="activeclientsField" value="${pz2.update()}" style="${cc.attrs.debug == 'true' ? '' : 'display:none;'}"/>\r
<h:outputText id="space" value=" - " style="${cc.attrs.debug == 'true' ? '' : 'display:none;'}"/>\r
- <h:outputText id="activeclientsFieldRecord" value="${pz2.update('record')}" style="${cc.attrs.debug == 'true' ? '' : 'display:none;'}"/>\r
- \r
- <h:panelGrid id="errorMessages" style="${pz2.hasErrors() ? 'display: block;' : 'display: none;'}">\r
- <h:dataTable value="#{pz2.configurationErrors}" var="error" cellspace="0" cellpadding="0" style="${pz2.hasConfigurationErrors() ? 'display: block; vertical-align: top;' : 'display: none;'}">\r
- <h:column valign="top">\r
- <h:outputText value="#{error.message}" style="color: red;"/>\r
- <h:dataTable value="#{error.suggestions}" var="suggestion" cellspacing="0" cellpadding="0">\r
- <h:column>\r
- #{suggestion} \r
- </h:column> \r
- </h:dataTable> \r
- </h:column>\r
- </h:dataTable>\r
- <h:panelGrid style="${pz2.hasCommandErrors() ? 'display: block;' : 'display: none;'}">\r
- <h:column>\r
- <h:outputText id="messages" value="#{pzresp.commandError.message}" style="color: red;"/>\r
- </h:column>\r
- <h:dataTable value="#{pzresp.commandError.suggestions}" var="suggestion" cellspacing="0" cellpadding="0"> \r
- <h:column>\r
- #{suggestion} \r
- </h:column> \r
- </h:dataTable>\r
- </h:panelGrid> \r
- </h:panelGrid> \r
+ <h:outputText id="activeclientsFieldRecord" value="${pz2.update('record')}" style="${cc.attrs.debug == 'true' ? '' : 'display:none;'}"/> \r
</h:form>\r
\r
<h:form id="stateForm" prependId="false" rendered="${cc.attrs.trackHistory == 'true'}" style="${cc.attrs.debug == 'true' ? '' : 'display:none;'}">\r
--- /dev/null
+<html xmlns="http://www.w3.org/1999/xhtml"\r
+ xmlns:h="http://java.sun.com/jsf/html"\r
+ xmlns:ui="http://java.sun.com/jsf/facelets"\r
+ xmlns:composite="http://java.sun.com/jsf/composite">\r
+\r
+ <composite:interface>\r
+ <composite:attribute name="user"/>\r
+\r
+ <composite:attribute name="namePrompt"/>\r
+ <composite:attribute name="passwordPrompt"/>\r
+\r
+ <composite:attribute name="loginButtonText"/>\r
+ <composite:attribute name="loginAction"\r
+ method-signature="java.lang.String action()"/>\r
+ </composite:interface>\r
+\r
+ <composite:implementation>\r
+ <h:form id="form">\r
+ <h:panelGrid columns="2">\r
+ #{cc.attrs.namePrompt}\r
+ <h:inputText id="name" value="#{cc.attrs.user.name}"/>\r
+\r
+ #{cc.attrs.passwordPrompt}\r
+ <h:inputSecret id="password" value="#{cc.attrs.user.password}"/>\r
+ </h:panelGrid>\r
+ <p>\r
+ <h:commandButton id="loginButton" value="#{cc.attrs.loginButtonText}"\r
+ action="#{cc.attrs.loginAction}"/>\r
+ </p>\r
+ </h:form>\r
+ </composite:implementation>\r
+</html>
\ No newline at end of file
private ErrorHelper helper;\r
private ErrorCode applicationErrorCode;\r
\r
- public ConfigurationError(String label, String exception, String message, ErrorHelper helper) {\r
+ public ConfigurationError(String label, String exception, String message) {\r
this.label = label;\r
- this.message = message;\r
- this.helper = helper; \r
+ this.message = message; \r
this.exception = exception;\r
}\r
\r
--- /dev/null
+package com.indexdata.pz2utils4jsf.errors;\r
+\r
+import java.io.Serializable;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import javax.annotation.PostConstruct;\r
+import javax.enterprise.context.SessionScoped;\r
+import javax.inject.Inject;\r
+import javax.inject.Named;\r
+\r
+import org.apache.log4j.Logger;\r
+\r
+import com.indexdata.pz2utils4jsf.config.ConfigurationReader;\r
+import com.indexdata.pz2utils4jsf.pazpar2.data.Pazpar2Responses;\r
+\r
+@Named("errors") @SessionScoped\r
+public class ErrorCentral implements Serializable {\r
+\r
+ private static final long serialVersionUID = -1658192041068396628L;\r
+ private static Logger logger = Logger.getLogger(ErrorCentral.class); \r
+ private ErrorHelper errorHelper = null;\r
+ \r
+ @Inject Pazpar2Responses pzresp;\r
+ @Inject ConfigurationReader configurator;\r
+ \r
+ private List<ErrorInterface> configurationErrors = new ArrayList<ErrorInterface>();\r
+\r
+ public ErrorCentral() {}\r
+ \r
+ @PostConstruct \r
+ public void postConstruct() {\r
+ errorHelper = new ErrorHelper(configurator);\r
+ pzresp.setErrorHelper(errorHelper); \r
+ }\r
+ \r
+ public void addConfigurationError (ErrorInterface configError) {\r
+ configError.setErrorHelper(errorHelper);\r
+ configurationErrors.add(configError);\r
+ }\r
+ \r
+ public boolean hasConfigurationErrors () {\r
+ return (configurationErrors.size()>0); \r
+ }\r
+\r
+ public boolean hasCommandErrors () {\r
+ return pzresp.hasApplicationError();\r
+ }\r
+ \r
+ public ErrorInterface getCommandError () {\r
+ return pzresp.getCommandError();\r
+ }\r
+\r
+ /**\r
+ * Returns true if application error found in any response data objects \r
+ */\r
+ public boolean hasErrors () {\r
+ logger.debug("Checking for configuration errors or command errors.");\r
+ return hasConfigurationErrors() || hasCommandErrors();\r
+ }\r
+ \r
+ public List<ErrorInterface> getConfigurationErrors() { \r
+ return configurationErrors;\r
+ }\r
+\r
+\r
+}\r
int pz2code = Integer.parseInt(error.getPazpar2Error().getCode());\r
switch (pz2code) {\r
case 3:\r
- suggestions.add("Query terms not supported.");\r
+ suggestions.add("The search experienced a problem with the query terms.");\r
break;\r
case 12:\r
suggestions.add("The Pazpar2 server does not have a service defined by the requested ID ");\r
import com.indexdata.pz2utils4jsf.errors.ConfigurationError;\r
import com.indexdata.pz2utils4jsf.errors.ConfigurationException;\r
import com.indexdata.pz2utils4jsf.errors.ErrorHelper;\r
-import com.indexdata.pz2utils4jsf.errors.ErrorInterface;\r
+import com.indexdata.pz2utils4jsf.errors.ErrorCentral;\r
import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandParameter;\r
import com.indexdata.pz2utils4jsf.pazpar2.commands.Pazpar2Commands;\r
import com.indexdata.pz2utils4jsf.pazpar2.data.Pazpar2ResponseData;\r
@Inject StateManager stateMgr;\r
@Inject Pazpar2Commands pzreq;\r
@Inject Pazpar2Responses pzresp;\r
+ @Inject ErrorCentral errors;\r
\r
protected ResultsPager pager = null; \r
\r
- protected List<ErrorInterface> configurationErrors = null;\r
+ \r
protected ErrorHelper errorHelper = null;\r
\r
public Pz2Bean () {\r
} \r
\r
public void configureClient(SearchClient searchClient, ConfigurationReader configReader) {\r
- errorHelper = new ErrorHelper(configurator);\r
- logger.info("pz2 " + Utils.objectId(this) + " sets error helper " + Utils.objectId(errorHelper) + " on pzresp " + Utils.objectId(pzresp));\r
- pzresp.setErrorHelper(errorHelper);\r
- configurationErrors = new ArrayList<ErrorInterface>(); \r
logger.debug(Utils.objectId(this) + " will configure search client for the session");\r
try {\r
searchClient.configure(configReader); \r
} catch (ConfigurationException e) {\r
- configurationErrors.add(new ConfigurationError("Search Client","Configuration",e.getMessage(),new ErrorHelper(configReader))); \r
+ logger.debug("Pz2Bean adding configuration error");\r
+ errors.addConfigurationError(new ConfigurationError("Search Client","Configuration",e.getMessage())); \r
} \r
logger.info(configReader.document());\r
pzresp.reset(); \r
* @return Number of activeclients at the time of the 'show' command\r
*/\r
public String update (String commands) {\r
- if (! hasConfigurationErrors()) {\r
+ if (! errors.hasConfigurationErrors()) {\r
if (commandsAreValid(commands)) {\r
if (hasQuery()) {\r
handleQueryStateChanges(commands);\r
stateMgr.setCurrentStateKey(key);\r
}\r
\r
- public boolean hasConfigurationErrors () {\r
- return (configurationErrors.size()>0); \r
- }\r
- \r
- public boolean hasCommandErrors () {\r
- return pzresp.hasApplicationError();\r
- }\r
- \r
- /**\r
- * Returns true if application error found in any response data objects \r
- */\r
- public boolean hasErrors () {\r
- logger.debug("Checking for configuration errors or command errors.");\r
- return hasConfigurationErrors() || hasCommandErrors();\r
- }\r
-\r
- public List<ErrorInterface> getConfigurationErrors() { \r
- return configurationErrors;\r
- }\r
\r
\r
protected boolean hasQuery() { \r
package com.indexdata.pz2utils4jsf.pazpar2;\r
\r
import java.io.Serializable;\r
-import java.util.List;\r
\r
import com.indexdata.pz2utils4jsf.controls.ResultsPager;\r
-import com.indexdata.pz2utils4jsf.errors.ErrorInterface;\r
\r
public interface Pz2Interface extends Serializable {\r
\r
*/\r
public void setCurrentStateKey(String key);\r
\r
- /** \r
- * @return true if any errors encountered so far\r
- */\r
- public boolean hasErrors();\r
- \r
- /**\r
- * \r
- * @return true if errors encountered during execution of commands\r
- */\r
- public boolean hasCommandErrors();\r
- \r
- /**\r
- * \r
- * @return true if errors encountered when configuring the service\r
- */\r
- public boolean hasConfigurationErrors();\r
- \r
- \r
- /**\r
- * Returns all errors encountered during configuration of the application, in particular\r
- * the Pazpar2 client. \r
- * \r
- * @return\r
- */\r
- public List<ErrorInterface> getConfigurationErrors();\r
\r
\r
}\r
\r
import com.indexdata.pz2utils4jsf.errors.ErrorHelper;\r
import com.indexdata.pz2utils4jsf.errors.ErrorInterface;\r
-import com.indexdata.pz2utils4jsf.utils.Utils;\r
\r
@Named("pzresp") @SessionScoped\r
public class Pazpar2Responses implements Serializable {\r