[opencms-dev] CmsSelectWidget: setConfiguration called twice?

Marc.Schlegel my.mailing.lists at gmx.de
Wed Jul 15 19:11:08 CEST 2009


Hello Everyone

I am including the CmsCustomSelectSourceWidget form the OpenCms 7 book
(packtpub) but when I am trying to use it the the list is empty and the
log tells me that there is NullPointerException.

14 Jul 2009 00:04:20,016 ERROR [ts.CmsCustomSourceSelectWidget:  45]
mine a.widgets.sources.ContentListDS
14 Jul 2009 00:04:20,029 ERROR [ts.CmsCustomSourceSelectWidget:  45]
mine null
14 Jul 2009 00:04:20,030 ERROR [ts.CmsCustomSourceSelectWidget:  50]
Error instantiating DataSource object of class "null" - "{1}"
java.lang.NullPointerException

The code is just copied from the book, except the logging after the try-line

    @Override
    public void setConfiguration(String configuration){
        super.setConfiguration(configuration);
        if(iDataSource == null){
            config = new CustomSourceConfiguration(configuration);
            String strClassName = config.getConfigValue("source");
            // read the class name for the data source and instantiate it
            Class<I_WidgetSelectSource> sourceClazz;
            try{
                LOG.error("mine " + strClassName);
                sourceClazz = (Class<I_WidgetSelectSource>)
Class.forName(strClassName);
                iDataSource = sourceClazz.newInstance();
            }catch(Exception e){
                // Log the error
               
LOG.error(Messages.getInstance().getBundle().key(Messages.LOG_DATASOURCE_INIT_ERROR_2,
strClassName), e);
                // since it failed, use the default source provider
                iDataSource = new DefaultDS();
            }
            // set the configuration
            iDataSource.setConfiguration(config);
        }
    }

So, somehow, this method is called twice, and I have no clue why.
Can anybody be of any assistance?


Maybe the layout-section where I actualy use that widget is helpfull
<layout element="Category" widget="CustomSourceSelectWidget"
                    configuration="source='a.widgets.sources.ContentListDS'|
                   
contenttype='ValueList'|location='/_news/newscategories'|
                    fieldname='Value'"  <!-- tried Category here as well -->
/>

Thanks



More information about the opencms-dev mailing list