Implementing a next button

Hi hopefully someone may be able to help me out on this one. I have created a servlet which access a DB, stores the results in an arraylist and passes this in the session object to a jsp page. At the moment the code below iterates throught the arraylist and prints out all the records. I would like to ammend this so that there is only one record at a time displayed and the user can use a next button to get the next element displayed from the arraylist. II have seen similar posts but am still struggling. if anyone could help it would be appreciated (code so far below)as i am having problens working out how to code the next button. Hope you can help.
thankyou
<%
for (int i=0;i<arrayList.size();i++)
Beaninfo info = (Beaninfo)arrayList.get(i);
String whatever=info.getSubmitter();
String whatever2=info.getUrl();
String whatever3=info.getSubmitt_date();
%>
     <tr>
     <td><%= whatever%></td>
     <td><%= whatever1%></td>
     <td><%= whatever2 %></td>
     </tr>
<%
%>

Ok dear here is the sample
///////////////////////Paging.jsp///////////////////////////////////////////////////////////////////////////////////
<%@ page language="java" import="java.util.ArrayList, com.test.*"%>
<html>
<body>
<%
ArrayList arrayList = null;
int i=0;
if(request.getParameter("NextRec")!=null) {
i = Integer.parseInt(request.getParameter("NextRec"));
if(session.getAttribute("MyList")!=null) {
arrayList = (ArrayList)session.getAttribute("MyList");
} else {
MyBean mb = new MyBean();
arrayList = mb.getAllWhatevers();
if(arrayList.size() > 0) {
session.setAttribute("MyList", arrayList);
%>
<form name="frmA" action="Paging.jsp" method="post">
<table>
<%
BeanInfo info = (BeanInfo)arrayList.get(i);
String whatever1=info.getWhatever1();
String whatever2=info.getWhatever1();
String whatever3=info.getWhatever1();
%>
<tr>
<td><%= whatever1%></td>
<td><%= whatever2%></td>
<td><%= whatever3%></td>
</tr>
</table>
<input type="submit" name="submit1" value="Next">
<input type="hidden" value="<%=++i%>" name="NextRec">
</form>
<%
%>
</body>
</html>
///////////////////////BeanInfo.java///////////////////////////////////////////////////////////////////////////////////
package com.test;
public class BeanInfo {
String strWhatever1;
String strWhatever2;
String strWhatever3;
public BeanInfo() {}
public String getWhatever1() {
return strWhatever1;
public void setWhatever1(String strWhatever1) {
this.strWhatever1 = strWhatever1;
public String getWhatever2() {
return strWhatever2;
public void setWhatever2(String strWhatever2) {
this.strWhatever2 = strWhatever2;
public String getWhatever3() {
return strWhatever3;
public void setWhatever3(String strWhatever3) {
this.strWhatever3 = strWhatever3;
///////////////////////MyBean.java///////////////////////////////////////////////////////////////////////////////////
package com.test;
import java.util.ArrayList;
public class MyBean {
String strWhatever1;
String strWhatever2;
String strWhatever3;
public MyBean() {}
public ArrayList getAllWhatevers() {
ArrayList arlWhatevers = new ArrayList();
BeanInfo bi = null;
for(int i=0; i<4; i++) {
     bi = new BeanInfo();
bi.setWhatever1("hehe"+i);
bi.setWhatever2("haha"+i);
bi.setWhatever3("hoho"+i);
arlWhatevers.add(bi);
return arlWhatevers;
}

Similar Messages

  • Iterating though a List with a 'next' button.

    Hey people,
    I am just finishing off my GUI but I had a thought, I really would like to have next and previous buttons so I can move through my list.
    However I started by implementing the 'Next' button, but I have run into some trouble, on the GUI I want the user to click next and it moves obviously to the next record, then they can hit it again and it moves onto the next record again.
    However when I tried to do this, the interator refuses to move to the next record, it just stays at they record with the index of 0.
    I've read some books, done some research and tried all the ways I can think of, but to no avail, my code for the 'Next' method is below, the button on the GUI just calls it from a separate class.
    public void MusicNext()
    ListIterator titerator = iList.listIterator();
    if(titeration.hasNext())
    System.out.println(titerator.next());
    }

    Hmmm, I am a little confused (yes I am stupid), heres my code:
    import java.util.*;
    public class MusicList
                private List iList;  //names are stored in a list.
         public MusicList()
              iList = new LinkedList();
         public MusicList(List pListOfMusic)
              iList = pListOfMusic;
            //Here's the interator, but I get a null pointer exception error.
            ListIterator titerator = iList.listIterator();
            public void MusicNext()
                    if(titerator.hasNext())
              System.out.println(titerator.next());
         public void addMusic(Music pMusicName)
                iList.add(pMusicName);
         public void removeMusic(Music pMusicName)
              iList.remove(pMusicName);
            //Return the name with the given surname, otherwise return null.
         //Uses a linear search.
            public Music findTitle(String pTitle)
              Music tTitle = null;
              boolean found = false;
              Iterator it = iList.iterator();
              while (it.hasNext() && !found)
                   tTitle = (Music) it.next();
                   found = tTitle.getTitle().equalsIgnoreCase(pTitle);
              if(!found) tTitle=null;
              return tTitle;
         public Music findAuthor(String pAuthor)
              Music tAuthor = null;
              boolean found = false;
              Iterator it = iList.iterator();
              while (it.hasNext() && !found)
                   tAuthor = (Music) it.next();
                   found = tAuthor.getAuthor().equalsIgnoreCase(pAuthor);
              if(!found) tAuthor=null;
              return tAuthor;
            public Music findPublisher(String pPublisher)
              Music tPub = null;
              boolean found = false;
              Iterator it = iList.iterator();
              while (it.hasNext() && !found)
                   tPub = (Music) it.next();
                   found = tPub.getPublisher().equalsIgnoreCase(pPublisher);
              if(!found) tPub=null;
              return tPub;
         public String toString()
              return "Music List = " + iList.toString();
    }Thanks,
    Rob.

  • Apex 2.1 (XE) Master/Detail Page Question Regarding Prev/Next Buttons

    When creating a page of type master/detail the master form is auto-populated with two buttons that allow the user to navigate to the previous or next record. These buttons are implemented as submit buttons, which cause the session variables to be updated with the current form values prior to moving to the previous or next record. But no database update happens because the buttons have matching before computation branches that reload the current page. It seems to me as if these buttons should have been implemented as URL redirects so as to not cause the session variables to be updated, especially since they are being updated to values that will not match the newly displayed record. And another problem is that any user changes to items on the form get picked up by the page navigation submittal and are stored into the session's item variables, yet are never persisted to the database. When code on other pages use these item variables, you can get some strange results because of this.
    My current workaround is to store each displayed item into the session during the display of the page (during the rendering phase) using the htmldb_util save_session_state function. This effectively overwrites any errant data in the session variables with what is actually being shown on the screen. (As an aside, if anyone has a better way to cause all the session variables to be updated during the fetch and page rendering step, please let me know, otherwise I will continue hand coding the save_session_state for each item in an anonymous PL/SQL block).
    Ultimately I was wondering if anyone else thought these two buttons should have been implemented by the Apex designers as URL redirects, rather than submit buttons? This would have kept the session data update from happening. Or is there a good reason to have these buttons submitting that I haven't been able to figure out?
    Thanks in advance for any thoughts on the issue.
    - Jim

    Is a before insert trigger not more interesting and safer in your use case?

  • BUG: NEXT BUTTON IN REPORT (PORTLET)

    If I run a report as a portlet and pass a parameter to the page containing the portlet and press the next-button of the report, the parameter is not passed again to the page... My intention is to write my "own" provider implementation to adjust page_url of the portlet_runtime_record in the show_portlet method. Is there an easier workaround available?

    Select customize and set the number of rows to 9999. I'm guessing that it's currently set to 10.

  • Changing the label of Next button in af:trainButtonBar

    Hi,
    I have a bounded task flow that contains 5 train stops.
    In each step, I’m using the train button component to show the back and next buttons.
    In the third train stop, I need to change the label of the next button to something else (read from a resource bundle if possible) but I need to do it only for this taskflow and for this step only.
    I found that I can do this with the skinning, but this will change it for the whole application no? but I need to do it for this task flow only
    Any hints how can i change the label?
    Thank you

    Hi,
    The task flow I’m implementing is a simple task flow where the user navigates through all the stops. No stop is skipped. So the af:trainButtonBar is very suitable for my case. The only modification I need is to change the text label of the next button from “next” to “a string read from a resource bundle”.
    In the example in the link, we are using command buttons but what I need is to stick to af:trainButtonBar with just changing the label.
    Thank you again

  • Create first,prev,last,next buttons

    Hi, tell me the syntax to create any one of these button(first,prev,next,last).
    Thanks in advance!

    Hi,
    You can create these buttons and can write your logic to query the required records, there is no such standard things provide by OA framework for this all these are custom so just create forur buttons with name as first, last nest and prev and write logic to fetch the first, last, next and previous records.
    you can make use of setCurrentRow method first set first record as current record and it will be displayed on your page after this on click of next button set next row as current row so it will display the next row on the page.
    For previous button again get previous row and set it as previous row and for lst button set last row as current row.
    I hope this is very simple to implement, let me know if anything you want to know.
    Regards,
    Reetesh Sharma

  • How to code a NEXT button

    Hello everyone,
    I am developing an web application in jsp.As a part of this application i need to get a list of records from the database.As per my code all the records are being listed in the same page. But i want to display some 50-100 records per page and keep a NEXT button on each page so that when the user clicks on this button he can go to the next set of records.But i am not getting an idea abt how to code this.So can anyone help me in this regard or just give me an idea of how to print a certain no. of records per page and the NEXT button coding.

    Is your application only jsp or struts or jsp/Helper java classes?
    In any case, assuming that the number of records are not very large, it is better to avoid repeated DB calls. The common way to implement this is to fetch all the records and store it in a data structure(an ArrayList for eg:) in the session. You would also have to maintain another variable for the current last record number. On click of the next button, fetch the records from current last record to current last record + 50 (or 100 or infact, you can make this as a variable too) from the session ArrayList and show it in the same jsp. Also, update the current last record number.
    The other way around (if at all you have session considerations) is to make a new call to the DB everytime you click on Next.

  • Click the Next button or Click the Next arrow to continue?

    Click the Next button or Click the Next arrow to continue. Which statement do you use and why?

    I like that idea with the line.  sometimes what I'll do in CP, is have the button appear and then have a glow affect hit it, like you said to draw the eye.  if it's text or narration I might use 'click to continue' or 'click when you're ready to continue' especially if they're going to an outside resource or reviewing some information on screen which some may take more time than others.  Mostly, that's just a cue to them to take as much time as they want.  Not to say they DO, but I try.
    That said, sometimes a client will say "it didn't tell me to click to continue."  which i always find.. not frustrating.. but something along those lines.
    Ten years ago I could imagine not knowing what to do, but I shouldn't 1) have to put "NEXT" on a button for you to know what to do if it has an arrow, or 2) tell you to click it on every slide.  The right/left arrows are so ubiquitous in technology and web now, I can't imagine people with appropriate background (understanding less tech-savvy audiences may not) wouldn't know what they should do.  And hey, if they have to click them to see what they do, that's all good too.  Proper implementation of the Gutenberg diagram should be enough for most learners.
    All just my opinion of course.  I'm curious what others have to say.

  • How do I make a learner attempt a question, without having the option of a 'Next' button?

    Hi,
    Is it possible to display the feedback option (learner selected) from a multiple choice Question by clicking the next (or previous) page button?
    I have set the progress to the next page, with the option 'Attempts - 1' from the Assessment page. The objective of this exercise was to make the learner attempt the given multiple choice question, without the option of going back or forward during their first attempt. The first time the learner comes across this page, he/she has to answer the question to move forward. Once he/she has answered the question (right or wrong), then he/she will be able to navigate to the next and previous pages.
    Is there any functionality where we can restrict the learner in taking up the test (compulsory), before navigating to the next page (using 'Next' button)?
    Thank you,
    Emayavaramban M E

    Don't show the Next button, but drag it under the Clear button if you have that one. Next button is really meant to skip an answer (which you do not want to allow) and during Review to make navigation possible. Since the Clear button will not be there during Review, then the Next button will become visible. Next is the new label (formerly it was labeled Skip). I explained some functionality of question slides in this post:
    http://blog.lilybiri.com/question-question-slides-in-captivate
    It was written in the CP5.5 time, so you'll still see the label 'Skip' that is now replaced by 'Next'
    Lilybiri

  • My Next button is not working. Please Help!

    Hello, everyone.
    Thank you very much for stopping by my question.
    I'm trying to make this work all day today. I'm out of idea...
    SortedMap m = new TreeMap()is used to sort the collection.
    I want to show next record(name and payrate) in the collection if there's any. Every time I try the code, I get 'Class Cast Exception'
    What am I doing wrong? The following is the code.
    <CODE>
    // Next button
    if (e.getSource().equals(nextBtn))
    // Show an error message if the collection is empty.
    if (m.isEmpty())
    msg.setText("No Record is in the Collection");
    //Instantiate an Inerator on the collection's key set and use it to
    // display next record.
    Iterator pointer = m.keySet().iterator();
    if (pointer.hasNext())
    msg.setText("The records: "+ (String)m.get(pointer.next()));
    // Show a message if there is no more record available in the collection.
    else {
    msg.setText("No More Record");
    </CODE>
    Please give me suggestion/advice.
    Thanks in advance.

    hi, Radish21.
    I think I'm not adding payRate into the collection succesfully.
    I changed the code as below:
    Iterator pointer = m.keySet().iterator();
    if (pointer.hasNext()){
      Object key = pointer.next(); // get the next key.
      Object value = m.values(); // get the value for that key.
      msg.setText(key +"," +value);
    }I got the following message in message area:
    Eric,[project06.App$Employee[Eric,0,0,0x0,invalid,layout=java.awt.FlowLayout], project06.App$Employee[Maya,0,0,0x0,invalid,layout=java.awt.FlowLayout], project06.App$Employee[Naoyo,0,0,0x0,invalid,layout=java.awt.FlowLayout]]
    I see the names I added, but don't see the payrate there.
    The following is the code to add the name/payrate into the collection:
    m.put(nameField.getText(),  new Employee (nameField.getText(), Double.parseDouble(payRateField.getText())));Isn't this adding payRate?
    I'm sorry to ask you so many questions.
    I do really appreciate your time and consideration.
    Thank you

  • How do I get the Next Button to appear on a form?

    I have a form built off of a view. I pass a parameter from a report through a link to launch the form with the appropriate values. I would like user to then be able to navigate to the next set of information from the report without having to navigate all the way back to the report. I tried to activate the Next button with the onClick event and doNext function but the button never appears to the user. Thank you for any assistance!

    Samuel,
    The reason that you don't get the "Next" button is that the query that the form is running on returns only one row. Take a look at EXAMPLE_APP.EXAMPLE_SQL_REPORT and EXAMPLE_APP.EXAMPLE_FORM. You'll find that this form also does not show the "NEXT" button when called from the report. However if you edit the report and change the link parameter from empno to deptno, you'll find that the button comes up in the form.
    I guess the best option you have is to create a custom button that simulates the functionality of the NEXT button i.e. have some logic to find out which empno must be the next one and then call the form like this :
    l_empno := <whatever logic you have come up with>
    l_url:=<portal_schema>.wwa_app_module.link?p_arg_names=_moduleid&p_arg_values=<module_id of the form>&p_arg_names=empno&p_arg_values='||l_empno||'&p_arg_names=_empno_cond&p_arg_values='||<portal_schema>wwv_standard_util.url_encode('=');
    <portal_schema>.wwa_app_module.set_target(l_url, 'CALL');
    Hope that helps,
    Hsiu

  • How can I grey out the 'Next' button until a user clicks 'Submit'?

    Hi guys,
    despite how I say it or display it in slides, users don't read the instructions before the quiz. This results in them doing the quiz and then asking me why they scored zero when they answered all the questions. So my question is, how can I disable/deactivate/grey-out the Next button until a user clicks Submit after answering the question?
    I've got Captivate 6.1 on a Windows platform.
    Advice appreciated.
    Carl

    Hello Rod,
    thanks for your answer - I should think more laterally in future.
    In my testing, another question has arisen - how do I get the Next button behind the Clear button? It sounds stupid but I can't get the Next button behind the Clear. I go in to the Master Slide, click on Next to highlight it, and then move it either by the mouse or with the arrow button so that it sits under the Clear button. While Next is still highlighted I click on the button in the toolbar 'Send selected objects backward' to be sure, so that I see 'Clear'. When I go back to the Filmstrip, all I see is 'Next' and when I preview the slides all I see is 'Next' - what am I missing here? What have I failed to do? What am I not understanding?
    Advice appreciated.
    Thanks

  • Firefox can't find the file at (a location is specified) when either "Navigate previous" (and next) buttons are pressed in an HTML5 skin (but OK in IE/Chrome).

    I create HTML5 help projects from a package called MadCap Flare. It uses what they call an HTML5 'skin' that sets the style/layout of the page and also includes 'Navigate previous' and 'Navigate next' buttons. When viewing the help and pressing these navigate buttons in IE8 or Chrome 32 there is no problem, but in Firefox 27 I get the following: (typical error for pressing a button on any page)
    "File not found"
    "Firefox can't find the file at /C:/SVN/FlareEnglishOnLineHelp/Output/HTML5_Help_Modeller_Reference/4attrib/idh_jointinterface_element_meshes.htm?TocPath=Modeller Reference Manual|Chapter 5 : Model Attributes|Meshing|_____2."
    " Check the file name for capitalisation or other typing errors."
    " Check to see if the file was moved, renamed or deleted."
    - Because the files and buttons work in other browsers I'm wondering just what is going on here with Firefox>>>>

    I should correct that last entry and state that the | charactacters are generated automatically in the Toc-Path for each 'book' name in the online help, and are not something manually created, whereas the : characters have come from the TOC book topic names (which were manually entered names and are what we would ideally require). But, because 'previous' and 'next' topics within nested TOC books without colon (:) characters CAN be browsed successfully when just | characters are present in the Toc-Path, the limitation would appear to be solely due to the : characters.

  • To disable the horizontal scrollbar and to create a next button to navigate

    To disable the horizontal scrollbar and to create a next button to navigate through the records. At present I create a JSF page and drag and drop my table view and then using the Tuning property I have limited the number of records to be shown. But I need to add a button and then code it to display the next few records. Can someone kindly suggest a suitable mechanism to get this accomplished.
    Edited by: 888970 on Oct 2, 2011 10:15 PM

    Hi Erp,
    At present these are the entries that I have in my JSPX page.
    I have a Table, Iterator and a Input List of Values. As per the scenario, I want a few rows to appear on the table for which I wanted to disable the horizontal scroll bar and then once I click on the list of values it must prompt me with the remaining page numbers.
    Earlier there are about 150 records in the table. I want to show them as 15 per page.
    For which I have added the Iterator and a LOV component code in my JSPX page.
    <af:iterator id="i1"
    value="#{bindings.NsEventDetailsView1.collectionModel}"
    var="row"
    binding="#{pageFlowScope.testPageBean.myIterator}"/>
    <af:inputListOfValues label="Label 1"
    popupTitle="Search and Result Dialog" id="ilov1"/>
    Then I created the bean class as per the example.
    Below is the bean class:
    import javax.faces.event.ValueChangeEvent;
    import oracle.adf.view.rich.context.AdfFacesContext;
    import org.apache.myfaces.trinidad.component.UIXIterator;
    import org.apache.myfaces.trinidad.event.AttributeChangeEvent;
    public class TestPagebean {
    public TestPagebean() {
    public void i1ov1_valueChangeListener(ValueChangeEvent valueChangeEvent) {
    // Add event code here...
    private UIXIterator myiter;
    public void setI1(UIXIterator myiter) {
    this.myiter=myiter;
    public UIXIterator getmyiter() {
    this.myiter=myiter;
    public UIXIterator setmyiter() {
    return myiter;
    UIXIterator valueIterator = getmyiter();
    if (!valueChangeEvent.getNewValue().equals(valueChangeEvent.getOldValue())) {
    int newPage =
    Integer.parseInt(valueChangeEvent.getNewValue().toString());
    int pageStart = (newPage) * valueIterator.getRows();
    valueIterator.setFirst(pageStart);
    AdfFacesContext.getCurrentInstance().addPartialTarget(valueIterator);
    But i am getting errors in the bean class.
    1. Block expecting }
    2. public UIXIterator getmyiter() {
    this.myiter=myiter;
    Return Statement missing
    3. Block expecting {
    4. Type or variable 'valueChangeEvent' not found
    5. Method 'getNewValue' not found
    6. Method 'getOldValue' not found
    7. Method 'toString' not found
    Can you suggest a possible solution?

  • How to create a "next" button out of image

    Hi all.
    I'm new to Dreamweaver and have no idea what I'm doing!  I'm a designer and not familiar with code.
    I've managed to get this far: I've created a teamplate and am using it successfully on subsequent pages.  My snag is that I want to create a "next" button out of an image.
    One forum poster suggested taking page_1.html and page_2.html and inserting a link between them. I get this, but in order to do so, it seems I have to detach my individual pages from the template in order to directly edit them.  Can I then somehow reattach them to the template so that I can continue to make other changes on one page that will update throughout?
    Any suggestions to a VERY green newbie that does not include copying and pasting code?  Is there a way to do this in design mode?
    thanks
    B.

    UPDATE:
    Nancy and Jon - and all future searchers with this question, I have found the answers!!!
    Here goes:
    MAKING A SIMPLE NEXT/PREVIOUS BUTTON OUT OF AN IMAGE IN DREAMWEAVER FOR THE CODE-RETARED DESIGNER:
    - Create a template which includes buttons for NEXT/PREVIOUS. The buttons should be sliced from a Photoshop file, or created using Div tags in Dreamweaver (see Tutvid.com for these tutorials - very good). The buttons should also be in their own separate Divs.
    - Select the individual Divs containing the buttons (one at a time), not the images themselves.
    - Go to Insert>Template Objects>Editable Region.
    - Give one Editable region the name of NEXT and the other editable region the name of PREVIOUS.
    - Save template file.
    - Go to page_1.html and now those buttons are selectable.  Choose the NEXT button and go to the properties panel and grab the little pick whip icon which is right beside the Link box. Drag and hold the pick whip onto your files panel and select page_2.html.  Do the same for each page.  From page_2.html onward, you also do this for the PREVIOUS button, only you select the page that comes before it, not the one after it.
    Viola!
    I really hope this helps out all you code-challenged designers like me!  I've searched everywhere and lo and behold, it was as simple as this.
    Thanks to you, Nancy, for twigging me into selecting the Div and not the graphic itself.
    BellyBuckle.

Maybe you are looking for