use of com.manydesigns.elements.servlet.UrlBuilder in project Portofino by ManyDesigns.
the class AbstractCrudAction method configureSortLinks.
protected void configureSortLinks(TableFormBuilder tableFormBuilder) {
for (PropertyAccessor propertyAccessor : classAccessor.getProperties()) {
String propName = propertyAccessor.getName();
String sortDirection;
if (propName.equals(sortProperty) && "asc".equals(this.sortDirection)) {
sortDirection = "desc";
} else {
sortDirection = "asc";
}
Map<String, Object> parameters = new HashMap<>();
parameters.put("sortProperty", propName);
parameters.put("sortDirection", sortDirection);
parameters.put(SEARCH_STRING_PARAM, searchString);
Charset charset = Charset.forName(context.getRequest().getCharacterEncoding());
UrlBuilder urlBuilder = new UrlBuilder(charset, Util.getAbsoluteUrl(context.getActionPath()), false).addParameters(parameters);
XhtmlBuffer xb = new XhtmlBuffer();
xb.openElement("a");
xb.addAttribute("class", "sort-link");
xb.addAttribute("href", urlBuilder.toString());
xb.writeNoHtmlEscape("%{label}");
if (propName.equals(sortProperty)) {
xb.openElement("em");
xb.addAttribute("class", "pull-right glyphicon glyphicon-chevron-" + ("desc".equals(sortDirection) ? "up" : "down"));
xb.closeElement("em");
}
xb.closeElement("a");
OgnlTextFormat hrefFormat = OgnlTextFormat.create(xb.toString());
String encoding = getUrlEncoding();
hrefFormat.setEncoding(encoding);
tableFormBuilder.configHeaderTextFormat(propName, hrefFormat);
}
}
use of com.manydesigns.elements.servlet.UrlBuilder in project Portofino by ManyDesigns.
the class AbstractCrudAction method getLinkToPage.
public String getLinkToPage(int page) {
int rowsPerPage = getCrudConfiguration().getRowsPerPage();
Map<String, Object> parameters = new HashMap<>();
parameters.put("sortProperty", getSortProperty());
parameters.put("sortDirection", getSortDirection());
parameters.put("firstResult", page * rowsPerPage);
parameters.put("maxResults", rowsPerPage);
parameters.put(AbstractCrudAction.SEARCH_STRING_PARAM, getSearchString());
Charset charset = Charset.forName(context.getRequest().getCharacterEncoding());
UrlBuilder urlBuilder = new UrlBuilder(charset, Util.getAbsoluteUrl(context.getActionPath()), false).addParameters(parameters);
return urlBuilder.toString();
}
use of com.manydesigns.elements.servlet.UrlBuilder in project Portofino by ManyDesigns.
the class AbstractCrudAction method getBlobDownloadUrl.
public String getBlobDownloadUrl(Field field, String baseUrl) {
Charset charset = Charset.forName(context.getRequest().getCharacterEncoding());
UrlBuilder urlBuilder = new UrlBuilder(charset, Util.getAbsoluteUrl(context.getRequest(), baseUrl + "/:blob/" + field.getPropertyAccessor().getName()), false);
return urlBuilder.toString();
}
Aggregations