Solved

JSP - pdf generation

Posted on 2006-07-21
8
1,060 Views
Last Modified: 2008-03-17
Hello All,

I am having a jsp page which displays a table of columns...one column is a checkbox column.  if i select the table header column, all the checkboxes get selected.  or i can select anything particularly.  the problem is i want to generate pdf which are all selected for.  so can you pls inform me how to do it.  i heard about jasper reg. pdf generation.

thanks
0
Comment
Question by:altima4u
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 15

Expert Comment

by:bpmurray
ID: 17154690
Well, Jasper is a report generator, and perhaps not quite what you need. I suggest iText (Jasper actually uses this to generate PDF) - see http://www.lowagie.com/iText/
0
 
LVL 1

Author Comment

by:altima4u
ID: 17154793
can you inform about the logic for getting out the selected values of the checkboxes, passing the parameters as query string for it and getting printed in the pdf file.  i have a pdf icon on the top of the page.  if i click that then for which all i selected, i should be able to generate the pdf for it !
0
 
LVL 15

Expert Comment

by:bpmurray
ID: 17154899
Do you mean in the browser or on the server?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:altima4u
ID: 17155025
server side.  Iam writing java code for it.
0
 
LVL 1

Author Comment

by:altima4u
ID: 17155027
using struts framework.
0
 
LVL 15

Expert Comment

by:bpmurray
ID: 17155761
Well, if you're using multibox, you can do something like this to get the values from the struts action:

public class CheckboxAction extends Action {
      public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                               HttpServletResponse response) throws ServletException, Exception {

                  //      Get the values in the checkboxes
                  String[] selectedDocuments = ((MyForm) form).getSelectedDocuments();

                  System.out.println("RETURNED*\n" + selectedDocuments.toString());

                  return (mapping.findForward("success"));
      }

}
0
 
LVL 1

Author Comment

by:altima4u
ID: 17156282
iam using this type of code.  kindly look at the code.

<td width="12%" class="blackRow" align="center"><b><input type="checkbox" name="chkAllBox" onclick="checkAll()"></b></td>

***** the above is for the table header column checkbox...

<logic:iterate id="Data" property="value(StrategySearchResults)" name="SSForm">

