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
405 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 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Using Quotation Marks in PHP This question (http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28217211.html) seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
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…
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.

696 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