Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
themeEclipse
languagejava
titleCRMUILicenseBean.javaInfoMessage Exception
collapsetrue
package com.crm.process;
import com.crm.businessobject.CRMSession;
import com.crm.framework.metadata.Message;
import com.crm.framework.metadata.MetadataUtil;
import com.crm.framework.util.StringUtil;

public class InfoMessage {
    
    private String message;
    
    public InfoMessage(CRMSession crmSession, String code, String[] msgParams, String context, String mpID) throws Exception {
        
        super();
        
        Message infoMsg = MetadataUtil.getMessage(context, mpID, code);
        
        if (infoMsg!=null)
        {
            this.message = crmSession.getTranslation(infoMsg.getExpression());
        }
        
        if (msgParams!=null && msgParams.length>0)
        {
            for (int i=0;i<msgParams.length;i++)
            {
                String msgParameter = "%" + (i+1);
                if(msgParams[i].startsWith("key_"))
                    this.message = StringUtil.replace(this.message, msgParameter, crmSession.getTranslation(msgParams[i]));
                else
                    this.message = StringUtil.replace(this.message, msgParameter, msgParams[i]);
            }
        }
    }
    public String getMessage() {
        return message;
    }
    
}

...