3 Replies Latest reply: Mar 30, 2012 12:33 AM by Mandar Tuljapurkar RSS

    Getting threads on the basis of category

    arpan.bansal

      Hi,

       

           I have to develop a widget on homepage which will show the only the threads(discussions) related to category(tagset) in a Space(community). I came to know a method "com.jivesoftware.community.impl.DBForumManager.JiveIterator<ForumThread> getThreads(TagSet tagSet)".

       

       

       

      I have tried also "com.jivesoftware.community.impl.DBForumManager.JiveIterator<ForumThread>getThreads(container)" but still no result.

       

       

       

      I assumed that this method will give me the iterator of the forum threads depending on the tagset passed, but it doesn't show me any.

       

       

       

      Added the dependency

       

       

       

       

       

      <bean id="fcCategoryWidget" class="com.foodcentral.community.widget.FCCategoryWidget">

       

                   <property name="forumThreadWrapperCategory" ref="forumThreadWrapperCategory"/>

       

                   <property name="categoryForumManager" ref="forumManagerImpl"/>

       

             </bean>

       

       

       

       

       

       

       

       

       

      Below is the method code snippet from the widget.

       

       

       

       

       

      public void setCategoryForumManager(ForumManager forumManager) {

       

              this.forumManager = forumManager;

       

          }

       

       

       

      protected Map<String, Object> loadProperties(WidgetContext widgetContext,

       

                  ContainerSize containerSize) {

       

              Map<String, Object> properties = super.loadProperties(widgetContext,

       

                      containerSize);

       

       

       

              JiveContainer container = getContainerFromContext(widgetContext);

       

       

       

              JiveIterator<TagSet> categories = null;

       

              JiveIterator<ForumThread> categoryContent = null;

       

              categories = tagSetManager.getTagSets(container);

       

              TagSet defaultTagSet = null;

       

       

       

              for (TagSet tagSet : categories) {

       

                  defaultTagSet = tagSet;

       

                  break;

       

              }

       

       

       

              categories = tagSetManager.getTagSets(container);          

       

              logger.error("Inside defaulttagset block"+ defaultTagSet);

       

                

       

                  if (null != defaultTagSet) {

       

                    

       

                      try {

       

                          categoryContent = forumManager.getThreads(defaultTagSet);

       

                        

       

                        

       

                      } catch (Exception e) {

       

                          // TODO Auto-generated catch block

       

                        

       

                          logger.error("Inside Esception block");

       

                          e.printStackTrace();

       

                      }

       

                  }

       

                  else

       

                  {

       

                      categoryContent = forumManager.getThreads(container);

       

                  }

       

                  properties.put("categoryContent", categoryContent);

       

                  logger.error("arpanLogs" +categoryContent);

       

            

       

            

       

              properties.put("defaultTagSet", defaultTagSet);

       

              properties.put("categories", categories);

       

              properties.put("discussionThreadHandler", forumThreadWrapperCategory);

       

              properties.put("numResults", getNumResults());

       

              properties.put("currentUser", widgetContext.getUser());

       

       

       

              return properties;

       

          }

       

       

       

      But still i am not getting any result . Please help on this as i need to deliver the same on urgent basis.