Java Code Examples for org.apache.struts.util.MessageResources#getMessage()

The following examples show how to use org.apache.struts.util.MessageResources#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SalutationForm.java    From openemm with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
    * Validate the properties that have been set from this HTTP request,
    * and return an <code>ActionErrors</code> object that encapsulates any
    * validation errors that have been found.  If no errors are found, return
    * <code>null</code> or an <code>ActionErrors</code> object with no
    * recorded error messages.
    * 
    * @param mapping The mapping used to select this instance
    * @param request The servlet request we are processing
    * @return errors
    */
   @Override
public ActionErrors formSpecificValidate(ActionMapping mapping, HttpServletRequest request) {
       
       ActionErrors errors = new ActionErrors();
       if (action == SalutationAction.ACTION_SAVE || action == SalutationAction.ACTION_NEW) {
           if (StringUtils.isEmpty(shortname) || shortname.length() < 3) {
               errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.name.too.short"));
           }
       }
       if (action == SalutationAction.ACTION_VIEW && salutationID == 0) {
       	Locale aLoc = AgnUtils.getLocale(request);
           MessageResources text=(MessageResources)this.getServlet().getServletContext().getAttribute(org.apache.struts.Globals.MESSAGES_KEY);
         
       	this.shortname=text.getMessage(aLoc, "default.salutation.shortname");
           this.description=text.getMessage(aLoc, "default.salutation.description");
       }
       
       return errors;
   }
 
Example 2
Source File: TargetForm.java    From openemm with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
   * Reset all properties to their default values.
   *
   * @param mapping The mapping used to select this instance
   * @param request The servlet request we are processing
   */
  @Override
  public void reset(ActionMapping mapping, HttpServletRequest request) {
      super.reset(mapping, request);

      this.targetID = 0;
this.action = StrutsActionBase.ACTION_SAVE;
      Locale aLoc = AgnUtils.getLocale(request);
      
      MessageResources text=(MessageResources)this.getServlet().getServletContext().getAttribute(org.apache.struts.Globals.MESSAGES_KEY);
      //MessageResources text=this.getServlet().getResources();
      
      this.shortname = text.getMessage(aLoc, "default.Name");
      this.description = text.getMessage(aLoc, "default.description");
      this.isShowStatistic = false;
      
      // Reset form fields for new rule
      clearNewRuleData();
  }
 
Example 3
Source File: EvaluationManagementBackingBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String publishMarks() {
    final MessageResources messages = MessageResources.getMessageResources(Bundle.APPLICATION);
    final String announcementTitle =
            (getPublishMarksMessage() != null && getPublishMarksMessage().length() > 0) ? messages
                    .getMessage("message.publishment") : null;

    try {
        PublishMarks.runPublishMarks(this.getExecutionCourseID(), this.getEvaluationID(), this.getPublishMarksMessage(),
                this.getSendSMS(), announcementTitle);
    } catch (Exception e) {
        this.setErrorMessage(e.getMessage());
        return "";
    }

    return this.getEvaluation().getClass().getSimpleName();
}
 
Example 4
Source File: ForunsManagement.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
private LocalizedString getQuotationText(HttpServletRequest request) {

        String quotedMessageId = this.getQuotedMessageId(request);
        String quotationText = null;
        if (quotedMessageId != null) {
            MessageResources resources = this.getResources(request, "MESSAGING_RESOURCES");
            ConversationMessage message = (ConversationMessage) FenixFramework.getDomainObject(quotedMessageId);

            String author = message.getCreator().getName() + " (" + message.getCreator().getUsername() + ")";

            quotationText =
                    resources.getMessage(this.getLocale(request), "messaging.viewThread.quotationText", author, message.getBody()
                            .getContent());

        }
        return new LocalizedString(I18N.getLocale(), quotationText);
    }
 
Example 5
Source File: BackTracker.java    From unitime with Apache License 2.0 5 votes vote down vote up
public static String getBackButton(HttpServletRequest request, int nrBackSteps, String name, String title, String accessKey, String style, String clazz, String backType, String backId) {
	MessageResources rsc = getResources(request);
	if (rsc!=null && rsc.getMessage(name)!=null) {
		name = rsc.getMessage(name);
	}
	synchronized (request.getSession()) {
		Vector backList = getBackList(request.getSession());
		if (backList.size()<nrBackSteps) return "";
		String[] backItem = (String[])backList.elementAt(backList.size()-nrBackSteps);
		if (backItem[1]!=null)
			title = title.replaceAll("%%", backItem[1]);
		String backUrl = backItem[0];
		if (backId!=null && backType!=null) {
			if (backUrl.indexOf('?')>0)
				backUrl += "&backType="+backType+"&backId="+backId+"#back";
			else
				backUrl += "?backType="+backType+"&backId="+backId+"#back";
		}
		return "<input type='button'"+
			" value='"+name+"' "+
			(accessKey==null?"":" accesskey=\""+accessKey+"\"")+
			(style==null?"":" style=\""+style+"\"")+
			(clazz==null?"":" class=\""+clazz+"\"")+
			" title=\""+title+"\""+
			" onClick=\"document.location='back.do?uri="+encodeURL(backUrl)+"'"+
			
			";\""+
			"/>";
	}
}
 
Example 6
Source File: PaymentPhase.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String getDescriptionFromMessageResourses() {
    MessageResources messages = MessageResources.getMessageResources(Bundle.APPLICATION);

    String newDescription = null;
    newDescription = messages.getMessage(super.getDescription());
    if (newDescription == null) {
        newDescription = super.getDescription();
    }
    return newDescription;
}
 
Example 7
Source File: ChameleonAction.java    From unitime with Apache License 2.0 4 votes vote down vote up
/** 
   * 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");
  }