String queryParams = getAttr(Constants.QUERY_PARAMS);
Map<String, Object> params = this._paramMap;
// If queryparams are not null and map is not null, error
if ((queryParams != null) && (params != null)) {
throw new JspException(
"Only one of queryparams or <queryparam> may be used"); //$NON-NLS-1$
}
// If queryParams is not null, then href must not be null.
if ((queryParams != null) || (params != null)) {
String href = getAttr(Constants.HREF);
if (href != null) {
try {
href = evalStringAttr(Constants.DISPLAY_VALUE, href);
if (params == null) {
params = evalHashMapAttr(Constants.QUERY_PARAMS,
queryParams);
}
} catch (Exception e) {
throw new JspException(" Evaluation attribute failed " //$NON-NLS-1$
+ e.getMessage(), e);
}
// now remove the QUERY_PARAMS attr from map
// so not output in genHTML()
removeAttr(Constants.QUERY_PARAMS);
// Add query params to the end of href.
String newHref;
try {
newHref = URLHelper.appendQueryParams(href, params);
} catch (UnsupportedEncodingException e) {
throw new JspException(
" Adding Query params to href has failed " //$NON-NLS-1$
+ e.getMessage(), e);
}
// set hrefs value to the href+queryParams value
setAttr(Constants.HREF, newHref);
} else {
throw new JspException("The " + Constants.QUERY_PARAMS //$NON-NLS-1$
+ " attribute was set, there must also be " //$NON-NLS-1$
+ "an href attribute set. "); //$NON-NLS-1$
}
} // else process href as any other attribute when query params is null.