<%
            if (i % 2 == 0)
            {
      %>            
                  <tr class="TABLE_EVEN_ROW">
      <%                  
            }
            else
            {
      %>            
                  <tr class="TABLE_ODD_ROW">
      <%                  
            }
            i++;
      %>

                <td class="td" align="center">
                    <a class="bluelink" href="/HFSPortal/EditStrategy.do?strategy_id=<bean:write name="Data"
                         property="value(TradeCode)"/>"><u>Edit</u></a>
                </td>
               
       
            <!-- Strategy Name -->      
            <logic:notEmpty property="value(StrategyName)" name="Data">            
                  <td class="td">
                  <a class="bluelink" href="./ShowCharts.do?tradeCode=<bean:write name="Data" property="value(TradeCode)"/>&Rating=<bean:write name="Data" property="value(StrategyRating)"/>&StratName=<bean:write name="Data" property="value(StrategyName)"/>" />
                        <bean:write name="Data" property="value(StrategyName)"/>
                  </a></td>
            </logic:notEmpty>
            <logic:empty property="value(StrategyName)" name="Data">
                  <td class="td">&nbsp;</td>            
            </logic:empty>
            <!-- Strategy Name -->                  
            
            <!-- check if StrategySector is null -->
            <logic:notEmpty property="value(StrategySector)" name="Data">            
                  <td class="td"><bean:write name="Data" property="value(StrategySector)"/></td>
            </logic:notEmpty>
            <logic:empty property="value(StrategySector)" name="Data">
                  <td class="td">&nbsp;</td>            
            </logic:empty>
            <!-- check if StrategySector is null -->

            <!-- check if StrategyRating is null -->
            <logic:notEmpty property="value(StrategyRating)" name="Data">
                  <td class="td"><bean:write name="Data" property="value(StrategyRating)"/></td>            
            </logic:notEmpty>
            <logic:empty property="value(StrategyRating)" name="Data">
                  <td class="td">&nbsp;</td>            
            </logic:empty>
            <!-- check if StrategyRating is null -->            

            <bean:define name="Data" property="value(TradeCode)" id="TradCode" />
            <bean:define name="Data" property="value(StrategyName)" id="StrategyName" />
            
            
            
            <!-- check if StrategyNav is null -->
            <logic:notEmpty property="value(StrategyNav)" name="Data">
                  <td class="td" align="right">
                  <a class="bluelink" onClick="return ShowAUMBreakup('<%=TradCode%>', '<%=StrategyName%>','<%=businessDate%>')" href="">
                        <bean:write name="Data" property="value(StrategyNav)"/>
                  </a></td>
            </logic:notEmpty>
            <logic:empty property="value(StrategyNav)" name="Data">
                  <td class="td">&nbsp;</td>            
            </logic:empty>
            <!-- check if StrategyNav is null -->                              

            <!-- check if Capacity is null -->
            <logic:notEmpty property="value(Capacity)" name="Data">
                  <td align="right" class="td"><bean:write name="Data" property="value(Capacity)"/></td>            
            </logic:notEmpty>
            <logic:empty property="value(Capacity)" name="Data">
                  <td align="right" class="td">&nbsp;</td>            
            </logic:empty>
            <!-- check if Capacity is null -->            

            <!-- check if ErisaCapacity is null -->
            <logic:notEmpty property="value(ErisaCapacity)" name="Data">
                  <td align="right" class="td"><bean:write name="Data" property="value(ErisaCapacity)"/></td>            
            </logic:notEmpty>
            <logic:empty property="value(ErisaCapacity)" name="Data">
                  <td align="right" class="td">&nbsp;</td>            
            </logic:empty>
            <!-- check if ErisaCapacity is null -->      
            
            <!-- Inception Date -->
            <logic:notEmpty property="value(inceptDate)" name="Data">
                  <td align="center" class="td"><bean:write name="Data" property="value(inceptDate)"/></td>
            </logic:notEmpty>
            <logic:empty property="value(inceptDate)" name="Data">
                  <td align="center" class="td">&nbsp;</td>
            </logic:empty>
            <!--Inception Date-->      
            
======= here comes the check box =========

            <!--Check Box-->
            <td align="center"><input type="checkbox"/></td>
        <!--Check Box-->
       </td>
       
      </tr>            
      </logic:iterate>
</table>


i have a pdf icon above table, for the selected check boxes, if i click the icon , i have to pass some values for each pdf generation.. i dont know how to do that..the link for the pdf icon is some.java..do i have to write all the logic in the java file..like getting the selection and able to print them in a pdf file.
pls let me know about this..
0
 
LVL 15

Accepted Solution

by:
bpmurray earned 200 total points
ID: 17156562
I don't know how your PDF icon works. I can only assume it does a submit, in which case, it will send the name-value pairs of the various input fields into the servlet. Now, there's a little problem here - you don't have an ID or a NAME on the checkbox. Perhaps you could do it like this:
             <td align="center"><input type="checkbox" id=<% generateID(i); %>/></td>

Just to verify that the PDF icon does the submit, check what it generates when it displays on the browser. It probably has something like
            onclick="SSform.submit();"

When the form is submitted, all the ticked generated checkboxes are sent on the request, and you cal identify these using the same techniques as you used to display the page, but this time in the action:
      public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                             HttpServletResponse response) throws ServletException, Exception {
            
            // Get the results that were used as a basis for the table on the page
            String[] foo = SSForm.getStrategySearchResults();
            int chkCount = foo.length;
            
            // Print report if the checkbox is ticked
            for (int iX=0; iX<chkCount; iX++) {
                  if (null != request.getParameter(generateID(iX))) {  // Use identical technique to generate the ID
                        generatePDFDocument(foo[iX]);
                  }
            }

            return (mapping.findForward("success"));
      }
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question