本文整理匯總了Java中org.apache.struts.action.ActionMessages.add方法的典型用法代碼示例。如果您正苦於以下問題:Java ActionMessages.add方法的具體用法?Java ActionMessages.add怎麽用?Java ActionMessages.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.struts.action.ActionMessages
的用法示例。
在下文中一共展示了ActionMessages.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addAttributePref
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
protected void addAttributePref(
HttpServletRequest request,
PreferencesForm frm,
ActionMessages errors ) {
List lst = frm.getAttributePrefs();
if(frm.checkPrefs(lst)) {
for (int i=0; i<Constants.PREF_ROWS_ADDED; i++) {
frm.addToAttributePrefs(
Preference.BLANK_PREF_VALUE,
Preference.BLANK_PREF_VALUE );
}
request.setAttribute(HASH_ATTR, HASH_ATTRIBUTE_PREF);
}
else {
errors.add("attributePrefs",
new ActionMessage(
"errors.generic",
MSG.errorInvalidAttributePreference()) );
saveErrors(request, errors);
}
}
示例2: addRoomGroup
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
private void addRoomGroup(HttpServletRequest request, PreferencesForm frm, ActionMessages errors) {
List lst = frm.getRoomGroups();
if(frm.checkPrefs(lst)) {
for (int i=0; i<Constants.PREF_ROWS_ADDED; i++) {
frm.addToRoomGroups(
Preference.BLANK_PREF_VALUE,
Preference.BLANK_PREF_VALUE );
}
request.setAttribute(HASH_ATTR, HASH_RM_GROUP);
}
else {
errors.add("roomGroup",
new ActionMessage(
"errors.generic",
MSG.errorInvalidRoomGroup()));
saveErrors(request, errors);
}
}
示例3: addRoomPref
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/**
* Add a room preference to the list (UI)
* @param request
* @param frm
* @param errors
*/
protected void addRoomPref(
HttpServletRequest request,
PreferencesForm frm,
ActionMessages errors ) {
List lst = frm.getRoomPrefs();
if(frm.checkPrefs(lst)) {
for (int i=0; i<Constants.PREF_ROWS_ADDED; i++) {
frm.addToRoomPrefs(
Preference.BLANK_PREF_VALUE,
Preference.BLANK_PREF_VALUE );
}
request.setAttribute(HASH_ATTR, HASH_RM_PREF);
}
else {
errors.add("roomPrefs",
new ActionMessage(
"errors.generic",
MSG.errorInvalidRoomPreference()) );
saveErrors(request, errors);
}
}
示例4: rollRoomGroupsForward
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
private void rollRoomGroupsForward(ActionMessages errors, Session fromSession, Session toSession) {
RoomGroup fromRoomGroup = null;
RoomGroup toRoomGroup = null;
RoomGroupDAO rgDao = new RoomGroupDAO();
Collection fromRoomGroups = RoomGroup.getAllRoomGroupsForSession(fromSession);
try {
if (fromRoomGroups != null && !fromRoomGroups.isEmpty()){
for (Iterator it = fromRoomGroups.iterator(); it.hasNext();){
fromRoomGroup = (RoomGroup) it.next();
if (fromRoomGroup != null){
toRoomGroup = (RoomGroup) fromRoomGroup.clone();
toRoomGroup.setSession(toSession);
if (fromRoomGroup.getDepartment() != null)
toRoomGroup.setDepartment(fromRoomGroup.getDepartment().findSameDepartmentInSession(toSession));
rgDao.saveOrUpdate(toRoomGroup);
}
}
}
} catch (Exception e) {
iLog.error("Failed to roll all room groups forward.", e);
errors.add("rollForward", new ActionMessage("errors.rollForward", "Room Groups", fromSession.getLabel(), toSession.getLabel(), "Failed to roll all room groups forward."));
}
}
示例5: validateLong
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/**
* Checks if the field can safely be converted to a long primitive.
*
* @param bean The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently being performed.
* @param field The <code>Field</code> object associated with the current
* field being validated.
* @param errors The <code>ActionMessages</code> object to add errors to if any
* validation errors occur.
* @param validator The <code>Validator</code> instance, used to access
* other field values.
* @param request Current request object.
* @return true if valid, false otherwise.
*/
public static Object validateLong(Object bean,
ValidatorAction va, Field field,
ActionMessages errors,
Validator validator,
HttpServletRequest request) {
Object result = null;
String value = null;
if (isString(bean)) {
value = (String) bean;
} else {
value = ValidatorUtils.getValueAsString(bean, field.getProperty());
}
if (GenericValidator.isBlankOrNull(value)) {
return Boolean.TRUE;
}
result = GenericTypeValidator.formatLong(value);
if (result == null) {
errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));
}
return result == null ? Boolean.FALSE : result;
}
示例6: validateDouble
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/**
* Checks if the field can safely be converted to a double primitive.
*
* @param bean The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently being performed.
* @param field The <code>Field</code> object associated with the current
* field being validated.
* @param errors The <code>ActionMessages</code> object to add errors to if any
* validation errors occur.
* @param validator The <code>Validator</code> instance, used to access
* other field values.
* @param request Current request object.
* @return true if valid, false otherwise.
*/
public static Object validateDouble(Object bean,
ValidatorAction va, Field field,
ActionMessages errors,
Validator validator,
HttpServletRequest request) {
Object result = null;
String value = null;
if (isString(bean)) {
value = (String) bean;
} else {
value = ValidatorUtils.getValueAsString(bean, field.getProperty());
}
if (GenericValidator.isBlankOrNull(value)) {
return Boolean.TRUE;
}
result = GenericTypeValidator.formatDouble(value);
if (result == null) {
errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));
}
return result == null ? Boolean.FALSE : result;
}
示例7: execute
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
sessionContext.checkPermission(Right.Instructors);
InstructorSearchForm instructorSearchForm = (InstructorSearchForm) form;
Set<Department> departments = setupManagerDepartments(request);
// Dept code is saved to the session - go to instructor list
String deptId = (String)sessionContext.getAttribute(SessionAttribute.DepartmentId);
if ((deptId == null || deptId.isEmpty()) && departments.size() == 1)
deptId = departments.iterator().next().getUniqueId().toString();
if (deptId == null || deptId.isEmpty() || !sessionContext.hasPermission(deptId, "Department", Right.Instructors)) {
return mapping.findForward("showInstructorSearch");
} else {
instructorSearchForm.setDeptUniqueId(deptId);
List instructors = DepartmentalInstructor.findInstructorsForDepartment(Long.valueOf(deptId));
if (instructors == null || instructors.isEmpty()) {
ActionMessages errors = new ActionMessages();
errors.add("searchResult", new ActionMessage("errors.generic", MSG.errorNoInstructorsFoundForDepartment()));
saveErrors(request, errors);
}
return mapping.findForward("instructorList");
}
}
示例8: validateUploadForm
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
private boolean validateUploadForm(LearnerForm learnerForm, HttpServletRequest request) {
ActionMessages errors = new ActionMessages();
Locale preferredLocale = (Locale) request.getSession().getAttribute(LocaleFilter.PREFERRED_LOCALE_KEY);
if (learnerForm.getFile() == null || StringUtils.isBlank(learnerForm.getFile().getFileName())) {
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.required",
this.getResources(request).getMessage(preferredLocale, "learner.form.filepath.displayname")));
}
if (StringUtils.isBlank(learnerForm.getDescription())) {
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.required",
this.getResources(request).getMessage(preferredLocale, "label.learner.fileDescription")));
} else if (learnerForm.getDescription().length() > LearnerForm.DESCRIPTION_LENGTH) {
errors.add(ActionMessages.GLOBAL_MESSAGE,
new ActionMessage("errors.maxdescsize", LearnerForm.DESCRIPTION_LENGTH));
}
FileValidatorUtil.validateFileSize(learnerForm.getFile(), false, errors);
if (learnerForm.getFile() != null) {
LearnerAction.logger.debug("Learner submit file : " + learnerForm.getFile().getFileName());
}
if (learnerForm.getFile() != null && FileUtil.isExecutableFile(learnerForm.getFile().getFileName())) {
LearnerAction.logger.debug("File is executatable : " + learnerForm.getFile().getFileName());
ActionMessage msg = new ActionMessage("error.attachment.executable");
errors.add(ActionMessages.GLOBAL_MESSAGE, msg);
}
if (!errors.isEmpty()) {
this.addErrors(request, errors);
return true;
}
return false;
}
示例9: validateMinLength
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/**
* Checks if the field's length is greater than or equal to the minimum value.
* A <code>Null</code> will be considered an error.
*
* @param bean The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently being performed.
* @param field The <code>Field</code> object associated with the current
* field being validated.
* @param errors The <code>ActionMessages</code> object to add errors to if any
* validation errors occur.
* @param validator The <code>Validator</code> instance, used to access
* other field values.
* @param request Current request object.
* @return True if stated conditions met.
*/
public static boolean validateMinLength(Object bean,
ValidatorAction va, Field field,
ActionMessages errors,
Validator validator,
HttpServletRequest request) {
String value = null;
if (isString(bean)) {
value = (String) bean;
} else {
value = ValidatorUtils.getValueAsString(bean, field.getProperty());
}
if (!GenericValidator.isBlankOrNull(value)) {
try {
int min = Integer.parseInt(field.getVarValue("minlength"));
if (!GenericValidator.minLength(value, min)) {
errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));
return false;
}
} catch (Exception e) {
errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));
return false;
}
}
return true;
}
示例10: exportNode
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/**
* Exports the selected node to a ZIP file. Method is based on a similar one for exporting learning designs.
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws ServletException
* @throws IOException
*/
public ActionForward exportNode(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
Long nodeUid = WebUtil.readLongParam(request, CentralConstants.PARAM_UID);
ActionMessages errors = new ActionMessages();
PedagogicalPlannerAction.log.debug("Exporting sequence node with UID" + nodeUid);
String zipFilePath = null;
// Different browsers handle stream downloads differently LDEV-1243
String filename = null;
try {
zipFilePath = exportNode(nodeUid);
// get only filename
String zipfile = FileUtil.getFileName(zipFilePath);
// replace spaces (" ") with underscores ("_")
zipfile = zipfile.replaceAll(" ", "_");
// write zip file as response stream.
filename = FileUtil.encodeFilenameForDownload(request, zipfile);
PedagogicalPlannerAction.log.debug("Final filename to export: " + filename);
response.setContentType(CentralConstants.RESPONSE_CONTENT_TYPE_DOWNLOAD);
// response.setContentType("application/zip");
response.setHeader(CentralConstants.HEADER_CONTENT_DISPOSITION, "attachment;filename=" + filename);
} catch (Exception e) {
PedagogicalPlannerAction.log.error(e, e);
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(PedagogicalPlannerAction.ERROR_KEY_EXPORT));
saveErrors(request, errors);
return openSequenceNode(mapping, form, request, nodeUid);
}
FileUtils.copyFile(new File(zipFilePath), response.getOutputStream());
return null;
}
示例11: validateMask
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/**
* Checks if the field matches the regular expression in the field's mask attribute.
*
* @param bean The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently being
* performed.
* @param field The <code>Field</code> object associated with the current
* field being validated.
* @param errors The <code>ActionMessages</code> object to add errors to if
* any validation errors occur.
* @param validator The <code>Validator</code> instance, used to access
* other field values.
* @param request Current request object.
* @return true if field matches mask, false otherwise.
*/
public static boolean validateMask(Object bean,
ValidatorAction va, Field field,
ActionMessages errors,
Validator validator,
HttpServletRequest request) {
String mask = field.getVarValue("mask");
String value = null;
if (isString(bean)) {
value = (String) bean;
} else {
value = ValidatorUtils.getValueAsString(bean, field.getProperty());
}
try {
if (!GenericValidator.isBlankOrNull(value)
&& !GenericValidator.matchRegexp(value, mask)) {
errors.add(
field.getKey(),
Resources.getActionMessage(validator, request, va, field));
return false;
} else {
return true;
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return true;
}
示例12: rollMidtermExamsForward
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
public void rollMidtermExamsForward(ActionMessages errors, RollForwardSessionForm rollForwardSessionForm){
Session toSession = Session.getSessionById(rollForwardSessionForm.getSessionToRollForwardTo());
try {
List exams = findExamToRollForward(toSession, ExamType.sExamTypeMidterm);
for(Iterator examIt = exams.iterator(); examIt.hasNext();){
rollForwardExam((Exam) examIt.next(), toSession, rollForwardSessionForm.getMidtermExamsPrefsAction());
}
} catch (Exception e) {
iLog.error("Failed to roll all midterm exams forward.", e);
errors.add("rollForward", new ActionMessage("errors.rollForward", "Midterm Exam", "previous session", toSession.getLabel(), "Failed to roll all midterm exams forward."));
}
}
示例13: validateCreditCard
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/**
* Checks if the field is a valid credit card number.
*
* @param bean The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently being performed.
* @param field The <code>Field</code> object associated with the current
* field being validated.
* @param errors The <code>ActionMessages</code> object to add errors to if any
* validation errors occur.
* @param validator The <code>Validator</code> instance, used to access
* other field values.
* @param request Current request object.
* @return true if valid, false otherwise.
*/
public static Object validateCreditCard(Object bean,
ValidatorAction va, Field field,
ActionMessages errors,
Validator validator,
HttpServletRequest request) {
Object result = null;
String value = null;
if (isString(bean)) {
value = (String) bean;
} else {
value = ValidatorUtils.getValueAsString(bean, field.getProperty());
}
if (GenericValidator.isBlankOrNull(value)) {
return Boolean.TRUE;
}
result = GenericTypeValidator.formatCreditCard(value);
if (result == null) {
errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));
}
return result == null ? Boolean.FALSE : result;
}
示例14: execute
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
UserContext user = sessionContext.getUser();
if (user != null && user instanceof UserContext.Chameleon)
user = ((UserContext.Chameleon)user).getOriginalUserContext();
else
sessionContext.checkPermission(Right.Chameleon);
MessageResources rsc = getResources(request);
ChameleonForm frm = (ChameleonForm) form;
frm.setCanLookup(sessionContext.hasPermission(Right.HasRole));
ActionMessages errors = new ActionMessages();
String op = (request.getParameter("op")==null)
? (frm.getOp()==null || frm.getOp().length()==0)
? (request.getAttribute("op")==null)
? null
: request.getAttribute("op").toString()
: frm.getOp()
: request.getParameter("op");
if(op==null || op.trim().length()==0)
op = rsc.getMessage("op.view");
frm.setOp(op);
// Lookup
String uid = request.getParameter("uid");
if (uid != null && !uid.isEmpty() && ApplicationProperty.ChameleonAllowLookup.isTrue()) {
frm.setPuid(uid);
frm.setName(request.getParameter("uname"));
op = rsc.getMessage("button.changeUser");
}
// First Access - display blank form
if ( op.equals(rsc.getMessage("op.view")) ) {
LookupTables.setupTimetableManagers(request);
if (user != null)
frm.setPuid(user.getExternalUserId());
}
// Change User
if ( op.equals(rsc.getMessage("button.changeUser")) ) {
try {
doSwitch(request, frm, user);
return mapping.findForward("reload");
}
catch(Exception e) {
Debug.error(e);
errors.add("exception",
new ActionMessage("errors.generic", e.getMessage()) );
saveErrors(request, errors);
LookupTables.setupTimetableManagers(request);
return mapping.findForward("displayForm");
}
}
return mapping.findForward("displayForm");
}
示例15: rollDatePatternsForward
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
public void rollDatePatternsForward(ActionMessages errors, RollForwardSessionForm rollForwardSessionForm) {
Session toSession = Session.getSessionById(rollForwardSessionForm.getSessionToRollForwardTo());
Session fromSession = Session.getSessionById(rollForwardSessionForm.getSessionToRollDatePatternsForwardFrom());
List<DatePattern> fromDatePatterns = DatePattern.findAll(fromSession, true, null, null);
DatePattern fromDatePattern = null;
DatePattern toDatePattern = null;
DatePatternDAO dpDao = new DatePatternDAO();
HashMap<DatePattern, DatePattern> fromToDatePatternMap = new HashMap<DatePattern, DatePattern>();
try {
for(Iterator it = fromDatePatterns.iterator(); it.hasNext();){
fromDatePattern = (DatePattern) it.next();
if (fromDatePattern != null){
toDatePattern = (DatePattern) fromDatePattern.clone();
toDatePattern.setSession(toSession);
rollDatePatternOntoDepartments(fromDatePattern, toDatePattern);
dpDao.saveOrUpdate(toDatePattern);
dpDao.getSession().flush();
fromToDatePatternMap.put(fromDatePattern, toDatePattern);
}
}
for (DatePattern fromDp: fromToDatePatternMap.keySet()){
DatePattern toDp = fromToDatePatternMap.get(fromDp);
if (fromDp.getParents() != null && !fromDp.getParents().isEmpty()){
for (DatePattern fromParent: fromDp.getParents()){
toDp.addToparents(fromToDatePatternMap.get(fromParent));
}
dpDao.saveOrUpdate(toDp);
}
}
if (fromSession.getDefaultDatePattern() != null){
DatePattern defDp = DatePattern.findByName(toSession, fromSession.getDefaultDatePattern().getName());
if (defDp != null){
toSession.setDefaultDatePattern(defDp);
SessionDAO sDao = new SessionDAO();
sDao.saveOrUpdate(toSession);
}
}
dpDao.getSession().flush();
dpDao.getSession().clear();
} catch (Exception e) {
iLog.error("Failed to roll all date patterns forward.", e);
errors.add("rollForward", new ActionMessage("errors.rollForward", "Date Patterns", fromSession.getLabel(), toSession.getLabel(), "Failed to roll all date patterns forward."));
}
}