views:

25

answers:

0

Hi,

I am working in Ruby on rails. I am trying to call APIS of my rails application using Jersey library.I am having 2 tables namely blogs (id,title,desc) and comments (id,commentdata,blog_id)..

I have written a function which retrieves the blog by giving its title. All these working fine.

Now i am trying to fetch the comments also associated with the blog ..

  final String LIST_BLOGS="api/blogs/show/"+title+".xml";
  return webResource.queryParam("with_comments", with_comments).path(LIST_BLOGS).header(ConfigurationUtil.AUTHENTICATION_HEADER, authentication)
        .accept(MediaType.APPLICATION_XML_TYPE).get(new GenericType<BlogBean>() {
    });

This returns the comments but i dont know how to make those comments to display the answers .

Here is my code :

    BlogWrapper objBlogWrapper = new BlogWrapper();
    String title=args[1];
    String comments="no";comments=args[2];
            BlogBean blogBean  = objBlogWrapper.displayblog(title,comments);

                    System.out.println("Id : "+blogBean.id);
                    System.out.println("Name : "+blogBean.title);
                    System.out.println("Description : "+blogBean.description);

                    System.out.println("Comments"+blogBean.?); // Dont know of how to retrive the comments for my retrived Blog 


   public BlogBean displayBlog(String title,String with_comments)
   {
    BlogBean blogList = null; 
    blogList = getBlogsXml(title,with_comments);
    return blogList;           

    }



     public BlogBean getBlogsXml(String title,String with_comments) {
       final String LIST_BLOGS="api/blogs/show/"+title+".xml";
       return webResource.queryParam("with_comments", with_comments).path(LIST_BLOGS).header(ConfigurationUtil.AUTHENTICATION_HEADER, authentication)
        .accept(MediaType.APPLICATION_XML_TYPE).get(new GenericType<BlogBean>() {
    });
       }

where my @XmlRootElement(name="blog")