?
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
Medium Priority
?
408 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
[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
  • 3
  • 2
6 Comments
 
LVL 27

Assisted Solution

by:mrcoffee365
mrcoffee365 earned 660 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 840 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction ( All good things must come to an end ) The original MySQL API has gone away.  It was deprecated (years ago) by PHP in Version 5.5, and removed from PHP in all current releases .  As a result, the issue is upon us today.  It's time to …
If I have to fix slow responding website my first thoughts are server side optimizations: the database may not be optimized or caching is not enabled, or things like that. We often overlook another major part of our web application: the client. We o…
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…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

777 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