Solved

JSP - using pager-taglib : Clear the data entry block after click on the next page from the first block

Posted on 2007-03-20
6
403 Views
Last Modified: 2008-01-09
I've developed a JSP page which contains 2 blocks: The first block allows the user to select one from a list of transaction codes with the radio button; the second block is to allow the user to enter the details

The first block i use pager-taglib for pagnation. The problem is if i enter the details from the second block and click on the page number, it then clears all the data i just entered in the second block.

*** I know the problem is when i click on the next page, it calls the form itself that is the reason it clear all fields. But I dont know how to tackle this problem

Please advise how to tackle this problem

See the codes below.

/******* problem below
 <pg:pager url="createRequest.jsp" maxIndexPages="10" maxPageItems="3">  


   <table border="0" bgcolor="D2D8E1" cellspacing="1" cellpadding="1" width="720">
   <form name="wizard" method="POST" action="/ServiceRequest/CreateSrOnline" onsubmit="return checkData()">  
   <%
       ArrayList reservations =(ArrayList) session.getAttribute(Constants.RESERVATIONS);
     if (reservations != null && reservations.size() > 0) {
   %>

         <tr align="left" style="font-size:9pt; font-weight:bold">
             <th width="10">Select</th>
             <th width="80">Service Type</th>
             <th width="200">Description</th>
         </tr>

         <%
           String claz = null;
             for (int i = 0; i < reservations.size(); i++) {
                  claz = (i%2 != 0) ? "odd" : "even";       
                String[] reservation = (String[]) reservations.get(i);
         %>
      <pg:item>
         <tr class="<%= claz %>"  align="left" bgcolor="ffffff" style="font-size:9pt;">
             <td>
              <input type="radio" name="SelectSRtype" value="<%=reservation[0]%>"/>
             </td>
 

             <%
              for (int j = 0; j < reservation.length - 1; j++) {
                  String value = reservation[j];
             %>
             
             <td><%=value%></td>
             <% } %>

         </tr>
        </pg:item>  
         <% } %>                  
   </table>
   <table border="0" bgcolor="DEE3E9" cellspacing="1" cellpadding="1" width="720">
              <tr >
                  <td align="right">    
                        <pg:index>
                              <pg:prev><a href="<%= pageUrl%>">[&lt;&lt;Prev]</a></pg:prev>
                              <pg:pages><a href="<%= pageUrl %>"><%= pageNumber %>&nbsp;</a></pg:pages>
                              <pg:next><a href="<%= pageUrl%>">[Next&gt;&gt;]</a></pg:next>
                        </pg:index>
                  </td>
                </tr>
      </table>  
   <% } %>
  </pg:pager>
<html>
<p>
   <table border="0" bgcolor="D2D8E1" cellspacing="1" cellpadding="1" width="720">
         <input type="hidden" name="appAction" value="<%=Constants.ACTION_SAVE%>"/>

                       
                  <tr align="right" style="font-size:9pt; font-weight:bold">
                    <td width="120"><font color="#ff0000">*</font>Your Email Address</td>
                    <td width="250" align="left"  style="font-size:9pt; font-weight:normal" >
                    <input type="text" name="inputEmailAddr" size="55"/></td>              
                  </tr>
                  <tr align="right" style="font-size:9pt; font-weight:bold">
                    <td width="120">Message</td>
                    <td width="250" align="left"  style="font-size:9pt; font-weight:normal" >
                        <textarea name="inputMessage"  rows="5" cols="63"></textarea>
                    </td>              
                  </tr>
                  <tr align="right" style="font-size:9pt; font-weight:bold">
                    <td width="120"> </td>
                  </tr>
         
              </tr>
              <table  border="0" bgcolor="D2D8E1" cellspacing="0" cellpadding="0" width="720">
                  <tr align="center" bgcolor="ffffff">  
                    <td align="right" bgcolor="DEE3E9" width="44">
                    </td>                   
                    <td align="left" bgcolor="DEE3E9" width="190">
                        <input type="submit" name="srAdd" value="Submit" >
                    </td>                             
             </tr>
             </table>
       </form>
   </table>
  </body>
</html>

0
Comment
Question by:LeanMoreTryMore
  • 3
  • 2
6 Comments
 
LVL 27

Assisted Solution

by:mrcoffee365
mrcoffee365 earned 220 total points
ID: 18772329
There are several ways to handle the issue of saving data from a form through successive iterations of the form.

Basically you have to save the values entered in the form before clearing the display of the form for the next set of entries.

So, before clearing out the display values, get all of the input parameters from the form.  You can save them in a session variable, as you seem to be doing with the reservations array, or save them in a cookie, or save them in a database.  Or, you can save them in additional hidden form input parameters.

Did you run into problems trying to save the previous form's input parameters?
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 280 total points
ID: 18772863
>> You can save them in a session variable

Storing it intermediarily in a hashtable or something in the session should be a good idea. Maybe call a Javascript which sends the values to a Servlet to store it on click on the button and then take it to another page.
0
 

Author Comment

by:LeanMoreTryMore
ID: 18774853
Thanks for both.
I think I got your idea. Let me try to see what happen.
May be I need your help later on?
0
Industry Leaders: 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 30

Expert Comment

by:Mayank S
ID: 18776195
Sure.
0
 

Author Comment

by:LeanMoreTryMore
ID: 18776781
Do you have any sample program i can reference to?
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18928127
Sorry I was busy with work, so couldn't
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Foreword (May 2015) This web page has appeared at Google.  It's definitely worth considering! https://www.google.com/about/careers/students/guide-to-technical-development.html How to Know You are Making a Difference at EE In August, 2013, one …
Foolproof security solutions has become one of the key necessities of every e-commerce or Internet banking website. If you too own an online shopping site then its vital for you to equip your web portal with customer security features that can allow…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

749 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