husted 2002/11/04 15:28:51
Modified: scaffold/src/java/org/apache/commons/scaffold/sql
ScrollerBeanBase.java StorageBeanBase.java
Log:
+ Add support for searchLabel and isLike properties.
Revision Changes Path
1.3 +41 -14
jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/sql/ScrollerBeanBase.java
Index: ScrollerBeanBase.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/sql/ScrollerBeanBase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ScrollerBeanBase.java 31 Oct 2002 14:27:08 -0000 1.2
+++ ScrollerBeanBase.java 4 Nov 2002 23:28:51 -0000 1.3
@@ -76,12 +76,24 @@
// See interface for Javadoc
+ public boolean isLike() {
+ return false;
+ }
+
+
+ // See interface for Javadoc
public int entryCount() throws ResourceException {
- if (hasParameter())
- return count(countKey(),searchValue());
- else
- return count(countKey());
+ if (hasParameter()) {
+
+ if (isLike())
+ return count(countKey(),like(searchValue().toString()));
+ else
+ return count(countKey(),searchValue());
+
+ }
+
+ return count(countKey());
}
@@ -100,6 +112,12 @@
// See interface for Javadoc
+ public String searchLabel() {
+ return searchProperty();
+ }
+
+
+ // See interface for Javadoc
public boolean failsOnEmpty () {
return false;
}
@@ -146,7 +164,10 @@
throws ResourceException {
String param = null;
- if (null!=parameter) param = parameter.toString();
+ if (null!=parameter) {
+ if (isLike()) param = like(parameter.toString());
+ else param = parameter.toString();
+ }
return findCollection(
target,
@@ -177,10 +198,19 @@
}
- /**
- * Invoke business logic; return ProcessResult.
- */
- public Object scrollerSearch() throws Exception {
+ // See interface for Javadoc
+ public void listLegend(ResultList list) {
+
+ if (hasParameter())
+ list.setLegend(searchLabel(),searchValue().toString());
+ else
+ list.setLegend(searchLabel());
+
+ }
+
+
+ // See interface for Javadoc
+ public ProcessResult scrollerSearch() throws Exception {
Object key = null;
if (hasParameter()) {
@@ -195,10 +225,7 @@
list.setScroller(scroller);
ProcessResult result = new ProcessResultBase(list);
- if (hasParameter())
- list.setLegend(searchProperty(),key.toString());
- else
- list.setLegend(searchProperty());
+ listLegend(list);
if (failsOnEmpty() && list.isEmpty()) {
result.addMessage(tokenEmptyMessage());
1.12 +21 -21
jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/sql/StorageBeanBase.java
Index: StorageBeanBase.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/sql/StorageBeanBase.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- StorageBeanBase.java 31 Oct 2002 14:27:08 -0000 1.11
+++ StorageBeanBase.java 4 Nov 2002 23:28:51 -0000 1.12
@@ -128,13 +128,13 @@
* Our command string properties.
* Can be loaded from an external properties file at startup.
*/
- private static Properties commands;
+ protected static Properties commands;
/**
* Retrieve command from <code>commands</code> Properties
*/
- protected final String getCommand(String key)
+ protected String lookup(String key)
throws PropertiesException {
if (null==commands) throw new PropertiesException();
@@ -156,7 +156,7 @@
/**
* Retrieve command from <code>commands</code> Properties
*/
- protected final String getCommandRoot(String key)
+ protected String lookupRoot(String key)
throws PropertiesException {
if (null==commands) throw new PropertiesException();
@@ -319,7 +319,7 @@
try {
int result = StatementUtils.executeUpdate(
- null,getCommand(command));
+ null,lookup(command));
}
catch (SQLException e) {
@@ -335,7 +335,7 @@
try {
int result = StatementUtils.executeUpdate(
- null,getCommandRoot(command));
+ null,lookupRoot(command));
}
catch (SQLException e) {
@@ -357,7 +357,7 @@
result = (Integer) StatementUtils.getColumn(
null,
1,
- getCommand(command)
+ lookup(command)
);
}
catch (SQLException e) {
@@ -378,7 +378,7 @@
result = (Integer) StatementUtils.getColumn(
null,
1,
- getCommand(command),
+ lookup(command),
parameter
);
}
@@ -401,7 +401,7 @@
try {
found = StatementUtils.getElement(null,target,
- getCommand(command),key);
+ lookup(command),key);
}
catch (SQLException e) {
@@ -424,7 +424,7 @@
try {
return StatementUtils.getCollection(null,
- target,getCommand(command));
+ target,lookup(command));
}
catch (SQLException e) {
@@ -446,7 +446,7 @@
try {
return StatementUtils.getCollection(null,
- target,getCommand(command),parameter);
+ target,lookup(command),parameter);
}
catch (SQLException e) {
@@ -467,7 +467,7 @@
try {
return StatementUtils.getCollection(null,
- target,getCommand(command),parameter);
+ target,lookup(command),parameter);
}
catch (SQLException e) {
@@ -484,7 +484,7 @@
try {
return StatementUtils.getCollection(null,
- target,getCommand(command),parameters);
+ target,lookup(command),parameters);
}
catch (SQLException e) {
@@ -701,9 +701,9 @@
result = StatementUtils.createKey(
null,
1,
- getCommandRoot(KEYS_NEXT),
- getCommand(keyName),
- getCommandRoot(KEYS_INC)
+ lookupRoot(KEYS_NEXT),
+ lookup(keyName),
+ lookupRoot(KEYS_INC)
);
}
@@ -734,10 +734,10 @@
String command = null;
if (isInsert) {
- command = getCommand(INSERT);
+ command = lookup(INSERT);
}
else {
- command = getCommand(UPDATE);
+ command = lookup(UPDATE);
}
Timestamp modified = getModified();
@@ -849,7 +849,7 @@
// Mark as deleted
result = StatementUtils.executeUpdate(null,
- getCommand(DELETE),getPrimaryKey());
+ lookup(DELETE),getPrimaryKey());
}
catch (SQLException e) {
@@ -906,7 +906,7 @@
// Mark as recycled
result = StatementUtils.executeUpdate(null,
- getCommand(RECYCLE),getPrimaryKey());
+ lookup(RECYCLE),getPrimaryKey());
}
catch (SQLException e) {
@@ -964,7 +964,7 @@
try {
result = StatementUtils.executeUpdate(null,
- getCommand(RESTORE),getPrimaryKey());
+ lookup(RESTORE),getPrimaryKey());
}
catch (SQLException e) {
--
To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>