Announcement Announcement Module
Collapse
No announcement yet.
Spring RSS Adding Custom Elements / Tags - AbstractRssFeedView Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring RSS Adding Custom Elements / Tags - AbstractRssFeedView

    Hi,
    I am extending org.springframework.web.servlet.view.feed.Abstract RssFeedView
    to generate an RSS Feed View.

    I would like to add custom elements and child elements to my feed item, but have no idea how.

    This is the format my feed item should have:
    Code:
         <jobs>
                  <job>
          			<title></title>
          			<salary></salary>
         			<description></description>
          			<expire></expire>
          		</job>
          </jobs>
    Here is my code that only creates a Standard RSS format, without any of the custom elements mentioned above.

    So, how can I add custom elements (as the ones above) to my feedItems mentioned in the Java code below.
    Any code snippets would be highly appreciated.

    Code:
    @Override
        protected List<Item> buildFeedItems(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response)
            throws Exception {                                               
    
            @SuppressWarnings("unchecked")
            List<Job> jobsList = (List<Job>) model.get("jobsList");
            String url = "http://www.example.com/jobs/";
            
            List<Item> feedItems = new ArrayList<Item>();
            for (Job thisJob : jobsList) {
            	
            	User user = 
            		((UserService)ApplicationContextProvider.getApplicationContext().getBean("userService")).getUserByUserId(thisJob.getUserId());
                
            	Item feedItem = new Item();
            	
                feedItem.setTitle(thisJob.getTitle());
                feedItem.setAuthor(user.getFirstName() + " " + user.getLastName());
                feedItem.setPubDate(thisJob.getDatePosted());
                feedItem.setLink(url + thisJob.getId());
                            
                Category category = new Category();
                category.setValue(thisJob.getService());
                List<Category> categories = new LinkedList<Category>();
                categories.add(category);
                feedItem.setCategories(categories);
                
                Guid guid = new Guid();
                guid.setValue(feedItem.getLink());
                feedItem.setGuid(guid);
                
                Description desc = new Description();
                desc.setType("text/html");
                desc.setValue(thisJob.getDescription());
                feedItem.setDescription(desc);
    
               /* Here I want to add custom elements to the feedItem */
               // feedItem.addMyCustomELement(customElement);
                feedItems.add(feedItem);
            }
    
            return feedItems;
        }

    So, how can I add custom elements to my feedItems mentioned in the Java code.
    Any code snippets would be highly appreciated.


    Thanks in advance!
Working...
X