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
399 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 26

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:
mayankeagle 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 30

Expert Comment

by:mayankeagle
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:mayankeagle
ID: 18928127
Sorry I was busy with work, so couldn't
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…
This video teaches users how to migrate an existing Wordpress website to a new domain.

759 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now