本文整理汇总了Java中net.sourceforge.stripes.controller.StripesConstants类的典型用法代码示例。如果您正苦于以下问题:Java StripesConstants类的具体用法?Java StripesConstants怎么用?Java StripesConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StripesConstants类属于net.sourceforge.stripes.controller包,在下文中一共展示了StripesConstants类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getValue
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
* Attempts to resolve the value as described in the class level javadoc.
* @param ctx the ELContext for the expression
* @param base the object on which the property resides (null == root property)
* @param prop the name of the property being looked for
* @return the value of the property or null if one can't be found
*/
@Override
public Object getValue(ELContext ctx, Object base, Object prop) {
if (ExpressionExecutorSupport.isSelfKeyword(this.bean, prop)) {
ctx.setPropertyResolved(true);
return this.currentValue;
}
else if (StripesConstants.REQ_ATTR_ACTION_BEAN.equals(prop)) {
ctx.setPropertyResolved(true);
return this.bean;
}
else {
try {
base = base == null ? this.bean : base;
Object retval = BeanUtil.getPropertyValue(String.valueOf(prop), base);
ctx.setPropertyResolved(true);
return retval;
}
catch (Exception e) { return null; }
}
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:28,代码来源:Jsp21ExpressionExecutor.java
示例2: setSourcePage
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
* All requests to Stripes that can generate validation errors are required to supply a
* request parameter telling Stripes where the request came from. If you do not supply a
* value for this parameter then the value of MockRoundTrip.DEFAULT_SOURCE_PAGE will be used.
*/
public void setSourcePage(String url) {
if (url != null) {
url = CryptoUtil.encrypt(url);
}
setParameter(StripesConstants.URL_KEY_SOURCE_PAGE, url);
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:12,代码来源:MockRoundtrip.java
示例3: getValueFromActionBean
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
* Helper method that will check to see if there is an ActionBean present in the request,
* and if so, retrieve the value for this tag from the ActionBean.
*
* @param tag the tag whose values to look for
* @return an Object, possibly null, representing the tag's value
*/
protected Object getValueFromActionBean(InputTagSupport tag) throws StripesJspException {
ActionBean actionBean = tag.getParentFormTag().getActionBean();
Object value = null;
if (actionBean != null) {
try {
value = BeanUtil.getPropertyValue(tag.getName(), actionBean);
}
catch (ExpressionException ee) {
if (!StripesConstants.SPECIAL_URL_KEYS.contains(tag.getName())) {
log.info("Could not find property [", tag.getName(), "] on ActionBean.", ee);
}
}
}
return value;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:25,代码来源:DefaultPopulationStrategy.java
示例4: getLocalizedFieldName
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
* Attempts to fetch a "field name" resource from the localization bundle. Delegates
* to {@link LocalizationUtility#getLocalizedFieldName(String, String, Class, java.util.Locale)}
*
* @param name the field name or resource to look up
* @return the localized String corresponding to the name provided
* @throws StripesJspException
*/
protected String getLocalizedFieldName(final String name) throws StripesJspException {
Locale locale = getPageContext().getRequest().getLocale();
FormTag form = null;
try { form = getParentFormTag(); }
catch (StripesJspException sje) { /* Do nothing. */}
String actionPath = null;
Class<? extends ActionBean> beanClass = null;
if (form != null) {
actionPath = form.getAction();
beanClass = form.getActionBeanClass();
}
else {
ActionBean mainBean = (ActionBean) getPageContext().getRequest().getAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN);
if (mainBean != null) {
beanClass = mainBean.getClass();
}
}
return LocalizationUtility.getLocalizedFieldName(name, actionPath, beanClass, locale);
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:31,代码来源:InputTagSupport.java
示例5: getExcludes
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/** Returns the list of parameters that should be excluded from the hidden tag. */
protected Set<String> getExcludes(FormTag form) {
Set<String> excludes = new HashSet<String>();
excludes.addAll(form.getRegisteredFields());
excludes.add(StripesConstants.URL_KEY_SOURCE_PAGE);
excludes.add(StripesConstants.URL_KEY_FIELDS_PRESENT);
excludes.add(StripesConstants.URL_KEY_EVENT_NAME);
excludes.add(StripesConstants.URL_KEY_FLASH_SCOPE_ID);
// Use the submitted action bean to eliminate any event related parameters
ServletRequest request = getPageContext().getRequest();
ActionBean submittedActionBean = (ActionBean) request
.getAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN);
if (submittedActionBean != null) {
String eventName = submittedActionBean.getContext().getEventName();
if (eventName != null) {
excludes.add(eventName);
excludes.add(eventName + ".x");
excludes.add(eventName + ".y");
}
}
return excludes;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:25,代码来源:WizardFieldsTag.java
示例6: getRequestedPath
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
* <p>
* Get the path from the given request. This method is different from
* {@link HttpServletRequest#getRequestURI()} in that it concatenates and returns the servlet
* path plus the path info from the request. These are usually the same, but in some cases they
* are not.
* </p>
* <p>
* One case where they are known to differ is when a request for a directory is forwarded by the
* servlet container to a welcome file. In that case, {@link HttpServletRequest#getRequestURI()}
* returns the path that was actually requested (e.g., {@code "/"}), whereas the servlet path
* plus path info is the path to the welcome file (e.g. {@code "/index.jsp"}).
* </p>
*/
public static String getRequestedPath(HttpServletRequest request) {
String servletPath, pathInfo;
// Check to see if the request is processing an include, and pull the path
// information from the appropriate source.
// only request attributes need decoding, not servletPath and pathInfo
// see http://www.stripesframework.org/jira/browse/STS-899
servletPath = urlDecodeNullSafe((String) request.getAttribute(StripesConstants.REQ_ATTR_INCLUDE_PATH));
if (servletPath != null) {
pathInfo = urlDecodeNullSafe((String) request.getAttribute(StripesConstants.REQ_ATTR_INCLUDE_PATH_INFO));
}
else {
servletPath = request.getServletPath();
pathInfo = request.getPathInfo();
}
if (servletPath == null)
return pathInfo == null ? "" : pathInfo;
else if (pathInfo == null)
return servletPath;
else
return servletPath + pathInfo;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:39,代码来源:HttpUtil.java
示例7: execute
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
* Attempts to forward the user to the specified path.
* @throws ServletException thrown when the Servlet container encounters an error
* @throws IOException thrown when the Servlet container encounters an error
*/
public void execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
if (status != null) {
response.setStatus(status);
}
String path = getUrl(request.getLocale());
// Set event name as a request attribute
String oldEvent = (String) request.getAttribute(StripesConstants.REQ_ATTR_EVENT_NAME);
request.setAttribute(StripesConstants.REQ_ATTR_EVENT_NAME, event);
// Figure out if we're inside an include, and use an include instead of a forward
if (autoInclude && request.getAttribute(StripesConstants.REQ_ATTR_INCLUDE_PATH) != null) {
log.trace("Including URL: ", path);
request.getRequestDispatcher(path).include(request, response);
}
else {
log.trace("Forwarding to URL: ", path);
request.getRequestDispatcher(path).forward(request, response);
}
// Revert event name to its original value
request.setAttribute(StripesConstants.REQ_ATTR_EVENT_NAME, oldEvent);
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:31,代码来源:ForwardResolution.java
示例8: doStartTag
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
* Determine if the body should be evaluated or not.
*
* @return EVAL_BODY_INCLUDE if the body should be included, or SKIP_BODY
* @throws JspException when the tag cannot (decide if to) write the body content
*/
@Override
public int doStartTag() throws JspException {
// Retrieve the action bean and event handler to secure.
SecurityAwareActionBean actionBean = (SecurityAwareActionBean) pageContext
.findAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN);
boolean render = !actionBean.isAtLeastOneSecuredTagRendered();
if (actionBean.getContext().getValidationErrors().size() > 0) {
render = false;
}
return render ? EVAL_BODY_AGAIN : SKIP_BODY;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:22,代码来源:NoSecuredTagRenderedTag.java
示例9: preparePage
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
protected void preparePage(ContainerRequestContext requestContext, Object resource) {
if(resource instanceof PageAction) {
PageAction pageAction = (PageAction) resource;
HttpServletRequest request = ElementsThreadLocals.getHttpServletRequest();
request.setAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN, pageAction);
if(!pageAction.getPageInstance().isPrepared()) {
ElementsActionBeanContext context = new ElementsActionBeanContext();
context.setRequest(request);
context.setResponse(response);
context.setServletContext(request.getServletContext());
context.setEventName("");
String path = requestContext.getUriInfo().getPath();
if(!path.startsWith("/")) {
path = "/" + path;
}
context.setActionPath(path); //TODO
pageAction.setContext(context);
Resolution resolution = pageAction.preparePage();
if(resolution != null) {
requestContext.abortWith(Response.serverError().entity(resolution).build());
}
}
}
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:25,代码来源:PortofinoFilter.java
示例10: resolveVariable
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
* Recognizes a couple of special variables, and if the property requested
* isn't one of them, just looks up a property on the action bean.
*
* @param property the name of the variable/property being looked for
* @return the property value or null
* @throws javax.servlet.jsp.el.ELException
*/
public Object resolveVariable(String property) throws ELException {
if (isSelfKeyword(bean, property)) {
return this.currentValue;
}
else if (StripesConstants.REQ_ATTR_ACTION_BEAN.equals(property)) {
return this.bean;
}
else {
try { return BeanUtil.getPropertyValue(property, bean); }
catch (Exception e) { return null; }
}
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:21,代码来源:ExpressionExecutorSupport.java
示例11: getTagStack
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
* Fetches a tag stack that is stored in the request. This tag stack is used to help
* Stripes tags find one another when they are spread across multiple included JSPs
* and/or tag files - situations in which the usual parent tag relationship fails.
*/
@SuppressWarnings("unchecked")
protected Stack<StripesTagSupport> getTagStack() {
Stack<StripesTagSupport> stack = (Stack<StripesTagSupport>)
getPageContext().getRequest().getAttribute(StripesConstants.REQ_ATTR_TAG_STACK);
if (stack == null) {
stack = new Stack<StripesTagSupport>();
getPageContext().getRequest().setAttribute(StripesConstants.REQ_ATTR_TAG_STACK, stack);
}
return stack;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:18,代码来源:StripesTagSupport.java
示例12: getValue
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
* Implementation of the interface method that will follow the search described in the class
* level JavaDoc and attempt to find a value for this tag.
*
* @param tag the form input tag whose value to populate
* @return Object will be one of null, a single Object or an Array of Objects depending upon
* what was submitted in the prior request, and what is declared on the ActionBean
*/
@Override
public Object getValue(InputTagSupport tag) throws StripesJspException {
// If the specific tag is in error, grab the values from the request
if (tag.hasErrors()) {
return super.getValue(tag);
}
else {
// Try getting from the ActionBean. If the bean is present and the property
// is defined, then the value from the bean takes precedence even if it's null
ActionBean bean = tag.getActionBean();
Object value = null;
boolean kaboom = false;
if (bean != null) {
try {
value = BeanUtil.getPropertyValue(tag.getName(), bean);
}
catch (ExpressionException ee) {
if (!StripesConstants.SPECIAL_URL_KEYS.contains(tag.getName())) {
log.info("Could not find property [", tag.getName(), "] on ActionBean.", ee);
}
kaboom = true;
}
}
// If there's no matching bean property, then look elsewhere
if (bean == null || kaboom) {
value = getValueFromTag(tag);
if (value == null) {
value = getValuesFromRequest(tag);
}
}
return value;
}
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:45,代码来源:BeanFirstPopulationStrategy.java
示例13: writeSourcePageHiddenField
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/** Write out a hidden field with the name of the page in it. */
protected void writeSourcePageHiddenField(JspWriter out) throws IOException {
out.write("<input type=\"hidden\" name=\"");
out.write(StripesConstants.URL_KEY_SOURCE_PAGE);
out.write("\" value=\"");
out.write(getSourcePageValue());
out.write(isXmlTags() ? "\" />" : "\">");
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:9,代码来源:FormTag.java
示例14: buildUrl
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的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
示例15: getCurrentPagePath
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/** Get the context-relative path of the page that invoked this tag. */
public String getCurrentPagePath() {
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
String path = (String) request.getAttribute(StripesConstants.REQ_ATTR_INCLUDE_PATH);
if (path == null)
path = HttpUtil.getRequestedPath(request);
return path;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:9,代码来源:LayoutTag.java
示例16: SourcePageNotFoundException
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
* Construct a new instance for the given action bean context.
*
* @param actionBeanContext The context.
*/
public SourcePageNotFoundException(ActionBeanContext actionBeanContext) {
// @formatter:off
super(
"Here's how it is. Someone (quite possibly the Stripes Dispatcher) needed " +
"to get the source page resolution. But no source page was supplied in the " +
"request, and unless you override ActionBeanContext.getSourcePageResolution() " +
"you're going to need that value. When you use a <stripes:form> tag a hidden " +
"field called '" + StripesConstants.URL_KEY_SOURCE_PAGE + "' is included. " +
"If you write your own forms or links that could generate validation errors, " +
"you must include a value for this parameter. This can be done by calling " +
"request.getServletPath().");
// @formatter:on
this.actionBeanContext = actionBeanContext;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:20,代码来源:SourcePageNotFoundException.java
示例17: getRequestedServletPath
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
* Get the servlet path of the current request. The value returned by this method may differ
* from {@link HttpServletRequest#getServletPath()}. If the given request is an include, then
* the servlet path of the included resource is returned.
*/
public static String getRequestedServletPath(HttpServletRequest request) {
// Check to see if the request is processing an include, and pull the path
// information from the appropriate source.
String path = (String) request.getAttribute(StripesConstants.REQ_ATTR_INCLUDE_PATH);
if (path == null) {
path = request.getServletPath();
}
return path == null ? "" : path;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:15,代码来源:HttpUtil.java
示例18: doStartTag
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
* Determine if the body should be evaluated or not.
*
* @return EVAL_BODY_INCLUDE if the body should be included, or SKIP_BODY
* @throws JspException when the tag cannot (decide if to) write the body content
*/
@Override
public int doStartTag() throws JspException {
// Retrieve the action bean and event handler to secure.
SecurityAwareActionBean actionBean = (SecurityAwareActionBean) pageContext
.findAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN);
if (name == null) {
return EVAL_BODY_AGAIN;
}
ApplicationContext context = WebApplicationContextUtils
.getWebApplicationContext(actionBean.getContext()
.getServletContext());
BeyondJWebSecurityManager securityManager = (BeyondJWebSecurityManager) context
.getBean(SECURITY_MANAGER);
if (securityManager == null) {
String msg = "Failed to obtain the BeyondJSecurityManager";
throw new StripesRuntimeException(msg);
}
boolean eventAllowed = false;
try {
eventAllowed = Boolean.TRUE.equals(securityManager
.getAccessAllowed(actionBean, this));
} catch (Exception e) {
LOG.error("Error: ", e);
}
if (eventAllowed) {
actionBean.setAtLeastOneSecuredTagRendered(true);
}
// Show the tag's content (or not) based on this
return eventAllowed ? EVAL_BODY_AGAIN : SKIP_BODY;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:45,代码来源:ProtectedElementTag.java
示例19: getEventNameFromEventNameParam
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
* Looks to see if there is a single non-empty parameter value for the
* parameter name specified by {@link StripesConstants#URL_KEY_EVENT_NAME}.
* If there is, and it matches a known event it is returned, otherwise
* returns null.
*
* @param bean
* the ActionBean type bound to the request
* @param context
* the ActionBeanContect for the current request
* @return String the name of the event submitted, or null if none can be
* found
*/
protected String getEventNameFromEventNameParam(Class<? extends ActionBean> bean, ActionBeanContext context) {
String[] values = context.getRequest().getParameterValues(StripesConstants.URL_KEY_EVENT_NAME);
String event = null;
if (values != null && values.length == 1
&& eventMappings.get(getGuicelessActionBean(bean)).containsKey(values[0])) {
event = values[0];
}
// Warn of non-backward-compatible behavior
if (event != null) {
try {
String otherName = getEventNameFromRequestParams(bean, context);
if (otherName != null && !otherName.equals(event)) {
String[] otherValue = context.getRequest().getParameterValues(otherName);
log.warn("The event name was specified by two request parameters: ",
StripesConstants.URL_KEY_EVENT_NAME, "=", event, " and ", otherName, "=",
Arrays.toString(otherValue), ". ", "As of Stripes 1.5, ",
StripesConstants.URL_KEY_EVENT_NAME, " overrides all other request parameters.");
}
} catch (StripesRuntimeException e) {
// Ignore this. It means there were too many event params, which
// is OK in this case.
}
}
return event;
}
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:41,代码来源:AnnotatedClassActionResolver.java
示例20: emit
import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
public static void emit(HttpServletRequest request, XhtmlBuffer xb) {
//Setup base href - uniform handling of .../resource and .../resource/
ActionBean actionBean = (ActionBean) request.getAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN);
if(actionBean instanceof AbstractActionBean) {
String baseHref =
request.getContextPath() +
((AbstractActionBean) actionBean).getContext().getActionPath();
//Remove all trailing slashes
while (baseHref.length() > 1 && baseHref.endsWith("/")) {
baseHref = baseHref.substring(0, baseHref.length() - 1);
}
//Add a single trailing slash so all relative URLs use this page as the root
baseHref += "/";
//Try to make the base HREF absolute
try {
URL url = new URL(request.getRequestURL().toString());
String port = url.getPort() > 0 ? ":" + url.getPort() : "";
baseHref = url.getProtocol() + "://" + url.getHost() + port + baseHref;
} catch (MalformedURLException e) {
//Ignore
}
xb.openElement("base");
xb.addAttribute("href", baseHref);
xb.closeElement("base");
}
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:28,代码来源:BaseHref.java
注:本文中的net.sourceforge.stripes.controller.StripesConstants类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论