/*
 * Copyright 2007 The Kuali Foundation
 * 
 * Licensed under the Educational Community License, Version 1.0 (the
 * "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.opensource.org/licenses/ecl1.php
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.kuali.rice.kns.uif.util;

import org.apache.commons.lang.StringUtils;
import org.kuali.rice.kns.uif.core.Component;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * Sets the unique Id for a <code>Component</code> if not set
 * 
 * @author Kuali Rice Team (rice.collab@kuali.org)
 */
public class ComponentIdBeanPostProcessor implements BeanPostProcessor {

    public ComponentIdBeanPostProcessor() {}

    /**
     * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object,
     *      java.lang.String)
     */
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    /**
     * Sets the unique Id for a <code>Component</code> if not set
     * 
     * <p>
     * Will use the bean name (if not the spring generated) or generate a
     * numeric identifier
     * </p>
     * 
     * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object,
     *      java.lang.String)
     * @see org.kuali.rice.kns.uif.core.Component#getDecorators
     */
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof Component) {
            Component component = (Component) bean;

            if (StringUtils.isBlank(component.getId())) {
                if (StringUtils.contains(beanName, "#")) {
                    beanName = StringUtils.substringAfterLast(beanName, "#");
                }

                // adding two underscores to name so we can pick off the original dictionary id
                component.setId(beanName + "__");
            }
        }

        return bean;
    }

}

@@ -2329,32 +2329,224 @@
            %7D%0D%0A%0D%0A
+                if (StringUtils.contains(beanName, %22__%22)) %7B%0D%0A                    throw new RuntimeException((%22Bean id is not allowed to have two underscores together%22));%0D%0A                %7D%0D%0A%0D%0A
                 

Adding check bean id does not contain two underscores together