When using AutogeneratedParagraph main are is not optional but extras area is.
------------------------------------------------------------------------------

                 Key: MGNLSTK-586
                 URL: http://jira.magnolia-cms.com/browse/MGNLSTK-586
             Project: Magnolia Standard Templating Kit
          Issue Type: Improvement
    Affects Versions: 1.3 M1
            Reporter: Teresa Miyar
            Assignee: Philipp Bärfuss
            Priority: Minor
             Fix For: 1.3


Patch

{code}
Index: 
magnolia-module-standard-templating-kit/src/main/java/info/magnolia/module/templatingkit/templates/SingletonParagraphTemplateModel.java
===================================================================
--- 
magnolia-module-standard-templating-kit/src/main/java/info/magnolia/module/templatingkit/templates/SingletonParagraphTemplateModel.java
     (revision 31608)
+++ 
magnolia-module-standard-templating-kit/src/main/java/info/magnolia/module/templatingkit/templates/SingletonParagraphTemplateModel.java
     (working copy)
@@ -118,20 +118,22 @@
     }
 
     private void createMainArea(STKTemplate templateDef) {
-        SingletonParagraphMainArea singletonDef = 
(SingletonParagraphMainArea)templateDef.getMainArea();
-        try {
-            Content mainCollection = ContentUtil.getOrCreateContent(content, 
"main", ItemType.CONTENTNODE, true);
-            if (!mainCollection.hasContent(SINGLETON_NODE_NAME)) {
-                Content singletonNode = 
mainCollection.createContent(SINGLETON_NODE_NAME, ItemType.CONTENTNODE);
-                
singletonNode.getMetaData().setTemplate(singletonDef.getAutoGeneratedParagraph().getName());
+        if( templateDef.getMainArea() != null && templateDef.getMainArea() 
instanceof SingletonParagraphMainArea) {
+          SingletonParagraphMainArea singletonDef = 
(SingletonParagraphMainArea)templateDef.getMainArea();
+          try {
+              Content mainCollection = ContentUtil.getOrCreateContent(content, 
"main", ItemType.CONTENTNODE, true);
+              if (!mainCollection.hasContent(SINGLETON_NODE_NAME)) {
+                  Content singletonNode = 
mainCollection.createContent(SINGLETON_NODE_NAME, ItemType.CONTENTNODE);
+                  
singletonNode.getMetaData().setTemplate(singletonDef.getAutoGeneratedParagraph().getName());
 
-                setDefaultValues(singletonNode, 
singletonDef.getAutoGeneratedParagraph().getDefaultValues());
+                  setDefaultValues(singletonNode, 
singletonDef.getAutoGeneratedParagraph().getDefaultValues());
 
-                mainCollection.save();
-            }
-        } catch (Exception e) {
-            throw new IllegalStateException("Can't create singleton 
paragraph", e);
-        }
+                  mainCollection.save();
+              }
+          } catch (Exception e) {
+              throw new IllegalStateException("Can't create singleton 
paragraph", e);
+          }
+        }//end if generate main area
     }
 
     protected void setDefaultValues(Content singletonNode, Map defaultValues)

{code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.magnolia-cms.com/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira



----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <dev-list-unsubscr...@magnolia-cms.com>
----------------------------------------------------------------

Reply via email to