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
402 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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
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 …
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

773 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