本文整理匯總了Java中org.apache.struts.action.ActionMessages.get方法的典型用法代碼示例。如果您正苦於以下問題:Java ActionMessages.get方法的具體用法?Java ActionMessages.get怎麽用?Java ActionMessages.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.struts.action.ActionMessages
的用法示例。
在下文中一共展示了ActionMessages.get方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: condition
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/**
* Evaluate the condition that is being tested by this particular tag,
* and return <code>true</code> if there is at least one message in the
* class or for the property specified.
* This method must be implemented by concrete subclasses.
*
* @param desired Desired outcome for a true result
*
* @exception JspException if a JSP exception occurs
*/
protected boolean condition(boolean desired) throws JspException {
ActionMessages am = null;
String key = name;
if (message != null && "true".equalsIgnoreCase(message)){
key = Globals.MESSAGE_KEY;
}
try {
am = TagUtils.getInstance().getActionMessages(pageContext, key);
} catch (JspException e) {
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
Iterator iterator = (property == null) ? am.get() : am.get(property);
return (iterator.hasNext() == desired);
}
示例2: doStartTag
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
public int doStartTag() throws JspException {
ActionMessages errors = null;
try {
errors = TagUtils.getInstance().getActionMessages(pageContext, Globals.ERROR_KEY);
} catch (JspException e) {
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
String hint = null;
if (errors != null && !errors.isEmpty()) {
String message = null;
Iterator reports = (getProperty() == null ? errors.get() : errors.get(getProperty()));
while (reports.hasNext()) {
ActionMessage report = (ActionMessage) reports.next();
if (report.isResource()) {
message = TagUtils.getInstance().message(pageContext, null, Globals.LOCALE_KEY, report.getKey(), report.getValues());
} else {
message = report.getKey();
}
if (message != null && !message.isEmpty()) {
hint = (hint == null ? "" : hint + "<br>") + message;
}
}
}
// setStyleClass("unitime-DateSelectionBox");
String onchange = getOnchange(); setOnchange(null);
TagUtils.getInstance().write(pageContext, "<span name='UniTimeGWT:CourseNumberSuggestBox' configuration=\"" + getConfiguration() + "\"" +
(hint == null ? "" : " error=\"" + hint + "\"") +
(onchange == null ? "" : " onchange=\"" + onchange + "\"") +
(getOuterStyle() == null ? "" : " style=\"" + getOuterStyle() + "\"" ) +
">");
super.doStartTag();
TagUtils.getInstance().write(pageContext, "</span>");
return EVAL_BODY_BUFFERED;
}
示例3: doStartTag
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
public int doStartTag() throws JspException {
ActionMessages errors = null;
try {
errors = TagUtils.getInstance().getActionMessages(pageContext, Globals.ERROR_KEY);
} catch (JspException e) {
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
String hint = null;
if (errors != null && !errors.isEmpty()) {
String message = null;
Iterator reports = (getProperty() == null ? errors.get() : errors.get(getProperty()));
while (reports.hasNext()) {
ActionMessage report = (ActionMessage) reports.next();
if (report.isResource()) {
message = TagUtils.getInstance().message(pageContext, null, Globals.LOCALE_KEY, report.getKey(), report.getValues());
} else {
message = report.getKey();
}
if (message != null && !message.isEmpty()) {
hint = (hint == null ? "" : hint + "<br>") + message;
}
}
}
setStyleClass("unitime-DateSelectionBox");
String onchange = getOnchange(); setOnchange(null);
TagUtils.getInstance().write(pageContext, "<span name='UniTimeGWT:Calendar' format=\"" + getFormat() + "\"" +
(hint == null ? "" : " error=\"" + hint + "\"") +
(onchange == null ? "" : " onchange=\"" + onchange + "\"") +
(getOuterStyle() == null ? "" : " style=\"" + getOuterStyle() + "\"" ) +
">");
super.doStartTag();
TagUtils.getInstance().write(pageContext, "</span>");
return EVAL_BODY_BUFFERED;
}
示例4: doStartTag
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/**
* Construct an iterator for the specified collection, and begin
* looping through the body once per element.
*
* @exception JspException if a JSP exception has occurred
*/
public int doStartTag() throws JspException {
// Initialize for a new request.
processed = false;
// Were any messages specified?
ActionMessages messages = null;
// Make a local copy of the name attribute that we can modify.
String name = this.name;
if (message != null && "true".equalsIgnoreCase(message)) {
name = Globals.MESSAGE_KEY;
}
try {
messages = TagUtils.getInstance().getActionMessages(pageContext, name);
} catch (JspException e) {
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
// Acquire the collection we are going to iterate over
this.iterator = (property == null) ? messages.get() : messages.get(property);
// Store the first value and evaluate, or skip the body if none
if (!this.iterator.hasNext()) {
return SKIP_BODY;
}
ActionMessage report = (ActionMessage) this.iterator.next();
String msg = null;
if (report.isResource()) {
msg = TagUtils.getInstance().message(
pageContext,
bundle,
locale,
report.getKey(),
report.getValues());
} else {
msg = report.getKey();
}
if (msg == null) {
pageContext.removeAttribute(id);
} else {
pageContext.setAttribute(id, msg);
}
if (header != null && header.length() > 0) {
String headerMessage =
TagUtils.getInstance().message(pageContext, bundle, locale, header);
if (headerMessage != null) {
TagUtils.getInstance().write(pageContext, headerMessage);
}
}
// Set the processed variable to true so the
// doEndTag() knows processing took place
processed = true;
return (EVAL_BODY_TAG);
}