Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
SimpleMedia Module for Magnolia CMS (http://www.openmindlab.com/lab/products/media.html) Copyright(C) 2008-2013, Openmind S.r.l. http://www.openmindonline.it This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
 
 
 package net.sourceforge.openutils.mgnlmedia.media.pages;
 
 import  freemarker.ext.beans.BeansWrapper;
 import  freemarker.template.TemplateHashModel;
 import  freemarker.template.TemplateMethodModel;
 import  freemarker.template.TemplateModelException;
 import  info.magnolia.cms.i18n.Messages;
 import  info.magnolia.cms.i18n.MessagesUtil;
 import  info.magnolia.module.admininterface.TemplatedMVCHandler;
 import  info.magnolia.objectfactory.Components;
 
 import java.util.List;
 import java.util.Map;
 
 
 
 import  org.apache.commons.beanutils.BeanUtils;
Make getMsgs method public

Author(s):
molaschi
Version:
$Id: MessagesTemplatedMVCHandler.java 4388 2013-10-19 20:58:07Z fgiust $
 
 public class MessagesTemplatedMVCHandler extends TemplatedMVCHandler
 {

    
Logger.
 
     protected Logger log = LoggerFactory.getLogger(getClass());
 
     protected TemplateMethodModel getStatic = new GetStaticMethodModel();

    

Parameters:
name
request
response
 
     public MessagesTemplatedMVCHandler(String nameHttpServletRequest requestHttpServletResponse response)
     {
         super(namerequestresponse);
     }
 
     private Messages mediaTypesExtendedMsgs;

    
 
     @Override
     public Messages getMsgs()
     {
 
         if ( == null)
         {
             Map<StringMediaTypeConfigurationtypes = Components
                 .getComponent(MediaConfigurationManager.class)
                 .getTypes();
             List<Stringbasenames = new ArrayList<String>();
             basenames.add(getI18nBasename());
             for (MediaTypeConfiguration typeConfig : types.values())
             {
                 String basename = typeConfig.getI18nBasename();
                 if (!StringUtils.isEmpty(basename) && !basenames.contains(basename))
                 {
                     basenames.add(basename);
                 }
             }
              = MessagesUtil.chain(basenames.toArray(new String[0]));
             super.setMsgs();
         }
        return super.getMsgs();
    }

    
Override the standard method in order to use request.getParameterMap instead of requestFormUtils.getParamenterMap() since the latter doesn't work with virtual URI
    @SuppressWarnings({"unchecked""deprecation" })
    @Override
    protected void populateFromRequest(Object bean)
    {
        Map<StringObjectparameters = new HashMap<StringObject>();
        // FIX: use request.getParameterMap instead of requestFormUtils.getParamenterMap()
        parameters.putAll(request.getParameterMap());
        // handle uploaded files too
        parameters.putAll(new info.magnolia.cms.util.RequestFormUtil(this.getRequest()).getDocuments());
        try
        {
            BeanUtils.populate(beanparameters);
        }
        catch (Exception e)
        {
            .error("can't set properties on the handler"e);
        }
    }

    
Returns the getStatic.

Returns:
the getStatic
    public TemplateMethodModel getGetStatic()
    {
        return ;
    }
    public static class GetStaticMethodModel implements TemplateMethodModel
    {

        
        @SuppressWarnings({"cast" })
        public Object exec(List argumentsthrows TemplateModelException
        {
            if (arguments != null && arguments.size() > 0)
            {
                BeansWrapper wrapper = BeansWrapper.getDefaultInstance();
                TemplateHashModel staticModel = wrapper.getStaticModels();
                return (TemplateHashModel) staticModel.get((Stringarguments.get(0));
            }
            return null;
        }
    }
New to GrepCode? Check out our FAQ X