Author: abelevich
Date: 2007-06-25 14:26:09 -0400 (Mon, 25 Jun 2007)
New Revision: 1307
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/JiraUserConverter.java
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/PriorityConverter.java
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/StatusConverter.java
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/utils/ConverterUtils.java
Log:
add ERROR types
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/JiraUserConverter.java
===================================================================
---
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/JiraUserConverter.java 2007-06-25
18:25:50 UTC (rev 1306)
+++
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/JiraUserConverter.java 2007-06-25
18:26:09 UTC (rev 1307)
@@ -29,7 +29,7 @@
private boolean transientFlag;
-
+
public JiraUserConverter() {
transientFlag = false;
}
@@ -40,7 +40,7 @@
JiraUser user = findUser(value);
// System.out.println("JiraUserConverter.getAsObject()");
if( user == null){
- FacesMessage errorMessage = ConverterUtils.createTypeErrorMessage(value,"real
jira username");
+ FacesMessage errorMessage =
ConverterUtils.createTypeErrorMessage(value,null,ConverterUtils.ERROR_2);
throw new ConverterException(errorMessage);
}
return user;
@@ -53,9 +53,8 @@
if(value instanceof JiraUser){
jiraUser = (JiraUser)value;
-// System.out.println("JiraUserConverter.getAsString()");
}else{
- FacesMessage errorMessage =
ConverterUtils.createTypeErrorMessage(value.getClass().getName(),
JiraUser.class.getName());
+ FacesMessage errorMessage =
ConverterUtils.createTypeErrorMessage(value.getClass().getName(),
JiraUser.class.getName(),ConverterUtils.ERROR_1);
throw new ConverterException(errorMessage);
}
@@ -106,6 +105,8 @@
}
}
+
+
return null;
}
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/PriorityConverter.java
===================================================================
---
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/PriorityConverter.java 2007-06-25
18:25:50 UTC (rev 1306)
+++
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/PriorityConverter.java 2007-06-25
18:26:09 UTC (rev 1307)
@@ -89,7 +89,7 @@
if(value instanceof Priority){
priority = (Priority)value;
}else{
- FacesMessage errorMessage =
ConverterUtils.createTypeErrorMessage(value.getClass().getName(),
Priority.class.getName());
+ FacesMessage errorMessage =
ConverterUtils.createTypeErrorMessage(value.getClass().getName(),
Priority.class.getName(),ConverterUtils.ERROR_1);
throw new ConverterException(errorMessage);
}
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/StatusConverter.java
===================================================================
---
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/StatusConverter.java 2007-06-25
18:25:50 UTC (rev 1306)
+++
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/StatusConverter.java 2007-06-25
18:26:09 UTC (rev 1307)
@@ -85,7 +85,7 @@
if(value instanceof Status){
status = (Status)value;
}else{
- FacesMessage errorMessage =
ConverterUtils.createTypeErrorMessage(value.getClass().getName(),
Status.class.getName());
+ FacesMessage errorMessage =
ConverterUtils.createTypeErrorMessage(value.getClass().getName(),
Status.class.getName(),ConverterUtils.ERROR_1);
throw new ConverterException(errorMessage);
}
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/utils/ConverterUtils.java
===================================================================
---
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/utils/ConverterUtils.java 2007-06-25
18:25:50 UTC (rev 1306)
+++
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/converters/utils/ConverterUtils.java 2007-06-25
18:26:09 UTC (rev 1307)
@@ -4,12 +4,27 @@
public class ConverterUtils {
- private static final String CONVERSATION_ERROR = "Conversation error: expected
";
+ private static final String CONVERSATION_ERROR = "Conversation error: ";
+
+ public static final int ERROR_1 = 0;
+
+ public static final int ERROR_2 = 1;
- public static FacesMessage createTypeErrorMessage(String received, String expected ){
- String summary = CONVERSATION_ERROR + expected + "found " + received;
+ public static FacesMessage createTypeErrorMessage(String received, String expected, int
type){
+ String summary = null;
+
+ switch (type) {
+ case ERROR_1:
+ summary = CONVERSATION_ERROR + " found " + expected + " found " +
received;
+ break;
+ case ERROR_2:
+ summary = CONVERSATION_ERROR + " found " + received;
+ break;
+ }
+
+
FacesMessage errorMessage = new FacesMessage();
errorMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
errorMessage.setSummary(summary);
Show replies by date