本文整理汇总了Java中net.sourceforge.stripes.util.UrlBuilder类的典型用法代码示例。如果您正苦于以下问题:Java UrlBuilder类的具体用法?Java UrlBuilder怎么用?Java UrlBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UrlBuilder类属于net.sourceforge.stripes.util包,在下文中一共展示了UrlBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: buildAction
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
protected String buildAction() {
String action = new UrlBuilder(pageContext.getRequest().getLocale(), getAction(), false).setEvent(null)
.toString();
if (action.startsWith("/")) {
HttpServletRequest request = (HttpServletRequest) getPageContext().getRequest();
String contextPath = request.getContextPath();
// *Always* prepend the context path if "beanclass" was used
// Otherwise, *only* prepend it if it is not already present
if (contextPath.length() > 1 && (beanclass != null || !action.startsWith(contextPath + '/'))) {
action = contextPath + action;
}
}
if (isSsl()) {
action = new StringBuilder(App.get().getSecureBasePath()).append(action).toString();
}
HttpServletResponse response = (HttpServletResponse) getPageContext().getResponse();
return response.encodeURL(action);
}
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:23,代码来源:FormTag.java
示例2: execute
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
public void execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
if(request.getParameter("__portofino_quiet_auth_failure") != null) {
return;
}
Subject subject = SecurityUtils.getSubject();
if (!subject.isAuthenticated()) {
new AuthenticationRequiredResolution(errorMessage).execute(request, response);
} else {
ServletContext servletContext = request.getServletContext();
Configuration configuration =
(Configuration) servletContext.getAttribute(BaseModule.PORTOFINO_CONFIGURATION);
String loginPage = configuration.getString(PortofinoProperties.LOGIN_PAGE);
UrlBuilder loginUrlBuilder =
new UrlBuilder(request.getLocale(), loginPage, false);
response.setHeader(AuthenticationRequiredResolution.LOGIN_PAGE_HEADER, loginUrlBuilder.toString());
new ErrorResolution(STATUS, errorMessage).execute(request, response);
}
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:19,代码来源:ForbiddenAccessResolution.java
示例3: doSearch
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
/**
* Executes a search and forwards to the appropriate view.
* @return the result of {@link #getSearchView()}
*/
protected Resolution doSearch() {
if(!isConfigured()) {
logger.debug("Crud not correctly configured");
return forwardToPageActionNotConfigured();
}
try {
executeSearch();
if(PageActionLogic.isEmbedded(this)) {
return getEmbeddedSearchView();
} else {
returnUrl = new UrlBuilder(
context.getLocale(), Util.getAbsoluteUrl(context.getActionPath()), false)
.toString();
returnUrl = appendSearchStringParamIfNecessary(returnUrl);
return getSearchView();
}
} catch(Exception e) {
logger.warn("Crud not correctly configured", e);
return forwardToPageActionNotConfigured();
}
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:27,代码来源:AbstractCrudAction.java
示例4: read
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
public Resolution read() {
if(!crudConfiguration.isLargeResultSet()) {
setupSearchForm(); // serve per la navigazione del result set
loadObjects();
setupResultSetNavigation();
}
setupForm(Mode.VIEW);
form.readFromObject(object);
BlobUtils.loadBlobs(form, getBlobManager(), false);
refreshBlobDownloadHref();
returnUrl = new UrlBuilder(
Locale.getDefault(), Util.getAbsoluteUrl(context.getActionPath()), false)
.toString();
returnUrl = appendSearchStringParamIfNecessary(returnUrl);
if(PageActionLogic.isEmbedded(this)) {
return getEmbeddedReadView();
} else {
return getReadView();
}
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:25,代码来源:AbstractCrudAction.java
示例5: getLinkToPage
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
public String getLinkToPage(int page) {
int rowsPerPage = getCrudConfiguration().getRowsPerPage();
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("sortProperty", getSortProperty());
parameters.put("sortDirection", getSortDirection());
parameters.put("firstResult", page * rowsPerPage);
parameters.put("maxResults", rowsPerPage);
if(!PageActionLogic.isEmbedded(this)) {
parameters.put(AbstractCrudAction.SEARCH_STRING_PARAM, getSearchString());
}
UrlBuilder urlBuilder =
new UrlBuilder(Locale.getDefault(), Util.getAbsoluteUrl(context.getActionPath()), false)
.addParameters(parameters);
return urlBuilder.toString();
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:17,代码来源:AbstractCrudAction.java
示例6: refreshTableBlobDownloadHref
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
protected void refreshTableBlobDownloadHref() {
Iterator<?> objIterator = objects.iterator();
for (TableForm.Row row : tableForm.getRows()) {
Iterator<Field> fieldIterator = row.iterator();
Object obj = objIterator.next();
String baseUrl = null;
while (fieldIterator.hasNext()) {
Field field = fieldIterator.next();
if (field instanceof AbstractBlobField) {
if(baseUrl == null) {
OgnlTextFormat hrefFormat = getReadURLFormat();
baseUrl = hrefFormat.format(obj);
}
Blob blob = ((AbstractBlobField) field).getValue();
if(blob != null) {
UrlBuilder urlBuilder = new UrlBuilder(Locale.getDefault(), baseUrl, false)
.addParameter("downloadBlob", "")
.addParameter("propertyName", field.getPropertyAccessor().getName());
field.setHref(urlBuilder.toString());
}
}
}
}
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:26,代码来源:AbstractCrudAction.java
示例7: read
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
public Resolution read() {
if(!crudConfiguration.isLargeResultSet()) {
setupSearchForm(); // serve per la navigazione del result set
loadObjects();
setupPagination();
}
setupForm(Mode.VIEW);
form.readFromObject(object);
refreshBlobDownloadHref();
returnUrl = new UrlBuilder(
Locale.getDefault(), Util.getAbsoluteUrl(context.getActionPath()), false)
.toString();
returnUrl = appendSearchStringParamIfNecessary(returnUrl);
if(PageActionLogic.isEmbedded(this)) {
return getEmbeddedReadView();
} else {
return getReadView();
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:24,代码来源:AbstractCrudAction.java
示例8: doStartTag
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
/**
* Does sanity checks and returns EVAL_BODY_BUFFERED. Everything else of interest happens in
* doEndTag.
*/
@Override
public int doStartTag() throws JspException {
if (this.actionWithoutContext == null) {
throw new StripesJspException("The form tag attributes 'beanClass' and 'action' "
+ "are both null. One of the two must be supplied to determine which "
+ "action bean should handle the form submission.");
}
getTagStack().push(this);
urlBuilder = new UrlBuilder(pageContext.getRequest().getLocale(), getAction(), false)
.setEvent(null);
return EVAL_BODY_BUFFERED;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:17,代码来源:FormTag.java
示例9: buildUrl
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
/**
* Builds the URL based on the information currently stored in the tag. Ensures that all
* parameters are appended into the URL, along with event name if necessary and the source
* page information.
*
* @return the fully constructed URL
* @throws StripesJspException if the base URL cannot be determined
*/
protected String buildUrl() throws StripesJspException {
HttpServletRequest request = (HttpServletRequest) getPageContext().getRequest();
HttpServletResponse response = (HttpServletResponse) getPageContext().getResponse();
// Add all the parameters and reset the href attribute; pass to false here because
// the HtmlTagSupport will HtmlEncode the ampersands for us
String base = getPreferredBaseUrl();
UrlBuilder builder = new UrlBuilder(pageContext.getRequest().getLocale(), base, false);
if (this.event != VALUE_NOT_SET) {
builder.setEvent(this.event == null || this.event.length() < 1 ? null : this.event);
}
if (addSourcePage) {
builder.addParameter(StripesConstants.URL_KEY_SOURCE_PAGE,
CryptoUtil.encrypt(request.getServletPath()));
}
if (this.anchor != null) {
builder.setAnchor(anchor);
}
builder.addParameters(this.parameters);
// Prepend the context path, but only if the user didn't already
String url = builder.toString();
String contextPath = request.getContextPath();
if (contextPath.length() > 1) {
boolean prepend = prependContext != null && prependContext
|| prependContext == null && beanclass != null
|| prependContext == null && url.startsWith("/") && !url.startsWith(contextPath);
if (prepend) {
if (url.startsWith("/"))
url = contextPath + url;
else
log.warn("Use of prependContext=\"true\" is only valid with a URL that starts with \"/\"");
}
}
return response.encodeURL(url);
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:48,代码来源:LinkTagSupport.java
示例10: getUrl
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
/**
* Constructs the URL for the resolution by taking the path and appending any parameters
* supplied.
*
* @param locale the locale to be used by {@link Formatter}s when formatting parameters
*/
public String getUrl(Locale locale) {
UrlBuilder builder = new UrlBuilder(locale, getPath(), false);
if (event != VALUE_NOT_SET) {
builder.setEvent(event == null || event.length() < 1 ? null : event);
}
if (anchor != null) {
builder.setAnchor(anchor);
}
builder.addParameters(this.parameters);
return builder.toString();
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:18,代码来源:OnwardResolution.java
示例11: execute
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
public void execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
if(request.getParameter("__portofino_quiet_auth_failure") != null) {
return;
}
ServletContext servletContext = request.getServletContext();
Configuration configuration =
(Configuration) servletContext.getAttribute(BaseModule.PORTOFINO_CONFIGURATION);
String loginPage = configuration.getString(PortofinoProperties.LOGIN_PAGE);
if (response.getContentType() == null || response.getContentType().contains("text/html")) {
ElementsActionBeanContext context = new ElementsActionBeanContext();
context.setRequest(request);
String originalPath = context.getActionPath();
UrlBuilder urlBuilder =
new UrlBuilder(Locale.getDefault(), originalPath, false);
Map<?, ?> parameters = request.getParameterMap();
urlBuilder.addParameters(parameters);
String returnUrl = urlBuilder.toString();
logger.info("Anonymous user not allowed to see {}. Redirecting to login.", originalPath);
RedirectResolution redirectResolution =
new RedirectResolution(loginPage, true);
redirectResolution.addParameter("returnUrl", returnUrl);
redirectResolution.execute(request, response);
} else {
logger.debug("AJAX call while user disconnected");
UrlBuilder loginUrlBuilder =
new UrlBuilder(request.getLocale(), loginPage, false);
response.setHeader(LOGIN_PAGE_HEADER, loginUrlBuilder.toString());
new ErrorResolution(STATUS, errorMessage).execute(request, response);
}
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:31,代码来源:AuthenticationRequiredResolution.java
示例12: forgotPassword2
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
public Resolution forgotPassword2() {
Subject subject = SecurityUtils.getSubject();
if (subject.isAuthenticated()) {
logger.debug("Already logged in");
return redirectToReturnUrl();
}
PortofinoRealm portofinoRealm = ShiroUtils.getPortofinoRealm();
try {
Serializable user = portofinoRealm.getUserByEmail(email);
if(user != null) {
String token = portofinoRealm.generateOneTimeToken(user);
HttpServletRequest req = context.getRequest();
String url = req.getRequestURL().toString();
UrlBuilder urlBuilder = new UrlBuilder(Locale.getDefault(), url, true);
urlBuilder.setEvent("resetPassword");
urlBuilder.addParameter("token", token);
String siteUrl = ServletUtils.getApplicationBaseUrl(req);
String changePasswordLink = urlBuilder.toString();
String body = getResetPasswordEmailBody(siteUrl, changePasswordLink);
String from = portofinoConfiguration.getString(
PortofinoProperties.MAIL_FROM, "[email protected]");
sendForgotPasswordEmail(
from, email, ElementsThreadLocals.getText("password.reset.confirmation.required"), body);
} else {
logger.warn("Forgot password request for nonexistent email");
}
//This is by design, for better security. Always give the successful message even if no mail was sent.
SessionMessages.addInfoMessage(ElementsThreadLocals.getText("check.your.mailbox.and.follow.the.instructions"));
} catch (Exception e) {
logger.error("Error during password reset", e);
SessionMessages.addErrorMessage(ElementsThreadLocals.getText("password.reset.failed"));
}
return new RedirectResolution(context.getActionPath());
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:40,代码来源:LoginAction.java
示例13: generateObjectUrl
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
protected String generateObjectUrl(String baseUrl, Object o) {
String[] objPk = pkHelper.generatePkStringArray(o);
String url = baseUrl + "/" + getPkForUrl(objPk);
return new UrlBuilder(
Locale.getDefault(), appendSearchStringParamIfNecessary(url), false)
.toString();
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:8,代码来源:AbstractCrudAction.java
示例14: configureSortLinks
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
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<String, Object>();
parameters.put("sortProperty", propName);
parameters.put("sortDirection", sortDirection);
if(!PageActionLogic.isEmbedded(this)) {
parameters.put(SEARCH_STRING_PARAM, searchString);
}
parameters.put(context.getEventName(), "");
UrlBuilder urlBuilder =
new UrlBuilder(Locale.getDefault(), 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);
}
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:40,代码来源:AbstractCrudAction.java
示例15: getBlobDownloadUrl
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
public String getBlobDownloadUrl(AbstractBlobField field) {
UrlBuilder urlBuilder = new UrlBuilder(
Locale.getDefault(), Util.getAbsoluteUrl(context.getActionPath()), false)
.addParameter("downloadBlob", "")
.addParameter("propertyName", field.getPropertyAccessor().getName());
return urlBuilder.toString();
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:8,代码来源:AbstractCrudAction.java
示例16: execute
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
@DefaultHandler
public Resolution execute() {
if(chartConfiguration == null) {
return forwardToPageActionNotConfigured();
}
try {
// Run/generate the chart
try {
Thread.currentThread().setContextClassLoader(Class.class.getClassLoader());
generateChart();
} finally {
Thread.currentThread().setContextClassLoader(JFreeChartAction.class.getClassLoader());
}
chartId = RandomUtil.createRandomId();
String actionurl = context.getActionPath();
UrlBuilder chartResolution =
new UrlBuilder(context.getLocale(), actionurl, false)
.addParameter("chartId", chartId)
.addParameter("chart", "");
String url = context.getRequest().getContextPath() + chartResolution.toString();
file = RandomUtil.getTempCodeFile(CHART_FILENAME_FORMAT, chartId);
jfreeChartInstance =
new JFreeChartInstance(chart, file, chartId, "Chart: " + chartConfiguration.getName(),
width, height, url);
} catch (Throwable e) {
logger.error("Chart exception", e);
return forwardToPageActionError(e);
}
return new ForwardResolution("/m/chart/jfreechart/display.jsp");
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:37,代码来源:JFreeChartAction.java
示例17: forgotPassword2
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
public Resolution forgotPassword2() {
Subject subject = SecurityUtils.getSubject();
if (subject.isAuthenticated()) {
logger.debug("Already logged in");
return redirectToReturnUrl();
}
PortofinoRealm portofinoRealm = ShiroUtils.getPortofinoRealm();
try {
Serializable user = portofinoRealm.getUserByEmail(email);
if(user != null) {
String token = portofinoRealm.generateOneTimeToken(user);
HttpServletRequest req = context.getRequest();
String url = req.getRequestURL().toString();
UrlBuilder urlBuilder = new UrlBuilder(Locale.getDefault(), url, true);
urlBuilder.setEvent("resetPassword");
urlBuilder.addParameter("token", token);
String siteUrl = ServletUtils.getApplicationBaseUrl(req);
String changePasswordLink = urlBuilder.toString();
String body = getResetPasswordEmailBody(siteUrl, changePasswordLink);
String from = portofinoConfiguration.getString(
PortofinoProperties.MAIL_FROM, "[email protected]");
sendForgotPasswordEmail(
from, email, ElementsThreadLocals.getText("user.passwordReset.emailSubject"), body);
}
SessionMessages.addInfoMessage(ElementsThreadLocals.getText("check.your.mailbox.and.follow.the.instructions"));
} catch (Exception e) {
logger.error("Error during password reset", e);
SessionMessages.addErrorMessage(ElementsThreadLocals.getText("password.reset.failed"));
}
return new RedirectResolution(context.getActionPath());
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:37,代码来源:LoginAction.java
示例18: doSearch
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
protected Resolution doSearch() {
if(!isConfigured()) {
logger.debug("Crud not correctly configured");
return forwardToPageActionNotConfigured();
}
try {
setupSearchForm();
if(maxResults == null) {
//Load only the first page if the crud is paginated
maxResults = getCrudConfiguration().getRowsPerPage();
}
loadObjects();
setupTableForm(Mode.VIEW);
if(PageActionLogic.isEmbedded(this)) {
return getEmbeddedSearchView();
} else {
returnUrl = new UrlBuilder(
context.getLocale(), Util.getAbsoluteUrl(context.getActionPath()), false)
.toString();
returnUrl = appendSearchStringParamIfNecessary(returnUrl);
return getSearchView();
}
} catch(Exception e) {
logger.warn("Crud not correctly configured", e);
return forwardToPageActionNotConfigured();
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:30,代码来源:AbstractCrudAction.java
示例19: configureSortLinks
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
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<String, Object>();
parameters.put("sortProperty", propName);
parameters.put("sortDirection", sortDirection);
if(!PageActionLogic.isEmbedded(this)) {
parameters.put(SEARCH_STRING_PARAM, searchString);
}
parameters.put(context.getEventName(), "");
UrlBuilder urlBuilder =
new UrlBuilder(Locale.getDefault(), 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("i");
xb.addAttribute("class", "pull-right icon-chevron-" + ("desc".equals(sortDirection) ? "up" : "down"));
xb.closeElement("i");
}
xb.closeElement("a");
OgnlTextFormat hrefFormat = OgnlTextFormat.create(xb.toString());
String encoding = getUrlEncoding();
hrefFormat.setEncoding(encoding);
tableFormBuilder.configHeaderTextFormat(propName, hrefFormat);
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:40,代码来源:AbstractCrudAction.java
示例20: refreshTableBlobDownloadHref
import net.sourceforge.stripes.util.UrlBuilder; //导入依赖的package包/类
protected void refreshTableBlobDownloadHref() {
Iterator<?> objIterator = objects.iterator();
for (TableForm.Row row : tableForm.getRows()) {
Iterator<Field> fieldIterator = row.iterator();
Object obj = objIterator.next();
String baseUrl = null;
while (fieldIterator.hasNext()) {
Field field = fieldIterator.next();
if (field instanceof FileBlobField) {
if(baseUrl == null) {
String readLinkExpression = getReadLinkExpression();
String encoding = getUrlEncoding();
OgnlTextFormat hrefFormat =
OgnlTextFormat.create(readLinkExpression);
hrefFormat.setUrl(true);
hrefFormat.setEncoding(encoding);
baseUrl = hrefFormat.format(obj);
}
Blob blob = ((FileBlobField) field).getValue();
if(blob != null) {
UrlBuilder urlBuilder = new UrlBuilder(Locale.getDefault(), baseUrl, false)
.addParameter("downloadBlob", "")
.addParameter("propertyName", field.getPropertyAccessor().getName())
.addParameter("code", blob.getCode());
field.setHref(urlBuilder.toString());
}
}
}
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:33,代码来源:AbstractCrudAction.java
注:本文中的net.sourceforge.stripes.util.UrlBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论