Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7178165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:51:57+00:00 2026-05-28T16:51:57+00:00

I have a form that takes date range value to generate a report with

  • 0

I have a form that takes date range value to generate a report with Jasper Reports

reports/statistic.html.erb

<%= form_tag("/reports/statistic", :method => "post", :target => "_blank") do %>

  <%= label_tag(:from_date, "From Date:") %>
  <%= text_field_tag :from_date %>

  <%= label_tag(:to_date, "To Date:") %>
  <%= text_field_tag :to_date %>

  <br><br>
  <%= submit_tag("Generate Report") %>
<% end %>

and this is reports_controller.rb

def statistic

    @details=StatisticTable.where(:dateindb => (params[:from_date])..(params[:to_date])

    send_doc(render_to_string(
        :template => 'reports/statistic.xml', :layout => false),  #source of xml and template
        '/statistic/detail', #xml xpath2 query in reports
        'statisticreport',   #name of .jasper file
        'StatisticReport',   #name of pdf file
        'pdf')
  end

When I clicked Generate Report button, the report displays nicely in a pdf viewer in a new window. But when I try to save the pdf file, the pdf is empty and the date value is returned as null.

Also, I followed this tutorial http://oldwiki.rubyonrails.org/rails/pages/HowtoIntegrateJasperReports which explains where the send_doc method comes from.

I don’t think the problem is in Jasper because if I replace this

@details=StatisticTable.where(:dateindb => (params[:from_date])..(params[:to_date])

with a pre-defined date value

@details=StatisticTable.where(:dateindb => ('2011-12-01')..('2011-12-31')

the report displays and saves perfectly. So I’m guessing there is something wrong with my Ruby on Rails variables setting?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:51:58+00:00Added an answer on May 28, 2026 at 4:51 pm

    I solved this by only changing form method to GET

    <%= form_tag("/reports/statistic", :method => "get", :target => "_blank") do %>
    
      <%= label_tag(:from_date, "From Date:") %>
      <%= text_field_tag :from_date %>
    
      <%= label_tag(:to_date, "To Date:") %>
      <%= text_field_tag :to_date %>
    
      <br><br>
      <%= submit_tag("Generate Report") %>
    <% end %>
    

    and after report is generated in PDF, I clicked Save and the PDF saves the whole data perfectly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that takes the following form: person, date, food1, food2, food3
I have a form that takes the following inputs: Name: IBM Surface(in m^2): 9
I have a Windows Form that takes quite a bit of time to load
I have a multipart form that takes basic user information at the beginning with
I have a recursive method on the base form that takes in a control
I have an SQL query that takes the following form: UPDATE foo SET flag=true
I have an HttpHandler on my webserver that takes a URL in the form
I have an HttpPost controller action that takes in a simple form DTO object.
I currently have a form which takes a date in the format m/d/y -
Drupal 6.22 I have an empty page except for a form that takes two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.