本文整理汇总了Java中net.sourceforge.stripes.action.Resolution类的典型用法代码示例。如果您正苦于以下问题:Java Resolution类的具体用法?Java Resolution怎么用?Java Resolution使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Resolution类属于net.sourceforge.stripes.action包,在下文中一共展示了Resolution类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderContent
import net.sourceforge.stripes.action.Resolution; //导入依赖的package包/类
public Resolution renderContent(String content) {
Configuration conf = FreemarkerHelper.newConfig(app.servletContext(), null);
try {
Template temp = new Template("templateName", new StringReader(content), conf);
// Template temp = conf.getTemplate(new
// StringBuilder(Templates.getWidgetsPath()).append("/").append(path).append(templateSuffix).toString());
StringWriter sw = new StringWriter();
temp.process(null, sw);
return new StreamingResolution("text/html", sw.toString());
} catch (IOException | TemplateException e) {
throw new RuntimeException(e);
}
}
示例2: wishListsAsJson
import net.sourceforge.stripes.action.Resolution; //导入依赖的package包/类
@HandlesEvent("wishlists-json")
public Resolution wishListsAsJson() {
List<WishList> wishLists = getWishLists();
if (wishLists != null) {
List<WishListJson> wishListsJson = new ArrayList<>();
for (WishList wishList : wishLists) {
WishListJson wishListJson = new WishListJson();
wishListJson.setId(wishList.getId());
wishListJson.setDefault(wishList.getDefault());
wishListJson.setName(wishList.getName());
wishListJson.setDelete(false);
wishListJson.setAccess(wishList.getAccessType().toString());
wishListsJson.add(wishListJson);
}
return json(Json.toJson(wishListsJson));
}
return json("");
}
示例3: saveChanges
import net.sourceforge.stripes.action.Resolution; //导入依赖的package包/类
@HandlesEvent("Save")
public Resolution saveChanges() {
PersonManager pm = new PersonManager();
// Save any changes to existing people (and create new ones)
for (Person person : people) {
pm.saveOrUpdate(person);
}
// Then, if the user checked anyone off to be deleted, delete them
if (deleteIds != null) {
for (int id : deleteIds) {
pm.deletePerson(id);
}
}
return new RedirectResolution(getClass());
}
示例4: save
import net.sourceforge.stripes.action.Resolution; //导入依赖的package包/类
/** Saves (or updates) a bug, and then returns the user to the bug list. */
public Resolution save() throws IOException {
BugManager bm = new BugManager();
Bug bug = getBug();
if (this.newAttachment != null) {
Attachment attachment = new Attachment();
attachment.setName(this.newAttachment.getFileName());
attachment.setSize(this.newAttachment.getSize());
attachment.setContentType(this.newAttachment.getContentType());
byte[] data = new byte[(int) this.newAttachment.getSize()];
InputStream in = this.newAttachment.getInputStream();
in.read(data);
attachment.setData(data);
bug.addAttachment(attachment);
}
// Set the open date for new bugs
if (bug.getOpenDate() == null)
bug.setOpenDate(new Date());
bm.saveOrUpdate(bug);
return new RedirectResolution(BugListActionBean.class);
}
示例5: markUnhelpful
import net.sourceforge.stripes.action.Resolution; //导入依赖的package包/类
@HandlesEvent("unhelpful")
public Resolution markUnhelpful() {
HashMap<String, String> result = new HashMap<>();
if (!isCustomerLoggedIn()) {
result.put("error", "not logged in");
return json(Json.toJson(result));
}
Id customerId = ((Customer) getLoggedInCustomer()).getId();
CustomerReview customerReview = customerReviewService.getCustomerReview(getId());
if (customerReview != null) {
if (!customerReview.getRatedByCustomer(customerId)) {
customerReview.getThinkUnhelpful().add(customerId);
customerReviewService.updateReview(customerReview);
}
}
return json(Json.toJson(result));
}
示例6: view
import net.sourceforge.stripes.action.Resolution; //导入依赖的package包/类
/**
* Handler method which will handle a request for a resource in the web application
* and stream it back to the client inside of an HTML preformatted section.
*/
public Resolution view() {
final InputStream stream = getContext().getRequest().getSession()
.getServletContext().getResourceAsStream(this.resource);
final BufferedReader reader = new BufferedReader( new InputStreamReader(stream) );
return new Resolution() {
public void execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
PrintWriter writer = response.getWriter();
writer.write("<html><head><title>");
writer.write(resource);
writer.write("</title></head><body><pre>");
String line;
while ( (line = reader.readLine()) != null ) {
writer.write(HtmlUtil.encode(line));
writer.write("\n");
}
writer.write("</pre></body></html>");
}
};
}
示例7: intercept
import net.sourceforge.stripes.action.Resolution; //导入依赖的package包/类
public Resolution intercept(ExecutionContext context) throws Exception {
HttpServletRequest request = context.getActionBeanContext().getRequest();
String url = HttpUtil.getRequestedPath(request);
if (request.getQueryString() != null)
url = url + '?' + request.getQueryString();
log.debug("Intercepting request: ", url);
Resolution resolution = context.proceed();
// A null resolution here indicates a normal flow to the next stage
boolean authed = ((BugzookyActionBeanContext) context.getActionBeanContext()).getUser() != null;
if (!authed && resolution == null) {
ActionBean bean = context.getActionBean();
if (bean != null && !bean.getClass().isAnnotationPresent(Public.class)) {
log.warn("Thwarted attempted to access ", bean.getClass().getSimpleName());
return new RedirectResolution(LoginActionBean.class).addParameter("targetUrl", url);
}
}
log.debug("Allowing public access to ", context.getActionBean().getClass().getSimpleName());
return resolution;
}
示例8: processEditReview
import net.sourceforge.stripes.action.Resolution; //导入依赖的package包/类
@HandlesEvent("process-edit")
public Resolution processEditReview() {
if (!isCustomerLoggedIn())
return redirect("/customer/account/login");
if (getId() == null)
return new ErrorResolution(404);
CustomerReview customerReview = customerReviewService.getCustomerReview(getId());
if (customerReview == null)
return new ErrorResolution(404);
customerReview.setRating(getRating());
customerReview.setHeadline(getHeadline());
customerReview.setReview(getReview());
customerReview.setPublished(getAutoPublished());
customerReviewService.updateReview(customerReview);
return redirect("/review/customer/" + ((Customer) getLoggedInCustomer()).getId());
}
示例9: reportAbuse
import net.sourceforge.stripes.action.Resolution; //导入依赖的package包/类
@HandlesEvent("abuse")
public Resolution reportAbuse() {
if (getId() == null)
return new ErrorResolution(404);
if (!isCustomerLoggedIn()) {
redirectUrl = "/review/abuse/" + getId();
return redirect("/customer/account/login");
}
CustomerReview review = customerReviewService.getCustomerReview(getId());
if (review == null)
return new ErrorResolution(404);
product = productService.getProduct(review.getProductId());
return view("review/abuse_form");
}
示例10: intercept
import net.sourceforge.stripes.action.Resolution; //导入依赖的package包/类
@Override
public Resolution intercept(ExecutionContext context) throws Exception {
String eventName = context.getActionBeanContext().getEventName();
Resolution r = context.proceed();
// If we have validation errors, Stripes will automatically try to
// forward to the previous action. This unfortunately
// ends up in a StripesRuntimeException "Multiple event parameters [...]
// are present in this request ..." because
// the previous event was not cleared and now stripes has 2 possible
// events. The problem with this is that Stripes
// does not know which one to choose. Here we attempt to overcome this
// by offering Stripes an event that it may
// ignore. See
// com.geecommerce.core.web.AnnotatedClassActionResolver:548.
if (eventName != null && context.getActionBeanContext().getValidationErrors().size() > 0
&& context.getActionBeanContext().getRequest().getAttribute(Constant.STRIPES_IGNORE_EVENT) == null) {
context.getActionBeanContext().getRequest().setAttribute(Constant.STRIPES_IGNORE_EVENT, eventName);
}
return r;
}
示例11: getHandledEvent
import net.sourceforge.stripes.action.Resolution; //导入依赖的package包/类
/**
* First checks with the super class to see if an annotated event name is present, and if
* not then returns the name of the handler method itself. Will return null for methods
* that do not return a resolution or are non-public or abstract.
*
* @param handler a method which may or may not be a handler method
* @return the name of the event handled, or null
*/
@Override
public String getHandledEvent(Method handler) {
String name = super.getHandledEvent(handler);
// If the method isn't annotated, but does return a resolution and is
// not abstract (we already know it's public) then use the method name
if ( name == null
&& !Modifier.isAbstract(handler.getModifiers())
&& Resolution.class.isAssignableFrom(handler.getReturnType())
&& handler.getParameterTypes().length == 0) {
name = handler.getName();
}
return name;
}
示例12: findView
import net.sourceforge.stripes.action.Resolution; //导入依赖的package包/类
/**
* <p>Attempts to locate a default view for the urlBinding provided and return a
* ForwardResolution that will take the user to the view. Looks for views by using the
* list of attempts returned by {@link #getFindViewAttempts(String)}.
*
* <p>For each view name derived a check is performed using
* {@link ServletContext#getResource(String)} to see if there is a file located at that URL.
* Only if a file actually exists will a Resolution be returned.</p>
*
* <p>Can be overridden to provide a different kind of resolution. It is strongly recommended
* when overriding this method to check for the actual existence of views prior to manufacturing
* a resolution in order not to cause confusion when URLs are mistyped.</p>
*
* @param urlBinding the url being accessed by the client in the current request
* @return a Resolution if a default view can be found, or null otherwise
* @since Stripes 1.3
*/
protected Resolution findView(String urlBinding) {
List<String> attempts = getFindViewAttempts(urlBinding);
ServletContext ctx = StripesFilter.getConfiguration()
.getBootstrapPropertyResolver().getFilterConfig().getServletContext();
for (String jsp : attempts) {
try {
// This will try /account/ViewAccount.jsp
if (ctx.getResource(jsp) != null) {
return new ForwardResolution(jsp);
}
}
catch (MalformedURLException mue) {
}
}
return null;
}
示例13: wrap
import net.sourceforge.stripes.action.Resolution; //导入依赖的package包/类
/**
* Used by the {@link DispatcherServlet} to wrap a block of lifecycle code in
* {@link Interceptor} calls.
*
* @param target a block of lifecycle/request processing code that is contained inside
* a class that implements Interceptor
* @return a Resolution instance or null depending on what is returned by the lifecycle
* code and any interceptors which intercept the execution
* @throws Exception if the lifecycle code or an interceptor throws an Exception
*/
public Resolution wrap(Interceptor target) throws Exception {
this.target = target;
this.iterator = null;
// Before executing RequestInit, set this as the current execution context
if (lifecycleStage == LifecycleStage.RequestInit)
currentContext.set(this);
try {
return proceed();
}
finally {
// Make sure the current execution context gets cleared after RequestComplete
if (LifecycleStage.RequestComplete == getLifecycleStage())
currentContext.set(null);
}
}
示例14: handle
import net.sourceforge.stripes.action.Resolution; //导入依赖的package包/类
/** Invokes the handler and executes the resolution if one is returned. */
public void handle(Throwable t, HttpServletRequest req, HttpServletResponse res) throws Exception {
try {
Object resolution = handlerMethod.invoke(this.handler, t, req, res);
if (resolution != null && resolution instanceof Resolution) {
((Resolution) resolution).execute(req, res);
}
}
catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause instanceof Exception)
throw (Exception) cause;
else if (cause instanceof Error)
throw (Error) cause;
else
throw e;
}
}
示例15: intercept
import net.sourceforge.stripes.action.Resolution; //导入依赖的package包/类
public Resolution intercept(ExecutionContext executionContext)
throws Exception {
BaseActionBean actionBean = (BaseActionBean) executionContext.getActionBean();
//validate annotation at class level
Resolution resolution = validateClassLevelAccess(actionBean);
if (resolution != null) {
return resolution;
}
//validate annotation at method level
resolution = validateMethodLevelAccess(actionBean);
if (resolution != null) {
return resolution;
}
return executionContext.proceed();
}