本文整理汇总了Java中net.sourceforge.stripes.exception.StripesJspException类的典型用法代码示例。如果您正苦于以下问题:Java StripesJspException类的具体用法?Java StripesJspException怎么用?Java StripesJspException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StripesJspException类属于net.sourceforge.stripes.exception包,在下文中一共展示了StripesJspException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getValue
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的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
*/
public Object getValue(InputTagSupport tag) throws StripesJspException {
// Look first for something that the user submitted in the current request
Object value = getValuesFromRequest(tag);
// If that's not there, let's look on the ActionBean
if (value == null) {
value = getValueFromActionBean(tag);
}
// And if there's no value there, look at the tag's own value
if (value == null) {
value = getValueFromTag(tag);
}
return value;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:25,代码来源:DefaultPopulationStrategy.java
示例2: getValuesFromRequest
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的package包/类
/**
* Helper method that will check the current request for user submitted values for the
* tag supplied and return them as a String[] if there is one or more present.
*
* @param tag the tag whose values to look for
* @return a String[] if values are found, null otherwise
*/
protected String[] getValuesFromRequest(InputTagSupport tag) throws StripesJspException {
String[] value = tag.getPageContext().getRequest().getParameterValues(tag.getName());
/*
* If the value was pulled from a request parameter and the ActionBean property it would
* bind to is flagged as encrypted, then the value needs to be decrypted now.
*/
if (value != null) {
// find the action bean class we're dealing with
Class<? extends ActionBean> beanClass = tag.getParentFormTag().getActionBeanClass();
if (beanClass != null) {
ValidationMetadata validate = config.getValidationMetadataProvider()
.getValidationMetadata(beanClass, new ParameterName(tag.getName()));
if (validate != null && validate.encrypted()) {
String[] copy = new String[value.length];
for (int i = 0; i < copy.length; i++) {
copy[i] = CryptoUtil.decrypt(value[i]);
}
value = copy;
}
}
}
return value;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:33,代码来源:DefaultPopulationStrategy.java
示例3: getValueFromActionBean
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的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: setBeanclass
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的package包/类
/**
* Sets the 'action' attribute by inspecting the bean class provided and asking the current
* ActionResolver what the appropriate URL is.
*
* @param beanclass the String FQN of the class, or a Class representing the class
* @throws StripesJspException if the URL cannot be determined for any reason, most likely
* because of a mis-spelled class name, or a class that's not an ActionBean
*/
public void setBeanclass(Object beanclass) throws StripesJspException {
String url = getActionBeanUrl(beanclass);
if (url == null) {
throw new StripesJspException(
"Could not determine action from 'beanclass' supplied. "
+ "The value supplied was '"
+ beanclass
+ "'. Please ensure that this bean type "
+ "exists and is in the classpath. If you are developing a page and the ActionBean "
+ "does not yet exist, consider using the 'action' attribute instead for now.");
}
else {
setAction(url);
}
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:24,代码来源:FieldMetadataTag.java
示例5: getSingleOverrideValue
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的package包/类
/**
* Returns a single value for the the value of this field. This can be used to ensure that
* only a single value is returned by the population strategy, which is useful in the case
* of text inputs etc. which can have only a single value.
*
* @return Object either a single value or null
* @throws StripesJspException if the enclosing form tag (which is required at all times, and
* necessary to perform repopulation) cannot be located
*/
protected Object getSingleOverrideValue() throws StripesJspException {
Object unknown = getOverrideValueOrValues();
Object returnValue = null;
if (unknown != null && unknown.getClass().isArray()) {
if (Array.getLength(unknown) > 0) {
returnValue = Array.get(unknown, 0);
}
}
else if (unknown != null && unknown instanceof Collection<?>) {
Collection<?> collection = (Collection<?>) unknown;
if (collection.size() > 0) {
returnValue = collection.iterator().next();
}
}
else {
returnValue = unknown;
}
return returnValue;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:31,代码来源:InputTagSupport.java
示例6: getLocalizedFieldName
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的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
示例7: getValidationMetadata
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的package包/类
protected ValidationMetadata getValidationMetadata() throws StripesJspException {
// find the action bean class we're dealing with
Class<? extends ActionBean> beanClass = getParentFormTag().getActionBeanClass();
if (beanClass != null) {
// ascend the tag stack until a tag name is found
String name = getName();
if (name == null) {
InputTagSupport tag = getParentTag(InputTagSupport.class);
while (name == null && tag != null) {
name = tag.getName();
tag = tag.getParentTag(InputTagSupport.class);
}
}
// check validation for encryption flag
return StripesFilter.getConfiguration().getValidationMetadataProvider()
.getValidationMetadata(beanClass, new ParameterName(name));
}
else {
return null;
}
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:24,代码来源:InputTagSupport.java
示例8: makeFocused
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的package包/类
/** Writes out a JavaScript string to set focus on the field as it is rendered. */
protected void makeFocused() throws JspException {
try {
JspWriter out = getPageContext().getOut();
out.write("<script type=\"text/javascript\">setTimeout(function(){try{var z=document.getElementById('");
out.write(getId());
out.write("');z.focus();");
if ("text".equals(getAttributes().get("type")) || "password".equals(getAttributes().get("type"))) {
out.write("z.select();");
}
out.write("}catch(e){}},1);</script>");
// Clean up tag state involved with focus
this.focus = false;
if (this.syntheticId) getAttributes().remove("id");
this.syntheticId = false;
}
catch (IOException ioe) {
throw new StripesJspException("Could not write javascript focus code to jsp writer.", ioe);
}
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:22,代码来源:InputTagSupport.java
示例9: getPreferredBaseUrl
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的package包/类
/**
* Returns the base URL that should be used for building the link. This is derived from
* the 'beanclass' attribute if it is set, else from the 'url' attribute.
*
* @return the preferred base URL for the link
* @throws StripesJspException if a beanclass attribute was specified, but does not identify
* an existing ActionBean
*/
protected String getPreferredBaseUrl() throws StripesJspException {
// If the beanclass attribute was supplied we'll prefer that to an href
if (this.beanclass != null) {
String beanHref = getActionBeanUrl(beanclass);
if (beanHref == null) {
throw new StripesJspException("The value supplied for the 'beanclass' attribute "
+ "does not represent a valid ActionBean. The value supplied was '" +
this.beanclass + "'. If you're prototyping, or your bean isn't ready yet " +
"and you want this exception to go away, just use 'href' for now instead.");
}
else {
return beanHref;
}
}
else {
return getUrl();
}
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:27,代码来源:LinkTagSupport.java
示例10: doEndTag
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的package包/类
/**
* Prepends the context to the href attribute if necessary, and then folds all the
* registered parameters into the URL.
*
* @return EVAL_PAGE in all cases
* @throws JspException
*/
@Override
public int doEndTag() throws JspException {
try {
set("href", buildUrl());
writeOpenTag(getPageContext().getOut(), "a");
String body = getBodyContentAsString();
if (body == null || body.trim().length() == 0) {
body = get("href");
}
if (body != null) {
getPageContext().getOut().write(body.trim());
}
writeCloseTag(getPageContext().getOut(), "a");
}
catch (IOException ioe) {
throw new StripesJspException("IOException while writing output in LinkTag.", ioe);
}
// Restore state and go on with the page
getAttributes().remove("href");
clearParameters();
return EVAL_PAGE;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:31,代码来源:LinkTag.java
示例11: isFormInError
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的package包/类
/**
* Helper method that will check to see if the form containing this tag is being rendered
* as a result of validation errors. This is not actually used by the default strategy,
* but is here to help subclasses provide different behaviour for when the form is rendering
* normally vs. in error.
*
* @param tag the tag that is being repopulated
* @return boolean true if the form is in error, false otherwise
*/
protected boolean isFormInError(InputTagSupport tag) throws StripesJspException {
boolean inError = false;
ActionBean actionBean = tag.getParentFormTag().getActionBean();
if (actionBean != null) {
ValidationErrors errors = actionBean.getContext().getValidationErrors();
inError = (errors != null && errors.size() > 0);
}
return inError;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:21,代码来源:DefaultPopulationStrategy.java
示例12: getEffectiveMaxlength
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的package包/类
/**
* Gets the maxlength value that is in effect for this tag, as determined by checking
* {@link #getMaxlength()} and then the {@code maxlength} element of the {@link Validate}
* annotation on the associated {@link ActionBean} property.
*
* @throws StripesJspException if thrown by {@link #getValidationMetadata()}
*/
protected String getEffectiveMaxlength() throws StripesJspException {
if (getMaxlength() == null) {
ValidationMetadata validation = getValidationMetadata();
if (validation != null && validation.maxlength() != null)
return validation.maxlength().toString();
else
return null;
}
else {
return getMaxlength();
}
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:20,代码来源:InputTextTag.java
示例13: doEndTag
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的package包/类
@Override
public int doEndTag() throws JspException {
JspWriter writer = getPageContext().getOut();
String body = getBodyContentAsString();
if (body != null) {
try {
String contentType = getPageContext().getResponse().getContentType();
// Catches application/x-javascript, text/javascript, and text/ecmascript
boolean pageIsScript = contentType != null && contentType.toLowerCase().contains("ascript");
// Don't write the script tags if this page is a script
if (!pageIsScript) {
writeOpenTag(writer, "script");
writer.write("//<![CDATA[\r\n");
}
writer.write(body);
if (!pageIsScript) {
writer.write("\r\n//]]>");
writeCloseTag(writer, "script");
}
}
catch (IOException ioe) {
throw new StripesJspException("IOException while writing output in LinkTag.", ioe);
}
}
// Only keep the type attribute between uses
String type = getAttributes().get("type");
getAttributes().clear();
getAttributes().put("type", type);
return SKIP_BODY;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:39,代码来源:FieldMetadataTag.java
示例14: getParentFormTag
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的package包/类
/**
* <p>Locates the enclosing stripes form tag. If no form tag can be found, because the tag
* was not enclosed in one on the JSP, an exception is thrown.</p>
*
* @return FormTag the enclosing form tag on the JSP
* @throws StripesJspException if an enclosing form tag cannot be found
*/
public FormTag getParentFormTag() throws StripesJspException {
FormTag parent = getParentTag(FormTag.class);
// find the first non-partial parent form tag
if (parent != null && parent.isPartial()) {
Stack<StripesTagSupport> stack = getTagStack();
ListIterator<StripesTagSupport> iter = stack.listIterator(stack.size());
while (iter.hasPrevious()) {
StripesTagSupport tag = iter.previous();
if (tag instanceof FormTag && !((FormTag) tag).isPartial()) {
parent = (FormTag) tag;
break;
}
}
}
if (parent == null) {
throw new StripesJspException
("InputTag of type [" + getClass().getName() + "] must be enclosed inside a " +
"stripes form tag. If, for some reason, you do not wish to render a complete " +
"form you may surround stripes input tags with <s:form partial=\"true\" ...> " +
"which will provide support to the input tags but not render the <form> tag.");
}
return parent;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:34,代码来源:InputTagSupport.java
示例15: loadErrors
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的package包/类
/**
* Find errors that are related to the form field this input tag represents and place
* them in an instance variable to use during error rendering.
*/
protected void loadErrors() throws StripesJspException {
ActionBean actionBean = getActionBean();
if (actionBean != null) {
ValidationErrors validationErrors = actionBean.getContext().getValidationErrors();
if (validationErrors != null) {
this.fieldErrors = validationErrors.get(getName());
}
}
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:15,代码来源:InputTagSupport.java
示例16: getFieldErrors
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的package包/类
/**
* Access for the field errors that occurred on the form input this tag represents
* @return List<ValidationError> the list of validation errors for this field
*/
public List<ValidationError> getFieldErrors() throws StripesJspException {
if (!fieldErrorsLoaded) {
loadErrors();
fieldErrorsLoaded = true;
}
return fieldErrors;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:13,代码来源:InputTagSupport.java
示例17: doEndInputTag
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的package包/类
/**
* Performs the main work of the tag as described in the class level javadoc.
* @return EVAL_PAGE in all cases.
* @throws JspException if an IOException is encountered writing to the output stream.
*/
@Override
public int doEndInputTag() throws JspException {
try {
String label = getLocalizedFieldName();
String fieldName = getAttributes().remove("name");
if (label == null) {
label = getBodyContentAsString();
}
if (label == null) {
if (fieldName != null) {
label = LocalizationUtility.makePseudoFriendlyName(fieldName);
}
else {
label = "Label could not find localized field name and had no body nor name attribute.";
}
}
// Write out the tag
writeOpenTag(getPageContext().getOut(), "label");
getPageContext().getOut().write(label);
writeCloseTag(getPageContext().getOut(), "label");
// Reset the field name so as to not screw up tag pooling
if (this.nameSet) {
super.setName(fieldName);
}
return EVAL_PAGE;
}
catch (IOException ioe) {
throw new StripesJspException("Encountered an exception while trying to write to " +
"the output from the stripes:label tag handler class, InputLabelTag.", ioe);
}
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:42,代码来源:InputLabelTag.java
示例18: loadErrors
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的package包/类
/**
* Wraps the parent loadErrors() to suppress exceptions when the label is outside of a
* stripes form tag.
*/
@Override
protected void loadErrors() {
try {
super.loadErrors();
}
catch (StripesJspException sje) {
// Do nothing, we're suppressing this error
}
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:14,代码来源:InputLabelTag.java
示例19: getValue
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的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
示例20: doEndTag
import net.sourceforge.stripes.exception.StripesJspException; //导入依赖的package包/类
/**
* Generates the URL and either writes it into the page or sets it in the appropraite
* JSP scope.
*
* @return {@link #EVAL_PAGE} in all cases.
* @throws JspException if the output stream cannot be written to.
*/
@Override
public int doEndTag() throws JspException {
String url = buildUrl();
// If the user specified a 'var', then set the url as a scoped variable
if (var != null) {
String s = (this.scope) == null ? "page" : this.scope;
if (s.equalsIgnoreCase("request")) {
getPageContext().getRequest().setAttribute(this.var, url);
}
else if (s.equalsIgnoreCase("session")) {
getPageContext().getSession().setAttribute(this.var, url);
}
else if (s.equalsIgnoreCase("application")) {
getPageContext().getServletContext().setAttribute(this.var, url);
}
else {
getPageContext().setAttribute(this.var, url);
}
}
// Else just write it out to the page
else {
try { getPageContext().getOut().write(url); }
catch (IOException ioe) {
throw new StripesJspException("IOException while trying to write url to page.", ioe);
}
}
clearParameters();
return EVAL_PAGE;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:42,代码来源:UrlTag.java
注:本文中的net.sourceforge.stripes.exception.StripesJspException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论