First, the assembly parameters of learning
The first is the query, the query conditions, the need to determine whether a null value passed from the front? - how to deal with inquiries null values?
A determination may of course be one of, but this leads to a lot of code that can be unitary, a common method.
1, a single process by:
Sentenced to call the utility method empty (bottom: determine whether it is null and empty)
/ ** UtilValidate class. * /
/** Check whether string s is NOT empty. */
public static boolean isNotEmpty(String s) {
return (s != null) && s.length() > 0;
}
/** Check whether collection c is NOT empty. */
public static <E> boolean isNotEmpty(Collection<E> c) {
return (c != null) && !c.isEmpty();
}
/** Check whether charsequence c is NOT empty. */
public static <E> boolean isNotEmpty(CharSequence c) {
return ((c != null) && (c.length() > 0));
}
if (UtilValidate.isNotEmpty(startDate)) { condList.add(EntityCondition.makeCondition(PackagePrepayFields.REPAY_APP_DATE, EntityOperator.GREATER_THAN_EQUAL_TO, startDate)); }
1, page
1.1 Service (Method name) corresponds to XML
To the Senate
<attribute name="viewSize" type="Integer" mode="IN" optional="true" description="条数" /> <attribute name="viewIndex" type="Integer" mode="IN" optional="true" description="页码" />
A reference
< Attribute name = "the returnCode" type = "the Map" MODE = "OUT" optional = "to true" Description = "normal return state data" /> < attribute name = "totalSize" type = "Integer" MODE = "OUT" optional = "to true" Description = "returns the total number of" /> <- Note here that the case of the parameters ->
1.2 Java code output
result.put("list", pagedList.getData());
result.put("totalSize", pagedList.getSize());
2, EntityQuery learning
// 带分页参数
PagedList<GenericValue> pagedList = EntityQuery.use(delegator) .select(columns) .from(PackagePrepayFields.COM_MESSAGE_INFO_TEXT_THREE) .where(condList) .cursorScrollInsensitive() .queryPagedList(viewIndex - 1, viewSize);
// 不带分页
List<GenericValue> list =EntityQuery.use(delegator)
.select(columns)
.from(PackagePrepayFields.COM_MESSAGE_INFO_TEXT_THREE)
.where(condList)
.queryList();